Skip to content

Commit 6b179d9

Browse files
[Import Maps] Make errors block the whole resolution, Blink-side
Reflects WICG/import-maps#205. This CL updates tests from #205. To match the behavior with the updated spec, this CL turns non-String values into `null` entries (i.e. make whole resolution fail without further fallback), instead of ignoring such entries. Other aspects were already conformant with the updated spec (i.e. weren't matching with the spec before #205). This CL updates (test-only) import maps serialization code so that it matches with the reference implementation, i.e. dump `null` entries as `null` instead of `[]`. This CL also updates spec comments. Bug: 990561, WICG/import-maps#184 Change-Id: Ifa2d04bf20fcef5575c14d135c328730ea09c454
1 parent d2c6bb0 commit 6b179d9

7 files changed

+115
-4
lines changed

import-maps/common/resolving.tentative.html

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'resources/data-base-url.json',
1616
'resources/scopes-exact-vs-prefix.json',
1717
'resources/overlapping-entries.json',
18+
'resources/resolving-null.json',
1819
]) {
1920
promise_test(() =>
2021
runTestsFromJSON(json),

import-maps/common/resources/parsing-addresses-absolute.json

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
"importMapBaseURL": "https://base.example/path1/path2/path3",
5252
"expectedParsedImportMap": {
5353
"imports": {
54+
"unparseable2": null,
55+
"unparseable3": null,
5456
"invalidButParseable1": "https://example.org/",
5557
"invalidButParseable2": "https://example.com///",
5658
"prettyNormal": "https://example.net/",

import-maps/common/resources/parsing-addresses-invalid.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
},
1414
"importMapBaseURL": "https://base.example/path1/path2/path3",
1515
"expectedParsedImportMap": {
16-
"imports": {},
16+
"imports": {
17+
"foo1": null,
18+
"foo2": null,
19+
"foo3": null,
20+
"foo4": null,
21+
"foo5": null
22+
},
1723
"scopes": {}
1824
}
1925
}

import-maps/common/resources/parsing-addresses.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
},
3030
"importMapBaseURL": "data:text/html,test",
3131
"expectedParsedImportMap": {
32-
"imports": {},
32+
"imports": {
33+
"dotSlash": null,
34+
"dotDotSlash": null,
35+
"slash": null
36+
},
3337
"scopes": {}
3438
}
3539
},
@@ -65,7 +69,15 @@
6569
},
6670
"importMapBaseURL": "https://base.example/path1/path2/path3",
6771
"expectedParsedImportMap": {
68-
"imports": {},
72+
"imports": {
73+
"dotSlash1": null,
74+
"dotDotSlash1": null,
75+
"dotSlash2": null,
76+
"dotDotSlash2": null,
77+
"slash2": null,
78+
"dotSlash3": null,
79+
"dotDotSlash3": null
80+
},
6981
"scopes": {}
7082
}
7183
}

import-maps/common/resources/parsing-schema-specifier-map.json

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
},
1919
"expectedParsedImportMap": {
2020
"imports": {
21+
"null": null,
22+
"boolean": null,
23+
"number": null,
24+
"object": null,
25+
"array": null,
26+
"array2": null,
2127
"string": "https://example.com/"
2228
},
2329
"scopes": {}

import-maps/common/resources/parsing-trailing-slashes.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
},
88
"importMapBaseURL": "https://base.example/path1/path2/path3",
99
"expectedParsedImportMap": {
10-
"imports": {},
10+
"imports": {
11+
"trailer/": null
12+
},
1113
"scopes": {}
1214
}
1315
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"importMapBaseURL": "https://example.com/app/index.html",
3+
"baseURL": "https://example.com/js/app.mjs",
4+
"name": "Entries with errors shouldn't allow fallback",
5+
"tests": {
6+
"No fallback to less-specific prefixes": {
7+
"importMap": {
8+
"imports": {
9+
"null/": "/1/",
10+
"null/b/": null,
11+
"null/b/c/": "/1/2/",
12+
"invalid-url/": "/1/",
13+
"invalid-url/b/": "https://:invalid-url:/",
14+
"invalid-url/b/c/": "/1/2/",
15+
"without-trailing-slashes/": "/1/",
16+
"without-trailing-slashes/b/": "/x",
17+
"without-trailing-slashes/b/c/": "/1/2/",
18+
"prefix-resolution-error/": "/1/",
19+
"prefix-resolution-error/b/": "data:text/javascript,/",
20+
"prefix-resolution-error/b/c/": "/1/2/"
21+
}
22+
},
23+
"expectedResults": {
24+
"null/x": "https://example.com/1/x",
25+
"null/b/x": null,
26+
"null/b/c/x": "https://example.com/1/2/x",
27+
"invalid-url/x": "https://example.com/1/x",
28+
"invalid-url/b/x": null,
29+
"invalid-url/b/c/x": "https://example.com/1/2/x",
30+
"without-trailing-slashes/x": "https://example.com/1/x",
31+
"without-trailing-slashes/b/x": null,
32+
"without-trailing-slashes/b/c/x": "https://example.com/1/2/x",
33+
"prefix-resolution-error/x": "https://example.com/1/x",
34+
"prefix-resolution-error/b/x": null,
35+
"prefix-resolution-error/b/c/x": "https://example.com/1/2/x"
36+
}
37+
},
38+
"No fallback to less-specific scopes": {
39+
"importMap": {
40+
"imports": {
41+
"null": "https://example.com/a",
42+
"invalid-url": "https://example.com/b",
43+
"without-trailing-slashes/": "https://example.com/c/",
44+
"prefix-resolution-error/": "https://example.com/d/"
45+
},
46+
"scopes": {
47+
"/js/": {
48+
"null": null,
49+
"invalid-url": "https://:invalid-url:/",
50+
"without-trailing-slashes/": "/x",
51+
"prefix-resolution-error/": "data:text/javascript,/"
52+
}
53+
}
54+
},
55+
"expectedResults": {
56+
"null": null,
57+
"invalid-url": null,
58+
"without-trailing-slashes/x": null,
59+
"prefix-resolution-error/x": null
60+
}
61+
},
62+
"No fallback to absolute URL parsing": {
63+
"importMap": {
64+
"imports": {},
65+
"scopes": {
66+
"/js/": {
67+
"https://example.com/null": null,
68+
"https://example.com/invalid-url": "https://:invalid-url:/",
69+
"https://example.com/without-trailing-slashes/": "/x",
70+
"https://example.com/prefix-resolution-error/": "data:text/javascript,/"
71+
}
72+
}
73+
},
74+
"expectedResults": {
75+
"https://example.com/null": null,
76+
"https://example.com/invalid-url": null,
77+
"https://example.com/without-trailing-slashes/x": null,
78+
"https://example.com/prefix-resolution-error/x": null
79+
}
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)