Commit 4d6b5d36 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[Import Maps] Split out WPT tests related to built-in modules

This CL splits some WPT tests into
- wpt/import-maps/core/ that tests the core features after
  https://github.com/WICG/import-maps/pull/176, and
- wpt/import-maps/builtin-support.tentative/ that
  requires pre-#176 built-in module and fallback support,

in order to test builtin- and non-builtin- versions easier.

Bug: 1010751
Change-Id: I9f4793f64fa0ad267fa1d4e43d5597d94a5cc541
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1839428
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarDomenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706510}
parent a0e3c3a1
......@@ -2,7 +2,7 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// "bare/..." (i.e. without leading "./") are bare specifiers
......@@ -15,16 +15,10 @@
const importMap = `
{
"imports": {
"bare/bare": "./resources/log.js?pipe=sub&name=bare",
"bare/cross-origin-bare": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-bare",
"bare/to-data": "data:text/javascript,log.push('dataURL')",
"bare/std-blank": "std:blank",
"bare/blank": "@std/blank",
"bare/std-none": "std:none",
"bare/none": "@std/none",
"bare/to-bare": "bare/bare"
"bare/none": "@std/none"
}
}
`;
......@@ -41,16 +35,6 @@ const tests = {
// a parse error, not fetch error. Therefore, we use Result.PARSE_ERROR
// below. https://crbug.com/928435
// Bare to HTTP(S).
"bare/bare":
[Result.URL, Result.URL, "log:bare", "log:bare"],
"bare/cross-origin-bare":
[Result.URL, Result.URL, "log:cross-origin-bare", "log:cross-origin-bare"],
// Bare to data:
"bare/to-data":
[Result.URL, Result.URL, "dataURL", "dataURL"],
// Bare to built-in.
"bare/std-blank":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
......@@ -60,10 +44,6 @@ const tests = {
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
"bare/none":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
// Bare to bare mapping is disabled.
"bare/to-bare":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
};
doTests(importMap, null, tests);
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
const importMap = `
{
"imports": {
"./resources/log.js?pipe=sub&name=empty": [ "@std/" ],
"./resources/log.js?pipe=sub&name=empty-fallback": [
"../resources/log.js?pipe=sub&name=empty": [ "@std/" ],
"../resources/log.js?pipe=sub&name=empty-fallback": [
"@std/",
"./resources/log.js?pipe=sub&name=empty-fallback"
"../resources/log.js?pipe=sub&name=empty-fallback"
]
}
}
......@@ -32,9 +32,9 @@ const tests = {
"@std/":
[Result.FETCH_ERROR, Result.PARSE_ERROR, Result.FETCH_ERROR, Result.FETCH_ERROR],
"./resources/log.js?pipe=sub&name=empty":
"../resources/log.js?pipe=sub&name=empty":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
"./resources/log.js?pipe=sub&name=empty-fallback":
"../resources/log.js?pipe=sub&name=empty-fallback":
[Result.URL, Result.URL, Result.URL, Result.URL],
};
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
const tests = {
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
const tests = {
......
......@@ -2,7 +2,7 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// "bare/..." (i.e. without leading "./") are bare specifiers
......@@ -15,18 +15,10 @@
const importMap = `
{
"imports": {
"bare": "./resources/log.js?pipe=sub&name=bare",
"data:text/javascript,log.push('data:foo')": "./resources/log.js?pipe=sub&name=foo",
"data:text/javascript,log.push('data:cross-origin-foo')": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo",
"data:text/javascript,log.push('data:to-data')": "data:text/javascript,log.push('dataURL')",
"data:text/javascript,log.push('data:std-blank')": "std:blank",
"data:text/javascript,log.push('data:blank')": "@std/blank",
"data:text/javascript,log.push('data:std-none')": "std:none",
"data:text/javascript,log.push('data:none')": "@std/none",
"data:text/javascript,log.push('data:to-bare')": "bare"
"data:text/javascript,log.push('data:none')": "@std/none"
}
}
`;
......@@ -43,16 +35,6 @@ const tests = {
// a parse error, not fetch error. Therefore, we use Result.PARSE_ERROR
// below. https://crbug.com/928435
// data: to HTTP(S).
"data:text/javascript,log.push('data:foo')":
[Result.URL, Result.URL, "log:foo", "log:foo"],
"data:text/javascript,log.push('data:cross-origin-foo')":
[Result.URL, Result.URL, "log:cross-origin-foo", "log:cross-origin-foo"],
// data: to data:
"data:text/javascript,log.push('data:to-data')":
[Result.URL, Result.URL, "dataURL", "dataURL"],
// data: to built-in.
"data:text/javascript,log.push('data:std-blank')":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
......@@ -62,10 +44,6 @@ const tests = {
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
"data:text/javascript,log.push('data:none')":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
// data: to bare mapping is disabled.
"data:text/javascript,log.push('data:to-bare')":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
};
doTests(importMap, null, tests);
......
......@@ -2,7 +2,7 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// Fallbacks from external URLs (such as HTTPS URLs) are
......@@ -18,51 +18,51 @@
const importMap = `
{
"imports": {
"bare": "./resources/log.js?pipe=sub&name=bare",
"bare": "../resources/log.js?pipe=sub&name=bare",
"./resources/log.js?pipe=sub&name=http-to-builtin": [
"./resources/log.js?pipe=sub&name=http-to-builtin",
"../resources/log.js?pipe=sub&name=http-to-builtin": [
"../resources/log.js?pipe=sub&name=http-to-builtin",
"@std/blank"
],
"./resources/log.js?pipe=sub&name=fallback-to-different-url-1": [
"../resources/log.js?pipe=sub&name=fallback-to-different-url-1": [
"@std/blank",
"./resources/log.js?pipe=sub&name=something-different"
"../resources/log.js?pipe=sub&name=something-different"
],
"./resources/log.js?pipe=sub&name=fallback-to-different-url-2": [
"../resources/log.js?pipe=sub&name=fallback-to-different-url-2": [
"@std/none",
"./resources/log.js?pipe=sub&name=something-different2"
"../resources/log.js?pipe=sub&name=something-different2"
],
"./resources/log.js?pipe=sub&name=fallback-to-different-origin-1": [
"../resources/log.js?pipe=sub&name=fallback-to-different-origin-1": [
"@std/blank",
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=fallback-to-different-origin-1"
],
"./resources/log.js?pipe=sub&name=fallback-to-different-origin-2": [
"../resources/log.js?pipe=sub&name=fallback-to-different-origin-2": [
"@std/none",
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=fallback-to-different-origin-2"
],
"./resources/log.js?pipe=sub&name=more-than-two-values-1": [
"../resources/log.js?pipe=sub&name=more-than-two-values-1": [
"@std/none",
"@std/blank",
"./resources/log.js?pipe=sub&name=more-than-two-values-1"
"../resources/log.js?pipe=sub&name=more-than-two-values-1"
],
"./resources/log.js?pipe=sub&name=more-than-two-values-2": [
"../resources/log.js?pipe=sub&name=more-than-two-values-2": [
"@std/none",
"./resources/log.js?pipe=sub&name=more-than-two-values-2",
"../resources/log.js?pipe=sub&name=more-than-two-values-2",
"@std/blank"
],
"./resources/log.js?pipe=sub&name=fallback-from-http": [
"./resources/log.js?pipe=sub&name=non-built-in",
"./resources/log.js?pipe=sub&name=fallback-from-http"
"../resources/log.js?pipe=sub&name=fallback-from-http": [
"../resources/log.js?pipe=sub&name=non-built-in",
"../resources/log.js?pipe=sub&name=fallback-from-http"
],
"./resources/log.js?pipe=sub&name=fallback-from-data-1": [
"../resources/log.js?pipe=sub&name=fallback-from-data-1": [
"data:text/plain,",
"./resources/log.js?pipe=sub&name=fallback-from-http"
"../resources/log.js?pipe=sub&name=fallback-from-http"
],
"./resources/log.js?pipe=sub&name=fallback-from-data-2": [
"../resources/log.js?pipe=sub&name=fallback-from-data-2": [
"data:text/javascript,log.push('dataURL')",
"./resources/log.js?pipe=sub&name=fallback-from-http"
"../resources/log.js?pipe=sub&name=fallback-from-http"
]
}
}
......
......@@ -2,7 +2,7 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// This tests is for fallbacks with the pattern of
......@@ -16,13 +16,13 @@
const importMap = `
{
"imports": {
"./resources/log.js?pipe=sub&name=blank": [
"../resources/log.js?pipe=sub&name=blank": [
"@std/blank",
"./resources/log.js?pipe=sub&name=blank"
"../resources/log.js?pipe=sub&name=blank"
],
"./resources/log.js?pipe=sub&name=none": [
"../resources/log.js?pipe=sub&name=none": [
"@std/none",
"./resources/log.js?pipe=sub&name=none"
"../resources/log.js?pipe=sub&name=none"
],
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-blank": [
"@std/blank",
......@@ -33,13 +33,13 @@ const importMap = `
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-none"
],
"./resources/log.js?pipe=sub&name=std-blank": [
"../resources/log.js?pipe=sub&name=std-blank": [
"std:blank",
"./resources/log.js?pipe=sub&name=std-blank"
"../resources/log.js?pipe=sub&name=std-blank"
],
"./resources/log.js?pipe=sub&name=std-none": [
"../resources/log.js?pipe=sub&name=std-none": [
"std:none",
"./resources/log.js?pipe=sub&name=std-none"
"../resources/log.js?pipe=sub&name=std-none"
],
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=std-cross-origin-blank": [
"std:blank",
......@@ -61,18 +61,18 @@ const tests = {
// - dynamic import.
// Result.URL indicates that the specifier was not re-mapped by import maps,
// i.e. either considered as a relative path, or fallback occured.
"./resources/log.js?pipe=sub&name=blank":
"../resources/log.js?pipe=sub&name=blank":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
"./resources/log.js?pipe=sub&name=none":
"../resources/log.js?pipe=sub&name=none":
[Result.URL, Result.URL, Result.URL, Result.URL],
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-blank":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-none":
[Result.URL, Result.URL, Result.URL, Result.URL],
"./resources/log.js?pipe=sub&name=std-blank":
"../resources/log.js?pipe=sub&name=std-blank":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
"./resources/log.js?pipe=sub&name=std-none":
"../resources/log.js?pipe=sub&name=std-none":
[Result.URL, Result.URL, Result.URL, Result.URL],
"https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=std-cross-origin-blank":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// "bare/..." (i.e. without leading "./") are bare specifiers
......@@ -14,18 +14,10 @@
const importMap = `
{
"imports": {
"bare": "./resources/log.js?pipe=sub&name=bare",
"./resources/log.js?pipe=sub&name=foo": "./resources/log.js?pipe=sub&name=bar",
"./resources/log.js?pipe=sub&name=cross-origin-foo": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-bar",
"./resources/log.js?pipe=sub&name=to-data": "data:text/javascript,log.push('dataURL')",
"./resources/log.js?pipe=sub&name=std-blank": "std:blank",
"./resources/log.js?pipe=sub&name=blank": "@std/blank",
"./resources/log.js?pipe=sub&name=std-none": "std:none",
"./resources/log.js?pipe=sub&name=none": "@std/none",
"./resources/log.js?pipe=sub&name=to-bare": "bare"
"../resources/log.js?pipe=sub&name=std-blank": "std:blank",
"../resources/log.js?pipe=sub&name=blank": "@std/blank",
"../resources/log.js?pipe=sub&name=std-none": "std:none",
"../resources/log.js?pipe=sub&name=none": "@std/none"
}
}
`;
......@@ -42,16 +34,6 @@ const tests = {
// a parse error, not fetch error. Therefore, we use Result.PARSE_ERROR
// below. https://crbug.com/928435
// HTTP(S) to HTTP(S).
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=foo":
[Result.URL, Result.URL, "log:bar", "log:bar"],
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo":
[Result.URL, Result.URL, "log:cross-origin-bar", "log:cross-origin-bar"],
// HTTP(S) to data:
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=to-data":
[Result.URL, Result.URL, "dataURL", "dataURL"],
// HTTP(S) to built-in.
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=std-blank":
[Result.URL, Result.URL, Result.BUILTIN, Result.BUILTIN],
......@@ -61,10 +43,6 @@ const tests = {
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=none":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
// HTTP(S) to bare mapping is disabled.
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=to-bare":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
};
doTests(importMap, null, tests);
......
<!DOCTYPE html>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// "bare/..." (i.e. without leading "./") are bare specifiers
// (not relative paths).
const importMap = `
{
"imports": {
"bare/bare": "../resources/log.js?pipe=sub&name=bare",
"bare/cross-origin-bare": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-bare",
"bare/to-data": "data:text/javascript,log.push('dataURL')",
"bare/to-bare": "bare/bare"
}
}
`;
const tests = {
// Arrays of expected results for:
// - <script src type="module">,
// - <script src> (classic script),
// - static import, and
// - dynamic import.
// Currently, Chromium's implementation resolves import maps as a part of
// specifier resolution, and thus failure in import map resolution causes
// a parse error, not fetch error. Therefore, we use Result.PARSE_ERROR
// below. https://crbug.com/928435
// Bare to HTTP(S).
"bare/bare":
[Result.URL, Result.URL, "log:bare", "log:bare"],
"bare/cross-origin-bare":
[Result.URL, Result.URL, "log:cross-origin-bare", "log:cross-origin-bare"],
// Bare to data:
"bare/to-data":
[Result.URL, Result.URL, "dataURL", "dataURL"],
// Bare to bare mapping is disabled.
"bare/to-bare":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
};
doTests(importMap, null, tests);
</script>
<body>
<!DOCTYPE html>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// "bare/..." (i.e. without leading "./") are bare specifiers
// (not relative paths).
const importMap = `
{
"imports": {
"bare": "../resources/log.js?pipe=sub&name=bare",
"data:text/javascript,log.push('data:foo')": "../resources/log.js?pipe=sub&name=foo",
"data:text/javascript,log.push('data:cross-origin-foo')": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo",
"data:text/javascript,log.push('data:to-data')": "data:text/javascript,log.push('dataURL')",
"data:text/javascript,log.push('data:to-bare')": "bare"
}
}
`;
const tests = {
// Arrays of expected results for:
// - <script src type="module">,
// - <script src> (classic script),
// - static import, and
// - dynamic import.
// Currently, Chromium's implementation resolves import maps as a part of
// specifier resolution, and thus failure in import map resolution causes
// a parse error, not fetch error. Therefore, we use Result.PARSE_ERROR
// below. https://crbug.com/928435
// data: to HTTP(S).
"data:text/javascript,log.push('data:foo')":
[Result.URL, Result.URL, "log:foo", "log:foo"],
"data:text/javascript,log.push('data:cross-origin-foo')":
[Result.URL, Result.URL, "log:cross-origin-foo", "log:cross-origin-foo"],
// data: to data:
"data:text/javascript,log.push('data:to-data')":
[Result.URL, Result.URL, "dataURL", "dataURL"],
// data: to bare mapping is disabled.
"data:text/javascript,log.push('data:to-bare')":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
};
doTests(importMap, null, tests);
</script>
<body>
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-helper.js"></script>
<script>
// "bare/..." (i.e. without leading "./") are bare specifiers
// (not relative paths).
const importMap = `
{
"imports": {
"bare": "../resources/log.js?pipe=sub&name=bare",
"../resources/log.js?pipe=sub&name=foo": "../resources/log.js?pipe=sub&name=bar",
"../resources/log.js?pipe=sub&name=cross-origin-foo": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-bar",
"../resources/log.js?pipe=sub&name=to-data": "data:text/javascript,log.push('dataURL')",
"../resources/log.js?pipe=sub&name=to-bare": "bare"
}
}
`;
const tests = {
// Arrays of expected results for:
// - <script src type="module">,
// - <script src> (classic script),
// - static import, and
// - dynamic import.
// Currently, Chromium's implementation resolves import maps as a part of
// specifier resolution, and thus failure in import map resolution causes
// a parse error, not fetch error. Therefore, we use Result.PARSE_ERROR
// below. https://crbug.com/928435
// HTTP(S) to HTTP(S).
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=foo":
[Result.URL, Result.URL, "log:bar", "log:bar"],
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo":
[Result.URL, Result.URL, "log:cross-origin-bar", "log:cross-origin-bar"],
// HTTP(S) to data:
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=to-data":
[Result.URL, Result.URL, "dataURL", "dataURL"],
// HTTP(S) to bare mapping is disabled.
"{{location[server]}}/import-maps/resources/log.js?pipe=sub&name=to-bare":
[Result.URL, Result.URL, Result.PARSE_ERROR, Result.PARSE_ERROR],
};
doTests(importMap, null, tests);
</script>
<body>
......@@ -5,7 +5,7 @@
<script type="importmap">
{
"imports": {
"./resources/log.js?pipe=sub&name=A": "./resources/log.js?pipe=sub&name=B"
"../resources/log.js?pipe=sub&name=A": "../resources/log.js?pipe=sub&name=B"
}
}
</script>
......@@ -17,8 +17,8 @@ const log = [];
// key will become the URL/specifier BEFORE import map resolution.
// https://crbug.com/928435
promise_test(() => {
return import("./resources/log.js?pipe=sub&name=A")
.then(() => import("./resources/log.js?pipe=sub&name=B"))
return import("../resources/log.js?pipe=sub&name=A")
.then(() => import("../resources/log.js?pipe=sub&name=B"))
.then(() => assert_array_equals(log, ["log:B"]))
},
"Module map's key is the URL after import map resolution");
......
......@@ -153,7 +153,7 @@ function testStaticImport(importMapString, importMapBaseURL, specifier, expected
const script = document.createElement("script");
script.setAttribute("type", "module");
script.setAttribute("src",
"/import-maps/static-import.js?pipe=sub(none)&url=" +
"static-import.js?pipe=sub(none)&url=" +
encodeURIComponent("${specifier}"));
script.addEventListener("load", handlers[Handler.ScriptLoadEvent]);
script.addEventListener("error", handlers[Handler.ScriptErrorEvent]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment