Backed out changeset d341f6827d75 (bug 1820119) for causing xpc failures in js/xpconnect/tests/unit/test_import_es6_modules.js CLOSED TREE

This commit is contained in:
Sandor Molnar 2023-03-16 19:18:45 +02:00
parent 4e15bb623b
commit b1ca540f9f
5 changed files with 8 additions and 75 deletions

View file

@ -1,7 +0,0 @@
import("./empty-worklet-script.js")
.then(() => {
console.log("Fail");
})
.catch(e => {
console.log(e.name + ": Success");
});

View file

@ -20,8 +20,6 @@ support-files=worklet_audioWorklet_options.js
support-files=worklet_console.js
[test_dump.html]
support-files=worklet_dump.js
[test_dynamic_import.html]
support-files=dynamic_import.js
[test_exception.html]
support-files =
worklet_exception.js

View file

@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test import() should throw a TypeError for Worklets</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="common.js"></script>
</head>
<body>
<script type="application/javascript">
const WORKLET_SCRIPT = "dynamic_import.js";
function configureTest() {
const ConsoleAPIStorage = SpecialPowers.Cc[
"@mozilla.org/consoleAPI-storage;1"
].getService(SpecialPowers.Ci.nsIConsoleAPIStorage);
// We use console API to check if a TypeError has been thrown, as worklets
// have limitations to post the result back to the main document:
// Worklets have a different global, and they don't have postMessage() APIs,
// and static import SimpleTest.js in worklets also don't work.
function consoleListener() {
this.observe = this.observe.bind(this);
ConsoleAPIStorage.addLogEventListener(this.observe, SpecialPowers.wrap(document).nodePrincipal);
}
consoleListener.prototype = {
observe(aSubject) {
var obj = aSubject.wrappedJSObject;
info("Got console message:" + obj.arguments[0]);
is(TypeError.name + ": Success", obj.arguments[0], "import() should throw");
ConsoleAPIStorage.removeLogEventListener(this.observe);
SimpleTest.finish();
}
}
var cl = new consoleListener();
return SpecialPowers.pushPrefEnv(
{"set": [["dom.audioworklet.enabled", true],
["dom.worklet.enabled", true]]});
}
// This function is called into an iframe.
function runTestInIframe() {
var audioContext = new AudioContext();
audioContext.audioWorklet.addModule(WORKLET_SCRIPT);
}
</script>
</body>
</html>

View file

@ -318,10 +318,7 @@ bool ModuleLoaderBase::HostImportModuleDynamically(
aCx, uri, script, aReferencingPrivate, specifierString, aPromise);
if (!request) {
// Throws TypeError if CreateDynamicImport returns nullptr.
JS_ReportErrorNumberASCII(aCx, js::GetErrorMessage, nullptr,
JSMSG_DYNAMIC_IMPORT_NOT_SUPPORTED);
JS_ReportErrorASCII(aCx, "Dynamic import not supported in this context");
return false;
}

View file

@ -692,14 +692,13 @@ MSG_DEF(JSMSG_CANT_DELETE_SUPER, 0, JSEXN_REFERENCEERR, "invalid delete involvin
MSG_DEF(JSMSG_REINIT_THIS, 0, JSEXN_REFERENCEERR, "super() called twice in derived class constructor")
// Modules
MSG_DEF(JSMSG_MISSING_INDIRECT_EXPORT, 0, JSEXN_SYNTAXERR, "indirect export not found")
MSG_DEF(JSMSG_AMBIGUOUS_INDIRECT_EXPORT, 0, JSEXN_SYNTAXERR, "ambiguous indirect export")
MSG_DEF(JSMSG_MISSING_IMPORT, 0, JSEXN_SYNTAXERR, "import not found")
MSG_DEF(JSMSG_AMBIGUOUS_IMPORT, 0, JSEXN_SYNTAXERR, "ambiguous import")
MSG_DEF(JSMSG_MISSING_EXPORT, 1, JSEXN_SYNTAXERR, "local binding for export '{0}' not found")
MSG_DEF(JSMSG_BAD_MODULE_STATUS, 1, JSEXN_INTERNALERR, "module record has unexpected status: {0}")
MSG_DEF(JSMSG_DYNAMIC_IMPORT_FAILED, 0, JSEXN_TYPEERR, "error loading dynamically imported module")
MSG_DEF(JSMSG_DYNAMIC_IMPORT_NOT_SUPPORTED, 0, JSEXN_TYPEERR, "Dynamic import not supported in this context")
MSG_DEF(JSMSG_MISSING_INDIRECT_EXPORT, 0, JSEXN_SYNTAXERR, "indirect export not found")
MSG_DEF(JSMSG_AMBIGUOUS_INDIRECT_EXPORT, 0, JSEXN_SYNTAXERR, "ambiguous indirect export")
MSG_DEF(JSMSG_MISSING_IMPORT, 0, JSEXN_SYNTAXERR, "import not found")
MSG_DEF(JSMSG_AMBIGUOUS_IMPORT, 0, JSEXN_SYNTAXERR, "ambiguous import")
MSG_DEF(JSMSG_MISSING_EXPORT, 1, JSEXN_SYNTAXERR, "local binding for export '{0}' not found")
MSG_DEF(JSMSG_BAD_MODULE_STATUS, 1, JSEXN_INTERNALERR, "module record has unexpected status: {0}")
MSG_DEF(JSMSG_DYNAMIC_IMPORT_FAILED, 0, JSEXN_TYPEERR, "error loading dynamically imported module")
// Import maps
MSG_DEF(JSMSG_IMPORT_MAPS_PARSE_FAILED, 1, JSEXN_SYNTAXERR, "Failed to parse import map: Invalid JSON format. {0}")