Bug 1328013 - Do not collect the flag of `allowJavascript` DocShell capabilities. r=mikedeboer

This commit is contained in:
Will Wang 2017-07-10 16:56:48 +08:00
Родитель 8893010bae
Коммит 47e943466e
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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.