Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worker: Add tests for import.meta.url on DedicatedWorker
Bug: 680046 Change-Id: Ieb341c5922ad247961ca477893037896dbd88ea6 Reviewed-on: https://chromium-review.googlesource.com/974726 Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#546254}
- Loading branch information
1 parent
8214a83
commit 8ccaab2
Showing
3 changed files
with
28 additions
and
0 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,23 @@ | ||
<!DOCTYPE html> | ||
<title>DedicatedWorker: import.meta</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
promise_test(() => { | ||
const script_url = 'resources/import-meta-url-worker.js'; | ||
const worker = new Worker(script_url, { type: 'module' }); | ||
return new Promise(resolve => worker.onmessage = resolve) | ||
.then(msg_event => assert_true(msg_event.data.endsWith(script_url))); | ||
}, 'Test import.meta.url on the top-level module script.'); | ||
|
||
promise_test(() => { | ||
const script_url = 'import-meta-url-worker.js'; | ||
const worker = new Worker('resources/dynamic-import-given-url-worker.js', | ||
{ type: 'module' }); | ||
worker.postMessage('./' + script_url); | ||
return new Promise(resolve => worker.onmessage = resolve) | ||
.then(msg_event => assert_true(msg_event.data.endsWith(script_url))); | ||
}, 'Test import.meta.url on the imported module script.'); | ||
|
||
</script> |
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,4 @@ | ||
// Dynamically import the script URL sent by postMessage(). | ||
self.addEventListener('message', e => { | ||
import(e.data); | ||
}); |
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 @@ | ||
postMessage(import.meta.url); |