From 7012b948f9d1374a1df6c0f9e0afe240ed2d5645 Mon Sep 17 00:00:00 2001 From: yan Date: Wed, 10 May 2017 00:19:16 +0000 Subject: [PATCH] noscript exceptions from private tabs should not apply to regular tabs fix https://github.com/brave/browser-laptop/issues/8779 Test Plan: 1. disable scripts on twitter.com 2. open twitter.com in a private tab. scripts should be disabled. 3. click the noscript icon to allow scripts in the private tab. it should work. 4. load twitter again in a regular tab. scripts should still be disabled. --- js/actions/appActions.js | 6 ++++-- js/components/noScriptInfo.js | 2 +- js/stores/appStore.js | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/js/actions/appActions.js b/js/actions/appActions.js index 93b8a96201f..db3fbe61d0a 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -943,12 +943,14 @@ const appActions = { * Dispatches a message when noscript exceptions are added for an origin * @param {string} hostPattern * @param {Object.} origins + * @param {boolean} temporary */ - noScriptExceptionsAdded: function (hostPattern, origins) { + noScriptExceptionsAdded: function (hostPattern, origins, temporary) { AppDispatcher.dispatch({ actionType: appConstants.APP_ADD_NOSCRIPT_EXCEPTIONS, hostPattern, - origins + origins, + temporary }) }, diff --git a/js/components/noScriptInfo.js b/js/components/noScriptInfo.js index 11a3adfb1ac..db26fc0271e 100644 --- a/js/components/noScriptInfo.js +++ b/js/components/noScriptInfo.js @@ -84,7 +84,7 @@ class NoScriptInfo extends ImmutableComponent { } }) if (checkedOrigins.filter((value) => value !== false).size) { - appActions.noScriptExceptionsAdded(this.origin, checkedOrigins) + appActions.noScriptExceptionsAdded(this.origin, checkedOrigins, this.isPrivate) this.reload() this.props.onHide() } diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 93f051c2e61..51840518c58 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -562,15 +562,18 @@ const handleAppAction = (action) => { break } case appConstants.APP_ADD_NOSCRIPT_EXCEPTIONS: - // Note that this is always cleared on restart or reload, so should not - // be synced or persisted. - let key = 'noScriptExceptions' - if (!action.origins || !action.origins.size) { - // Clear the exceptions - appState = appState.setIn(['siteSettings', action.hostPattern, key], new Immutable.Map()) - } else { - const currentExceptions = appState.getIn(['siteSettings', action.hostPattern, key]) || new Immutable.Map() - appState = appState.setIn(['siteSettings', action.hostPattern, key], currentExceptions.merge(action.origins)) + { + const propertyName = action.temporary ? 'temporarySiteSettings' : 'siteSettings' + // Note that this is always cleared on restart or reload, so should not + // be synced or persisted. + const key = 'noScriptExceptions' + if (!action.origins || !action.origins.size) { + // Clear the exceptions + appState = appState.setIn([propertyName, action.hostPattern, key], new Immutable.Map()) + } else { + const currentExceptions = appState.getIn([propertyName, action.hostPattern, key]) || new Immutable.Map() + appState = appState.setIn([propertyName, action.hostPattern, key], currentExceptions.merge(action.origins)) + } } break case appConstants.APP_UPDATE_LEDGER_INFO: