Bug 1582512 - Disable the javascript filename load restriction on specific tests r=jdescottes

Certain tests load data: URIs, blob: URIs, or otherwise do unusual things
that mean we need to disable the restriction for them.

Differential Revision: https://phabricator.services.mozilla.com/D46501

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Ritter 2019-12-02 17:27:24 +00:00
Родитель d5a5b3aad0
Коммит 0fda120100
13 изменённых файлов: 61 добавлений и 6 удалений

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

@ -29,6 +29,8 @@ async function test() {
"privacy.resistFingerprinting.reduceTimerPrecision.microseconds",
2000
);
// Needed for a loadFrameScript(data:) call in helper_codemirror_runner.js
await pushPref("security.allow_parent_unrestricted_js_loads", true);
const tab = await addTab(URI);
runCodeMirrorTest(tab.linkedBrowser);

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

@ -8,11 +8,13 @@ const URI =
"/shared/sourceeditor/test/codemirror/vimemacs.html";
loadHelperScript("helper_codemirror_runner.js");
function test() {
async function test() {
requestLongerTimeout(4);
waitForExplicitFinish();
addTab(URI).then(function(tab) {
runCodeMirrorTest(tab.linkedBrowser);
});
// Needed for a loadFrameScript(data:) call in helper_codemirror_runner.js
await pushPref("security.allow_parent_unrestricted_js_loads", true);
const tab = await addTab(URI);
runCodeMirrorTest(tab.linkedBrowser);
}

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

@ -21,6 +21,8 @@ const TEST_IMAGE =
"test/test-image.png";
add_task(async function() {
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
await pushPref("devtools.browserconsole.contentMessages", true);
await addTab(TEST_URI);

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

@ -7,6 +7,9 @@
"use strict";
add_task(async function() {
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
// Show the content messages
await pushPref("devtools.browserconsole.contentMessages", true);

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

@ -12,6 +12,9 @@ const {
} = require("devtools/client/framework/devtools-browser");
add_task(async function() {
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
await addTab("about:blank");
const hud = await BrowserConsoleManager.openBrowserConsoleOrFocus();

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

@ -13,6 +13,9 @@
"use strict";
add_task(async function() {
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
const hud = await BrowserConsoleManager.toggleBrowserConsole();
ok(hud, "browser console opened");

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

@ -10,6 +10,8 @@ const TEST_URI =
"data:text/html;charset=utf-8,Top-level await Browser Console test";
add_task(async function() {
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
// Enable await mapping.
await pushPref("devtools.debugger.features.map-await-expression", true);

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

@ -9,6 +9,9 @@ const TEST_URI =
"data:text/html;charset=utf-8,Web Console test failing top-level await";
add_task(async function() {
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
// Enable await mapping.
await pushPref("devtools.debugger.features.map-await-expression", true);
const hud = await openNewTabAndConsole(TEST_URI);

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

@ -26,6 +26,9 @@ requestLongerTimeout(2);
add_task(async function() {
let browserConsole, webConsole, objInspector;
// Needed for the execute() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
// We don't use `pushPref()` because we need to revert the same pref later
// in the test.
Services.prefs.setBoolPref("devtools.chrome.enabled", true);

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

@ -26,6 +26,8 @@ Services.scriptloader.loadSubScript(
add_task(async function() {
await pushPref("devtools.browsertoolbox.fission", true);
// Needed for the invokeInTab() function below
await pushPref("security.allow_parent_unrestricted_js_loads", true);
await addTab(TEST_URI);
const ToolboxTask = await initBrowserToolboxTask();

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

@ -37,7 +37,8 @@ add_task(async function() {
global,
undefined,
"test-file.js",
1
1,
/* enforceFilenameRestrictions */ false
);
/* eslint-enable no-undef */
@ -58,7 +59,14 @@ add_task(async function() {
` + ${afterCreation - before} -> ${afterCreation})`
);
Cu.evalInSandbox("list = null;", global, undefined, "test-file.js", 7);
Cu.evalInSandbox(
"list = null;",
global,
undefined,
"test-file.js",
7,
/* enforceFilenameRestrictions */ false
);
Cu.forceGC();
Cu.forceCC();

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

@ -20,6 +20,10 @@ const WORKER_DATA = (function() {
const INTERVAL = 100;
const DURATION = 1000;
registerCleanupFunction(function() {
Services.prefs.clearUserPref("security.allow_parent_unrestricted_js_loads");
});
add_task(async function() {
// Test both CJS and JSM versions
@ -31,6 +35,11 @@ add_task(async function() {
});
async function testWorker(context, workerFactory) {
// Needed for blob:null
Services.prefs.setBoolPref(
"security.allow_parent_unrestricted_js_loads",
true
);
const { DevToolsWorker, workerify } = workerFactory();
const worker = new DevToolsWorker(WORKER_URL);
const results = await worker.performTask("plotTimestampsGraph", {
@ -52,6 +61,10 @@ async function testWorker(context, workerFactory) {
}
async function testTransfer() {
Services.prefs.setBoolPref(
"security.allow_parent_unrestricted_js_loads",
true
);
const { workerify } = ChromeUtils.import(
"resource://devtools/shared/worker/worker.js"
);

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

@ -25,7 +25,16 @@ function squarePromiseReject(x) {
return new Promise((_, reject) => reject("Nope"));
}
registerCleanupFunction(function() {
Services.prefs.clearUserPref("security.allow_parent_unrestricted_js_loads");
});
add_task(async function() {
// Needed for blob:null
Services.prefs.setBoolPref(
"security.allow_parent_unrestricted_js_loads",
true
);
let fn = workerify(square);
is(await fn(5), 25, "return primitives successful");
fn.destroy();