diff --git a/app/renderer/components/frame/frame.js b/app/renderer/components/frame/frame.js index 25d3f0c5a00..8113e45ec6f 100644 --- a/app/renderer/components/frame/frame.js +++ b/app/renderer/components/frame/frame.js @@ -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)) } } diff --git a/test/bravery-components/noScriptTest.js b/test/bravery-components/noScriptTest.js index f1aa342ebcb..deedcb584f8 100644 --- a/test/bravery-components/noScriptTest.js +++ b/test/bravery-components/noScriptTest.js @@ -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 () {