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

Commit

Permalink
fix noscript allow-once for selective scripts
Browse files Browse the repository at this point in the history
fix #9150

test plan:
1. block scripts globally
2. go to twitter.com
3. click the noscript icon, make sure only 'twitter.com' is checked, click 'allow once'
4. close the tab
5. open twitter.com in a new tab
3. click the noscript icon. 'twitter.com' should appear in the list.
  • Loading branch information
diracdeltas committed Jun 20, 2017
1 parent f44726d commit c5d2f7b
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 c5d2f7b

Please sign in to comment.