blob: e0326b976c3158c5f39a03eab5dee9919b8e617b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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>
|