Backed out changeset f255030d86d8 (bug 1577122) for causing talos crashes in Bug 1762611.

This commit is contained in:
Cosmin Sabou 2022-04-01 23:30:12 +03:00
parent e75208ec5b
commit ae056f8313
8 changed files with 23 additions and 35 deletions

View File

@ -31,8 +31,12 @@ server.registerPathHandler("/", (request, response) => {
response.write(HTML);
});
function getResourceURI(file) {
return Services.io.newFileURI(do_get_file(file)).spec;
}
const { AllowJavascriptParent } = ChromeUtils.import(
"resource://test/AllowJavascriptParent.jsm"
getResourceURI("AllowJavascriptParent.jsm")
);
async function assertScriptsAllowed(bc, expectAllowed, desc) {
@ -65,11 +69,11 @@ add_task(async function() {
ChromeUtils.registerWindowActor(ACTOR, {
allFrames: true,
child: {
moduleURI: "resource://test/AllowJavascriptChild.jsm",
moduleURI: getResourceURI("AllowJavascriptChild.jsm"),
events: { load: { capture: true } },
},
parent: {
moduleURI: "resource://test/AllowJavascriptParent.jsm",
moduleURI: getResourceURI("AllowJavascriptParent.jsm"),
},
});

View File

@ -14,7 +14,7 @@ function* testSteps() {
// Test for IDBKeyRange and indexedDB availability in JS modules.
const { GlobalObjectsModule } = ChromeUtils.import(
"resource://test/GlobalObjectsModule.jsm"
getSpec("GlobalObjectsModule.jsm")
);
let test = new GlobalObjectsModule();
test.ok = ok;

View File

@ -1253,12 +1253,6 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
// Note: This implies EnsureURI().
MOZ_TRY(info.EnsureResolvedURI());
// Reject imports from untrusted sources.
if ((!info.URI()->SchemeIs("resource")) &&
(!info.URI()->SchemeIs("chrome"))) {
return NS_ERROR_DOM_SECURITY_ERR;
}
// get the JAR if there is one
nsCOMPtr<nsIJARURI> jarURI;
jarURI = do_QueryInterface(info.ResolvedURI(), &rv);

View File

@ -3,8 +3,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
var file = do_get_file("syntax_error.jsm");
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var uri = ios.newFileURI(file);
try {
ChromeUtils.import("resource://test/syntax_error.jsm");
ChromeUtils.import(uri.spec);
do_throw("Failed to report any error at all");
} catch (e) {
Assert.notEqual(/^SyntaxError:/.exec(e + ''), null);

View File

@ -49,10 +49,8 @@ function run_test() {
dump("resURI: " + resURI + "\n");
var filePath = res.resolveURI(resURI);
var scope3 = {};
Assert.throws(
() => ChromeUtils.import(filePath, scope3),
/SecurityError/, "Expecting file URI not to be imported"
);
Assert.throws(() => ChromeUtils.import(filePath, scope3),
/NS_ERROR_UNEXPECTED/);
// make sure we throw when the second arg is bogus
var didThrow = false;
@ -90,12 +88,4 @@ function run_test() {
.createInstance(Ci.nsIClassInfo);
Assert.ok(Boolean(bar));
Assert.ok(bar.contractID == contractID + "2");
// make sure we throw when the URL scheme is not known
var scope4 = {};
const wrongScheme = "data:text/javascript,var a = {a:1}";
Assert.throws(
() => ChromeUtils.import(wrongScheme, scope4),
/SecurityError/, "Expecting data URI not to be imported"
);
}

View File

@ -12,15 +12,9 @@ async function runBackgroundTask(commandLine) {
// sibling `testcrasher` library to be in the current working
// directory. Fail right away if we can't find the module or the
// native library.
let cwd = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
let protocolHandler = Services.io
.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
var curDirURI = Services.io.newFileURI(cwd);
protocolHandler.setSubstitution("test", curDirURI);
let testPath = Services.dirsvc.get("CurWorkD", Ci.nsIFile).path;
const { CrashTestUtils } = ChromeUtils.import(
"resource://test/CrashTestUtils.jsm"
`file://${testPath}/CrashTestUtils.jsm`
);
// Get the temp dir.

View File

@ -53,8 +53,6 @@ TESTING_JS_MODULES += [
"ExtensionTestCommon.jsm",
"ExtensionXPCShellUtils.jsm",
"MessageChannel.jsm",
"test/xpcshell/data/TestWorkerWatcherChild.jsm",
"test/xpcshell/data/TestWorkerWatcherParent.jsm",
]
DIRS += [

View File

@ -111,12 +111,15 @@ class TestWorkerWatcher extends ExtensionCommon.EventEmitter {
registerProcessActor() {
const { JS_ACTOR_NAME } = this;
const getModuleURI = fileName =>
Services.io.newFileURI(do_get_file(`${this.dataRelPath}/${fileName}`))
.spec;
ChromeUtils.registerProcessActor(JS_ACTOR_NAME, {
parent: {
moduleURI: `resource://testing-common/${JS_ACTOR_NAME}Parent.jsm`,
moduleURI: getModuleURI(`${JS_ACTOR_NAME}Parent.jsm`),
},
child: {
moduleURI: `resource://testing-common/${JS_ACTOR_NAME}Child.jsm`,
moduleURI: getModuleURI(`${JS_ACTOR_NAME}Child.jsm`),
},
});
}