script: complete resolve_module_specifier (#37552)

Implement whole spec of `resolve_module_specifier`. Servo can now
support script element with import map type!

Testing: `tests/wpt/tests/import-map`
Fixes: #37316 #36394

---------

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2025-06-21 15:17:27 +09:00 committed by GitHub
parent d7269c0f3b
commit 927573de97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 376 additions and 281 deletions

View file

@ -1,3 +0,0 @@
[dynamic-import.html]
[After a dynamic import(), import maps work fine]
expected: FAIL

View file

@ -1,3 +0,0 @@
[modulepreload-link-header.html]
[With modulepreload link header, import maps work fine]
expected: FAIL

View file

@ -1,3 +0,0 @@
[modulepreload.html]
[After <link rel=modulepreload> import maps should work fine]
expected: FAIL

View file

@ -1,3 +0,0 @@
[script-tag-inline.html]
[After inline <script type="module"> import maps work fine]
expected: FAIL

View file

@ -1,3 +0,0 @@
[script-tag.html]
[After <script type="module"> import maps work fine]
expected: FAIL

View file

@ -1,3 +0,0 @@
[worker-request.html]
[After module worker creation import maps are still effective]
expected: FAIL

View file

@ -1,27 +0,0 @@
[bare-specifiers.sub.html]
[bare/bare: static import]
expected: FAIL
[bare/bare: dynamic import (from module)]
expected: FAIL
[bare/bare: dynamic import (from text/javascript)]
expected: FAIL
[bare/cross-origin-bare: static import]
expected: FAIL
[bare/cross-origin-bare: dynamic import (from module)]
expected: FAIL
[bare/cross-origin-bare: dynamic import (from text/javascript)]
expected: FAIL
[bare/to-data: static import]
expected: FAIL
[bare/to-data: dynamic import (from module)]
expected: FAIL
[bare/to-data: dynamic import (from text/javascript)]
expected: FAIL

View file

@ -1,6 +0,0 @@
[applied-to-target-dynamic.sub.html]
[The URL after mapping violates CSP (but not the URL before mapping)]
expected: FAIL
[The URL before mapping violates CSP (but not the URL after mapping)]
expected: FAIL

View file

@ -1,6 +0,0 @@
[applied-to-target.sub.html]
[The URL after mapping violates CSP (but not the URL before mapping)]
expected: FAIL
[The URL before mapping violates CSP (but not the URL after mapping)]
expected: FAIL

View file

@ -1,3 +0,0 @@
[hash.html]
[Importmap should be accepted due to hash]
expected: FAIL

View file

@ -1,3 +0,0 @@
[nonce.html]
[Importmap should be accepted according to its correct nonce]
expected: FAIL

View file

@ -1,3 +0,0 @@
[unsafe-inline.html]
[Importmap should be accepted due to unsafe-inline]
expected: FAIL

View file

@ -1,36 +0,0 @@
[data-url-specifiers.sub.html]
[data:text/javascript,log.push('data:foo'): static import]
expected: FAIL
[data:text/javascript,log.push('data:foo'): dynamic import (from module)]
expected: FAIL
[data:text/javascript,log.push('data:foo'): dynamic import (from text/javascript)]
expected: FAIL
[data:text/javascript,log.push('data:cross-origin-foo'): static import]
expected: FAIL
[data:text/javascript,log.push('data:cross-origin-foo'): dynamic import (from module)]
expected: FAIL
[data:text/javascript,log.push('data:cross-origin-foo'): dynamic import (from text/javascript)]
expected: FAIL
[data:text/javascript,log.push('data:to-data'): static import]
expected: FAIL
[data:text/javascript,log.push('data:to-data'): dynamic import (from module)]
expected: FAIL
[data:text/javascript,log.push('data:to-data'): dynamic import (from text/javascript)]
expected: FAIL
[data:text/javascript,log.push('data:to-bare'): static import]
expected: FAIL
[data:text/javascript,log.push('data:to-bare'): dynamic import (from module)]
expected: FAIL
[data:text/javascript,log.push('data:to-bare'): dynamic import (from text/javascript)]
expected: FAIL

View file

@ -2,14 +2,11 @@
[script was not loaded, as its resolved URL failed its integrity check]
expected: FAIL
[script was loaded, as its resolved URL had no integrity check, despite its specifier having one]
expected: FAIL
[Script with no import definition was not loaded, as it failed its integrity check]
expected: FAIL
[Bare specifier used for integrity loaded, as its definition should have used the URL]
expected: FAIL
[Script imported inside an event handler was not loaded as its integrity check failed]
expected: FAIL
[Bare specifier script was not loaded, as it failed its integrity check]
expected: FAIL

View file

@ -1,36 +0,0 @@
[http-url-like-specifiers.sub.html]
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=foo: static import]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=foo: dynamic import (from module)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=foo: dynamic import (from text/javascript)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo: static import]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo: dynamic import (from module)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=cross-origin-foo: dynamic import (from text/javascript)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=to-data: static import]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=to-data: dynamic import (from module)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=to-data: dynamic import (from text/javascript)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=to-bare: static import]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=to-bare: dynamic import (from module)]
expected: FAIL
[http://web-platform.test:8000/import-maps/resources/log.js?pipe=sub&name=to-bare: dynamic import (from text/javascript)]
expected: FAIL

View file

@ -1,18 +0,0 @@
[import-maps-base-url.sub.html]
[bare/bare: static import]
expected: FAIL
[bare/bare: dynamic import (from module)]
expected: FAIL
[bare/bare: dynamic import (from text/javascript)]
expected: FAIL
[bare/bare: static import with inject <base>]
expected: FAIL
[bare/bare: dynamic import (from module) with inject <base>]
expected: FAIL
[bare/bare: dynamic import (from text/javascript) with inject <base>]
expected: FAIL

View file

@ -1,3 +0,0 @@
[module-map-key.html]
[Module map's key is the URL after import map resolution]
expected: FAIL

View file

@ -0,0 +1,2 @@
[already-resolved-dropped.html]
expected: CRASH

View file

@ -1,3 +0,0 @@
[basic.html]
[Second import map should be used for resolution]
expected: FAIL

View file

@ -1,9 +0,0 @@
[conflict-first-persists.html]
[First defined rule persists in case of conflict]
expected: FAIL
[First defined rule persists in case of conflict - prefixed bare specifiers]
expected: FAIL
[First defined rule persists in case of conflict - non-prefix bare specifier]
expected: FAIL

View file

@ -1,3 +0,0 @@
[resolution-consistency-in-module-tree-inline.html]
[Module tree that started to download before a new import map should still take it into account]
expected: FAIL

View file

@ -1,3 +0,0 @@
[resolution-consistency-in-module-tree.html]
[Module tree that started to download before a new import map should still take it into account]
expected: FAIL

View file

@ -1,3 +0,0 @@
[url-resolution-conflict.html]
[Second import map should not override same resolved URL]
expected: FAIL

View file

@ -1,3 +0,0 @@
[with-errors.html]
[Second import map should be used for resolution even after an import map with errors]
expected: FAIL

View file

@ -1,3 +1,4 @@
[dynamic.html]
expected: CRASH
[Resolution after import map should not be redefined]
expected: FAIL

View file

@ -1,2 +1,9 @@
[external-script-bare-descendent.html]
expected: ERROR
[Resolution after import map should not be redefined]
expected: FAIL
[Resolution after import map should not be redefined for bare prefixes or exact matches]
expected: FAIL
[Resolution after import map should be redefined for non-prefixes]
expected: FAIL

View file

@ -1,3 +0,0 @@
[integrity.html]
[Static script loaded as its integrity check passed]
expected: FAIL

View file

@ -1,3 +1,4 @@
[prefix.html]
expected: CRASH
[Prefix resolution after import map should not be redefined]
expected: FAIL

View file

@ -2,9 +2,6 @@
[Static script did not load as it failed its integrity check]
expected: FAIL
[Static script loaded as its integrity check passed]
expected: FAIL
[Static script did not load as it failed its integrity check, even without an import defined]
expected: FAIL

View file

@ -1,3 +0,0 @@
[script-enforcement-006.html]
[Untrusted HTMLScriptElement of importmap type uses the source text returned by the default policy.]
expected: FAIL

View file

@ -1,6 +1,3 @@
[script-enforcement-008.https.html]
[script-src CSP directive is properly set.]
expected: FAIL
[Untrusted HTMLScriptElement of importmap type uses the source text returned by the default policy for inline CSP check.]
expected: FAIL