diff --git a/browser/components/sessionstore/DocShellCapabilities.jsm b/browser/components/sessionstore/DocShellCapabilities.jsm index 062dbb06c3e9..64c2d0c2136e 100644 --- a/browser/components/sessionstore/DocShellCapabilities.jsm +++ b/browser/components/sessionstore/DocShellCapabilities.jsm @@ -19,6 +19,8 @@ this.DocShellCapabilities = Object.freeze({ }, }); +const CAPABILITIES_TO_IGNORE = new Set(["Javascript"]); + /** * Internal functionality to save and restore the docShell.allow* properties. */ @@ -39,7 +41,8 @@ var DocShellCapabilitiesInternal = { collect(docShell) { let caps = this.allCapabilities(docShell); - return caps.filter(cap => !docShell["allow" + cap]); + return caps.filter(cap => !docShell["allow" + cap] + && !CAPABILITIES_TO_IGNORE.has(cap)); }, restore(docShell, disallow) { diff --git a/browser/components/sessionstore/test/browser_capabilities.js b/browser/components/sessionstore/test/browser_capabilities.js index 4a68d39c14fa..bc6a789b0214 100644 --- a/browser/components/sessionstore/test/browser_capabilities.js +++ b/browser/components/sessionstore/test/browser_capabilities.js @@ -24,6 +24,7 @@ add_task(async function docshell_capabilities() { // Flip a couple of allow* flags. docShell.allowImages = false; docShell.allowMetaRedirects = false; + docShell.allowJavascript = false; // Now reload the document to ensure that these capabilities // are taken into account. @@ -58,11 +59,15 @@ add_task(async function docshell_capabilities() { ok(!docShell.allowImages, "images not allowed"); ok(!docShell.allowMetaRedirects, "meta redirects not allowed"); + // Check that docShell allowJavascript flag is not set. + ok(docShell.allowJavascript, "Javascript still allowed"); + // Check that we correctly restored features as disabled. state = JSON.parse(ss.getTabState(tab)); disallow = new Set(state.disallow.split(",")); ok(disallow.has("Images"), "images not allowed anymore"); ok(disallow.has("MetaRedirects"), "meta redirects not allowed anymore"); + ok(!disallow.has("Javascript"), "Javascript still allowed"); is(disallow.size, 2, "two capabilities disallowed"); // Clean up after ourselves.