forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1820119 - import() should throw a TypeError in a worklet script. …
…r=jonco,yulia Differential Revision: https://phabricator.services.mozilla.com/D171563
- Loading branch information
1 parent
5036a4f
commit 19e0568
Showing
6 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import("./empty-worklet-script.js") | ||
.then(() => { | ||
console.log("Fail"); | ||
}) | ||
.catch(e => { | ||
console.log(e.name + ": Success"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters