-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7748df
commit 19e9d13
Showing
11 changed files
with
137 additions
and
51 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.any.js
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,32 @@ | ||
// META: global=window,dedicatedworker,sharedworker | ||
// META: script=ticker.js | ||
|
||
promise_test(async t => { | ||
const getCount = ticker(1000); | ||
|
||
const importP = import("<invalid>"); | ||
await promise_rejects_js(t, TypeError, importP, 'import() should reject'); | ||
|
||
assert_less_than(getCount(), 1000); | ||
}, "import() should not drain the microtask queue if it fails during specifier resolution"); | ||
|
||
promise_test(async t => { | ||
// Use Date.now() to ensure that the module is not in the module map | ||
const specifier = "./empty-module.js?" + Date.now(); | ||
|
||
await import(specifier); | ||
|
||
const getCount = ticker(1000); | ||
await import(specifier); | ||
assert_less_than(getCount(), 1000); | ||
}, "import() should not drain the microtask queue when loading an already loaded module"); | ||
|
||
promise_test(async t => { | ||
// Use Date.now() to ensure that the module is not in the module map | ||
const specifier = "./empty-module.js?" + Date.now(); | ||
|
||
const getCount = ticker(1e7); | ||
await import(specifier); | ||
assert_equals(getCount(), 1e7); | ||
}, "import() should drain the microtask queue when fetching a new module"); | ||
|
32 changes: 0 additions & 32 deletions
32
html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.html
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...ripting-1/the-script-element/module/dynamic-import/microtasks/css-import-in-worker.any.js
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,14 @@ | ||
// META: global=dedicatedworker,sharedworker | ||
// META: script=ticker.js | ||
|
||
promise_test(async t => { | ||
// Use Date.now() to ensure that the module is not in the module map | ||
const specifier = "./empty-module.css?" + Date.now(); | ||
|
||
const getCount = ticker(1000); | ||
|
||
const importP = import(specifier, { assert: { type: "css" } }); | ||
await promise_rejects_js(t, TypeError, importP, 'import() should reject'); | ||
|
||
assert_less_than(getCount(), 1000); | ||
}, "import() should not drain the microtask queue if it fails because of the 'type: css' assertion in a worker"); |
4 changes: 4 additions & 0 deletions
4
...emantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.css
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 @@ | ||
/* | ||
This file is empty, because all it matters is if the | ||
dynamic import that loads it fails or succedes. | ||
*/ |
4 changes: 4 additions & 0 deletions
4
...semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.js
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 @@ | ||
/* | ||
This file is empty, because all it matters is if the | ||
dynamic import that loads it fails or succedes. | ||
*/ |
14 changes: 14 additions & 0 deletions
14
...tics/scripting-1/the-script-element/module/dynamic-import/microtasks/serviceworker.any.js
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,14 @@ | ||
// META: global=serviceworker | ||
// META: script=ticker.js | ||
|
||
promise_test(async t => { | ||
// Use Date.now() to ensure that the module is not in the module map | ||
const specifier = "./empty-module.js?" + Date.now(); | ||
|
||
const getCount = ticker(1000); | ||
|
||
const importP = import(specifier); | ||
await promise_rejects_js(t, TypeError, importP, 'import() should reject'); | ||
|
||
assert_less_than(getCount(), 1000); | ||
}, "import() should not drain the microtask queue if it fails because it's used in a ServiceWorker"); |
2 changes: 1 addition & 1 deletion
2
html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/ticker.js
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
15 changes: 15 additions & 0 deletions
15
...pting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.any.js
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,15 @@ | ||
// META: global=window,dedicatedworker,sharedworker | ||
// META: script=ticker.js | ||
|
||
promise_test(async t => { | ||
// Use Date.now() to ensure that the module is not in the module map | ||
const specifier = "./empty-module.js?" + Date.now(); | ||
|
||
const getCount = ticker(1000); | ||
|
||
const importP = import(specifier, { assert: { type: "<invalid>" } }); | ||
await promise_rejects_js(t, TypeError, importP, 'import() should reject'); | ||
|
||
assert_less_than(getCount(), 1000); | ||
}, "import() should not drain the microtask queue if it fails while validating the 'type' assertion"); | ||
|
18 changes: 0 additions & 18 deletions
18
...ripting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.html
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...emantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet-ref.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<canvas id ="output" width="100" height="100" style="background: blue;"></canvas> | ||
<script> | ||
"use strict"; | ||
const canvas = document.getElementById('output'); | ||
const ctx = canvas.getContext('2d'); | ||
|
||
ctx.fillStyle = 'green'; | ||
ctx.fillRect(0, 0, 100, 100); | ||
</script> |
43 changes: 43 additions & 0 deletions
43
html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html class="reftest-wait"> | ||
<link rel="help" href="https://html.spec.whatwg.org/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)"> | ||
<link rel="match" href="worklet-ref.html"> | ||
<style> | ||
#output { | ||
width: 100px; | ||
height: 100px; | ||
background-image: paint(rects); | ||
background-color: blue; | ||
} | ||
</style> | ||
<script src="/common/reftest-wait.js"></script> | ||
<script src="/common/worklet-reftest.js"></script> | ||
<body> | ||
<div id="output"></div> | ||
|
||
<script id="code" type="text/worklet"> | ||
registerPaint('rects', class { | ||
async paint(ctx, geom) { | ||
ctx.fillStyle = 'red'; | ||
|
||
const getCount = ticker(1000); | ||
|
||
try { | ||
// Use Date.now() to ensure that the module is not in the module map | ||
await import("./empty-module.js?" + Date.now()); | ||
} catch (e) { | ||
if (getCount() < 1000) { | ||
ctx.fillStyle = 'green'; | ||
} | ||
} | ||
ctx.fillRect(0, 0, geom.width, geom.height); | ||
} | ||
}); | ||
</script> | ||
|
||
<script> | ||
"use strict"; | ||
CSS.paintWorklet.addModule("./ticker.js").then(() => | ||
importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent) | ||
); | ||
</script> |