Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Add nested flash link check
Browse files Browse the repository at this point in the history
fix #8581

Auditors: @diracdeltas, @bbondy

Test Plan:
Covered by automatic test
  • Loading branch information
darkdh committed May 8, 2017
1 parent 1f536b0 commit 7f8e77e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/extensions/brave/content/scripts/blockFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ if (adobeRegex.test(window.location.href)) {

if (chrome.contentSettings.flashEnabled == 'allow') {
document.addEventListener('click', (e) => {
let href = e.target.href || (e.target.parentNode && e.target.parentNode.href)
let node = e.target
while (!node.href && node.parentNode)
node = node.parentNode
const href = node.href
if (href && href.match(adobeRegex)) {
e.preventDefault()
chrome.ipcRenderer.send('dispatch-action', JSON.stringify([{
Expand Down
11 changes: 11 additions & 0 deletions test/bravery-components/flashTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ describe('flash install interception', function () {
return this.getText(notificationBar).then((val) => val.includes('run Flash Player'))
})
})
it('shows notification bar on nested span click', function * () {
yield this.app.client
.tabByIndex(0)
.loadUrl(this.flashUrl)
.click('#flashNestedSpan')
.windowByUrl(Brave.browserWindowUrl)
.waitForExist(notificationBar)
.waitUntil(function () {
return this.getText(notificationBar).then((val) => val.includes('run Flash Player'))
})
})
it('shows flash notification bar when small element is loaded', function * () {
const flashUrl = Brave.server.url('flash_small.html')
yield this.app.client
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/flash_interception.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@
</p>
<a id='flashLink' target='_blank' href='https://get.adobe.com/flashplayer/'>Adobe Flash</a>
</div>
<div>
<a href='https://get.adobe.com/flashplayer/'>
<div>
<span>
<span id='flashNestedSpan'>get.adobe.com/flashplayer</span>
</span>
<div>
</a>
</div>
</body>

0 comments on commit 7f8e77e

Please sign in to comment.