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

Commit

Permalink
Merge pull request #9595 from brave/fix/9150
Browse files Browse the repository at this point in the history
fix noscript allow-once for selective scripts
  • Loading branch information
bsclifton authored Jun 22, 2017
2 parents a88c8f8 + c5d2f7b commit ebec62b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/renderer/components/frame/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ class Frame extends React.Component {
}
const noScriptExceptions = activeSiteSettings.get('noScriptExceptions')
if (noScriptExceptions) {
appActions.noScriptExceptionsAdded(origin, noScriptExceptions.filter((value, host) => value !== 0))
appActions.noScriptExceptionsAdded(origin,
noScriptExceptions.map(value => value === 0 ? false : value))
}
}

Expand Down
46 changes: 46 additions & 0 deletions test/bravery-components/noScriptTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,52 @@ describe('noscript info', function () {
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(noScriptNavButton)
})

it('can selectively allow scripts once', function * () {
yield this.app.client
.tabByIndex(0)
.url(this.url)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(noScriptNavButton)
.click(noScriptNavButton)
.waitForVisible(noScriptInfo)
.waitUntil(function () {
return this.getText('.blockedOriginsList')
.then((text) => {
return text.includes('https://cdnjs.cloudflare.com') && text.includes('http://localhost:')
})
})
.click('[for="checkbox-for-https://cdnjs.cloudflare.com"]') // keep blocking cloudflare
.waitForVisible(noScriptAllowOnceButton)
.click(noScriptAllowOnceButton)
.tabByIndex(0)
.url(this.url)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(noScriptNavButton)
.click(noScriptNavButton)
.waitForVisible(noScriptInfo)
.waitUntil(function () {
return this.getText('.blockedOriginsList')
.then((text) => {
return text.includes('https://cdnjs.cloudflare.com') && !text.includes('http://localhost:')
})
})
.newTab()
.closeTabByIndex(0)
.pause(10) // wait for appstate changes
.tabByUrl(Brave.newTabUrl)
.url(this.url)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(noScriptNavButton)
.click(noScriptNavButton)
.waitForVisible(noScriptInfo)
.waitUntil(function () {
return this.getText('.blockedOriginsList')
.then((text) => {
return text.includes('https://cdnjs.cloudflare.com') && text.includes('http://localhost:')
})
})
})
})

describe('noscript', function () {
Expand Down

0 comments on commit ebec62b

Please sign in to comment.