Bug 1690933 [wpt PR 27497] - Check MIME type against asserted module type in ModuleSc...
commitf751aa483f3fb8e86c0f860455e311cd431791ac
authorDaniel Clark <daniec@microsoft.com>
Thu, 11 Feb 2021 16:50:11 +0000 (11 16:50 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Fri, 12 Feb 2021 12:12:39 +0000 (12 12:12 +0000)
tree0b6dd2677859940c8c33f03487f8e6788e4e1068
parent63f1337af334576f6ef98424b01e2dd6a651b2ef
Bug 1690933 [wpt PR 27497] - Check MIME type against asserted module type in ModuleScriptFetcher, a=testonly

Automatic update from web-platform-tests
Check MIME type against asserted module type in ModuleScriptFetcher

Add module type to the module map key.

Plumb module type into ModuleScriptFetcher and its subclasses, and
require that the MIME type match the type that was specified with
import assertions.

Add the necessary import assertions to the JSON/CSS module web tests
so that they continue passing.  Add tests to ensure that the modules
don't load when the correct assertion is not present.

A minor functional change to JSON modules is that trying to start a
a Worker with a top-level JSON module (e.g. new Worker("./foo.json"))
now results in a rejected Promise, instead of loading a no-op worker
without an error.  This change follows the spec change at
https://github.com/whatwg/html/pull/5658/; note that the invocation
of 'fetch a single module script' from 'fetch a worklet/module worker
script graph' doesn't pass a ModuleRequest, so the type is assumed to
be JavaScript, and a failure will be triggered if the MIME type is
not JavaScript.

Some of the non-virtual versions of the tests now time out because
the import assertion syntax is seen as a syntax error when
--harmony-import-assertions is not enabled, causing <script>s not to
run.  TestExpectations is updated to account for these.

Bug: 1132413
Change-Id: I01bf7d907a96e791208534c9c4f2af11434c76db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2674259
Commit-Queue: Dan Clark <daniec@microsoft.com>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852991}

--

wpt-commits: 2c6f296858c62d4628bf58d2db4af687edbf674e
wpt-pr: 27497
17 files changed:
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic.html [new file with mode: 0644]
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-at-import-iframe.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-large-iframe.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-without-assertion-iframe.html [copied from testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/css-module-basic-iframe.html with 60% similarity]
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/malformed-iframe.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker-dynamic-import.js
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/resources/worker.js
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/css-module/utf8.tentative.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https.tentative.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/module.tentative.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/non-object.tentative.any.js
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker-dynamic-import.js
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/serviceworker.js
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/utf8.tentative.html
testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type.tentative.html