mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1833503 - Test for importScripts. r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D181215
This commit is contained in:
parent
d81e60336d
commit
74429a25c6
@ -160,6 +160,8 @@ skip-if =
|
||||
[test_eventDispatch.html]
|
||||
[test_fibonacci.html]
|
||||
[test_importScripts.html]
|
||||
[test_importScripts_1.html]
|
||||
[test_importScripts_2.html]
|
||||
[test_importScripts_mixedcontent.html]
|
||||
tags = mcb
|
||||
[test_instanceof.html]
|
||||
|
35
dom/workers/test/test_importScripts_1.html
Normal file
35
dom/workers/test/test_importScripts_1.html
Normal file
@ -0,0 +1,35 @@
|
||||
<head>
|
||||
<title>Test for ServiceWorker importScripts</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script id="worker" type="javascript/worker">
|
||||
onconnect = async function(e) {
|
||||
e.ports[0].onmessage = async function(msg) {
|
||||
try {
|
||||
self.importScripts("N:", "");
|
||||
} catch (ex) {
|
||||
e.source.postMessage("done");
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
const blob = new Blob([document.querySelector('#worker').textContent],
|
||||
{type: "text/javascript"});
|
||||
const sw = new SharedWorker(window.URL.createObjectURL(blob));
|
||||
sw.port.postMessage([], []);
|
||||
sw.port.onmessage = function(e) {
|
||||
if (e.data == "done") {
|
||||
ok(true);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
34
dom/workers/test/test_importScripts_2.html
Normal file
34
dom/workers/test/test_importScripts_2.html
Normal file
@ -0,0 +1,34 @@
|
||||
<head>
|
||||
<title>Test for Worker importScripts</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script id="worker" type="javascript/worker">
|
||||
onmessage = async function(msg) {
|
||||
try {
|
||||
self.importScripts("N:", "");
|
||||
} catch (ex) {
|
||||
postMessage("done");
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
const blob = new Blob([document.querySelector('#worker').textContent],
|
||||
{type: "text/javascript"});
|
||||
const worker = new Worker(window.URL.createObjectURL(blob));
|
||||
worker.postMessage([], []);
|
||||
worker.onmessage = function(e) {
|
||||
if (e.data == "done") {
|
||||
ok(true);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user