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

Commit

Permalink
noscript exceptions from private tabs should not apply to regular tabs
Browse files Browse the repository at this point in the history
fix #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.
  • Loading branch information
diracdeltas committed May 10, 2017
1 parent 9b85662 commit 7012b94
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,12 +943,14 @@ const appActions = {
* Dispatches a message when noscript exceptions are added for an origin
* @param {string} hostPattern
* @param {Object.<string, (boolean|number)>} 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
})
},

Expand Down
2 changes: 1 addition & 1 deletion js/components/noScriptInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
21 changes: 12 additions & 9 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7012b94

Please sign in to comment.