-
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.
Add test for invalid import assertion
- Loading branch information
1 parent
3f80923
commit 6382a5b
Showing
3 changed files
with
35 additions
and
17 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
13 changes: 13 additions & 0 deletions
13
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function ticker(max) { | ||
let i = 0; | ||
let stop = false; | ||
Promise.resolve().then(function loop() { | ||
if (stop || i >= max) return; | ||
i++; | ||
Promise.resolve().then(loop); | ||
}); | ||
return () => { | ||
stop = true; | ||
return i; | ||
}; | ||
}; |
18 changes: 18 additions & 0 deletions
18
...ripting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.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,18 @@ | ||
<!DOCTYPE html> | ||
<title>Dynamic import interaction with microtask queue</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script type="module"> | ||
import { ticker } from "./ticker.js"; | ||
|
||
promise_test(async t => { | ||
const getCount = ticker(1000); | ||
|
||
try { | ||
await import("./../../imports-a.js", { type: "<invalid>" }); | ||
assert_unreached('import() should reject'); | ||
} catch (_) {} | ||
|
||
assert_less_than(getCount(), 1000); | ||
}, "import() should not drain the microtask queue if it fails while validating the 'type' assertion"); | ||
</script> |