Commit af81abb4 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[Import Maps] Handle non-fetch scheme URLs in keys as URLs, not as bare

Follows https://github.com/WICG/import-maps/pull/180 that removes
fetch scheme check in the spec.
(Chromium already didn't have fetch scheme checks in other callers of
`parse a URL-like import specifier`, so after this CL Chromium will
fully align with the PR #180)

Bug: 990561, 1011075
Change-Id: Ieb0c3f09ab1014d462b8ef7c898a5abe1afb5b9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1836972
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702579}
parent dd708979
...@@ -22,8 +22,6 @@ namespace blink { ...@@ -22,8 +22,6 @@ namespace blink {
namespace { namespace {
static const char kStdScheme[] = "std";
// TODO(https://crbug.com/928549): Audit and improve error messages throughout // TODO(https://crbug.com/928549): Audit and improve error messages throughout
// this file. // this file.
...@@ -72,17 +70,6 @@ String NormalizeSpecifierKey(const String& key_string, ...@@ -72,17 +70,6 @@ String NormalizeSpecifierKey(const String& key_string,
return key_string; return key_string;
case ParsedSpecifier::Type::kURL: case ParsedSpecifier::Type::kURL:
// <spec
// href="https://wicg.github.io/import-maps/#parse-a-url-like-import-specifier"
// step="4">If url’s scheme is either a fetch scheme or "std", then return
// url.</spec>
//
// TODO(hiroshige): Perhaps we should move this into ParsedSpecifier.
if (!SchemeRegistry::IsFetchScheme(key.GetUrl().Protocol()) &&
key.GetUrl().Protocol() != kStdScheme) {
// <spec step="4">Return specifierKey.</spec>
return key_string;
}
// <spec step="3">If url is not null, then return the serialization of // <spec step="3">If url is not null, then return the serialization of
// url.</spec> // url.</spec>
return key.GetImportMapKeyString(); return key.GetImportMapKeyString();
......
...@@ -3,7 +3,7 @@ PASS Relative URL-like specifier keys / should absolutize strings prefixed with ...@@ -3,7 +3,7 @@ PASS Relative URL-like specifier keys / should absolutize strings prefixed with
FAIL Relative URL-like specifier keys / should not absolutize strings prefixed with ./, ../, or / with a data: URL base assert_equals: expected "{\"../foo\":[\"https://example.com/dotdotslash\"],\"./foo\":[\"https://example.com/dotslash\"],\"/foo\":[\"https://example.com/slash\"]}" but got "{\"http://web-platform.test:8001/foo\":[\"https://example.com/slash\"],\"http://web-platform.test:8001/import-maps/foo\":[\"https://example.com/dotdotslash\"],\"http://web-platform.test:8001/import-maps/imported/foo\":[\"https://example.com/dotslash\"]}" FAIL Relative URL-like specifier keys / should not absolutize strings prefixed with ./, ../, or / with a data: URL base assert_equals: expected "{\"../foo\":[\"https://example.com/dotdotslash\"],\"./foo\":[\"https://example.com/dotslash\"],\"/foo\":[\"https://example.com/slash\"]}" but got "{\"http://web-platform.test:8001/foo\":[\"https://example.com/slash\"],\"http://web-platform.test:8001/import-maps/foo\":[\"https://example.com/dotdotslash\"],\"http://web-platform.test:8001/import-maps/imported/foo\":[\"https://example.com/dotslash\"]}"
PASS Relative URL-like specifier keys / should absolutize the literal strings ./, ../, or / with no suffix PASS Relative URL-like specifier keys / should absolutize the literal strings ./, ../, or / with no suffix
PASS Relative URL-like specifier keys / should treat percent-encoded variants of ./, ../, or / as bare specifiers PASS Relative URL-like specifier keys / should treat percent-encoded variants of ./, ../, or / as bare specifiers
PASS Absolute URL specifier keys / should only accept absolute URL specifier keys with fetch schemes, treating others as bare specifiers FAIL Absolute URL specifier keys / should only accept absolute URL specifier keys with fetch schemes, treating others as bare specifiers assert_equals: expected "{\"about:good\":[\"https://base.example/about\"],\"blob:good\":[\"https://base.example/blob\"],\"data:good\":[\"https://base.example/data\"],\"file:///good\":[\"https://base.example/file\"],\"filesystem:good\":[\"https://base.example/filesystem\"],\"ftp://good/\":[\"https://base.example/ftp/\"],\"http://good/\":[\"https://base.example/http/\"],\"https://good/\":[\"https://base.example/https/\"],\"import:bad\":[\"https://base.example/import\"],\"javascript:bad\":[\"https://base.example/javascript\"],\"mailto:bad\":[\"https://base.example/mailto\"],\"wss:bad\":[\"https://base.example/wss\"]}" but got "{\"about:good\":[\"https://base.example/about\"],\"blob:good\":[\"https://base.example/blob\"],\"data:good\":[\"https://base.example/data\"],\"file:///good\":[\"https://base.example/file\"],\"filesystem:good\":[\"https://base.example/filesystem\"],\"ftp://good/\":[\"https://base.example/ftp/\"],\"http://good/\":[\"https://base.example/http/\"],\"https://good/\":[\"https://base.example/https/\"],\"import:bad\":[\"https://base.example/import\"],\"javascript:bad\":[\"https://base.example/javascript\"],\"mailto:bad\":[\"https://base.example/mailto\"],\"wss://bad/\":[\"https://base.example/wss\"]}"
FAIL Absolute URL specifier keys / should parse absolute URLs, treating unparseable ones as bare specifiers assert_equals: expected "{\"http://[www.example.com]/\":[\"https://base.example/unparseable3/\"],\"https://ex ample.org/\":[\"https://base.example/unparseable1/\"],\"https://example.com/\":[\"https://base.example/percentDecoding/\"],\"https://example.com/%41\":[\"https://base.example/noPercentDecoding\"],\"https://example.com///\":[\"https://base.example/invalidButParseable2/\"],\"https://example.com:demo\":[\"https://base.example/unparseable2\"],\"https://example.net/\":[\"https://base.example/prettyNormal/\"],\"https://example.org/\":[\"https://base.example/invalidButParseable1/\"]}" but got "{\"http://[www.example.com]/\":[\"https://base.example/unparseable3/\"],\"https://ex%20ample.org/\":[\"https://base.example/unparseable1/\"],\"https://example.com/\":[\"https://base.example/percentDecoding/\"],\"https://example.com///\":[\"https://base.example/invalidButParseable2/\"],\"https://example.com/A\":[\"https://base.example/noPercentDecoding\"],\"https://example.com:demo\":[\"https://base.example/unparseable2\"],\"https://example.net/\":[\"https://base.example/prettyNormal/\"],\"https://example.org/\":[\"https://base.example/invalidButParseable1/\"]}" FAIL Absolute URL specifier keys / should parse absolute URLs, treating unparseable ones as bare specifiers assert_equals: expected "{\"http://[www.example.com]/\":[\"https://base.example/unparseable3/\"],\"https://ex ample.org/\":[\"https://base.example/unparseable1/\"],\"https://example.com/\":[\"https://base.example/percentDecoding/\"],\"https://example.com/%41\":[\"https://base.example/noPercentDecoding\"],\"https://example.com///\":[\"https://base.example/invalidButParseable2/\"],\"https://example.com:demo\":[\"https://base.example/unparseable2\"],\"https://example.net/\":[\"https://base.example/prettyNormal/\"],\"https://example.org/\":[\"https://base.example/invalidButParseable1/\"]}" but got "{\"http://[www.example.com]/\":[\"https://base.example/unparseable3/\"],\"https://ex%20ample.org/\":[\"https://base.example/unparseable1/\"],\"https://example.com/\":[\"https://base.example/percentDecoding/\"],\"https://example.com///\":[\"https://base.example/invalidButParseable2/\"],\"https://example.com/A\":[\"https://base.example/noPercentDecoding\"],\"https://example.com:demo\":[\"https://base.example/unparseable2\"],\"https://example.net/\":[\"https://base.example/prettyNormal/\"],\"https://example.org/\":[\"https://base.example/invalidButParseable1/\"]}"
FAIL Absolute URL specifier keys / should parse built-in module specifier keys, including with a "/" assert_equals: expected "{\"std:blank\":[\"https://base.example/blank\"],\"std:blank/\":[\"https://base.example/blank/\"],\"std:blank/foo\":[\"https://base.example/blank/foo\"],\"std:blank\\\foo\":[\"https://base.example/blank/backslashfoo\"]}" but got "{\"std:blank\":[\"https://base.example/blank\"],\"std:blank\\foo\":[\"https://base.example/blank/backslashfoo\"],\"std:blank/\":[\"https://base.example/blank/\"],\"std:blank/foo\":[\"https://base.example/blank/foo\"]}" FAIL Absolute URL specifier keys / should parse built-in module specifier keys, including with a "/" assert_equals: expected "{\"std:blank\":[\"https://base.example/blank\"],\"std:blank/\":[\"https://base.example/blank/\"],\"std:blank/foo\":[\"https://base.example/blank/foo\"],\"std:blank\\\foo\":[\"https://base.example/blank/backslashfoo\"]}" but got "{\"std:blank\":[\"https://base.example/blank\"],\"std:blank\\foo\":[\"https://base.example/blank/backslashfoo\"],\"std:blank/\":[\"https://base.example/blank/\"],\"std:blank/foo\":[\"https://base.example/blank/foo\"]}"
Harness: the test ran to completion. Harness: the test ran to completion.
......
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