Bug 1685822 [wpt PR 27117] - [Import Maps] Add tests for rejecting multiple import maps, a=testonly

Automatic update from web-platform-tests
[Import Maps] Add tests for rejecting multiple import maps

According to the spec after
https://github.com/WICG/import-maps/pull/242.

Bug: 848607
Change-Id: I21e2d494c75ddf9187d2a8d8b63bc59bccd9beb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2618680
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842149}

--

wpt-commits: 704b55147c12d54980b16f44346325ebdcd81605
wpt-pr: 27117
This commit is contained in:
Hiroshige Hayashizaki
2021-01-15 22:13:11 +00:00
committed by moz-wptsync-bot
parent ffa483ebe3
commit 6ad414c099
2 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const log = [];
</script>
<script type="importmap" onerror="log.push('onerror 1')">
{
"imports": {
"../resources/log.js?pipe=sub&name=A1": "../resources/log.js?pipe=sub&name=B1",
"../resources/log.js?pipe=sub&name=A2": "../resources/log.js?pipe=sub&name=B2"
}
}
</script>
<script type="importmap" onerror="log.push('onerror 2')">
{
"imports": {
"../resources/log.js?pipe=sub&name=A1": "../resources/log.js?pipe=sub&name=C1",
"../resources/log.js?pipe=sub&name=A3": "../resources/log.js?pipe=sub&name=C3"
}
}
</script>
<script>
// Currently the spec doesn't allow multiple import maps, by setting acquiring
// import maps to false on preparing the first import map.
promise_test(() => {
return import("../resources/log.js?pipe=sub&name=A1")
.then(() => import("../resources/log.js?pipe=sub&name=A2"))
.then(() => import("../resources/log.js?pipe=sub&name=A3"))
.then(() => assert_array_equals(
log,
["onerror 2", "log:B1", "log:B2", "log:A3"]))
},
"Second import map should be rejected");
</script>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({allow_uncaught_exception : true});
const log = [];
</script>
<script type="importmap" onerror="log.push('onerror 1')">
Parse Error
</script>
<script type="importmap" onerror="log.push('onerror 2')">
{
"imports": {
"../resources/log.js?pipe=sub&name=A": "../resources/log.js?pipe=sub&name=C"
}
}
</script>
<script>
// Currently the spec doesn't allow multiple import maps, by setting acquiring
// import maps to false on preparing the first import map.
// Even the first import map has errors and thus Document's import map is not
// updated, the second import map is still rejected at preparationg.
promise_test(() => {
return import("../resources/log.js?pipe=sub&name=A")
.then(() => assert_array_equals(
log,
["onerror 2", "log:A"]))
},
"Second import map should be rejected after an import map with errors");
</script>