Skip to content
Permalink
Browse files
[JSC] Implement import-assertion and JSON module
https://bugs.webkit.org/show_bug.cgi?id=243622

Reviewed by Alexey Shvayka and Ryosuke Niwa.

This patch implements import-assertions and JSON module.

1. Import assertions' syntax work was already done. We propagate assertions through ScriptFetchParameters, which already exists.
2. Get "type" assertion, and based on that, we parse JSON if it is "json".
3. Add SyntheticModuleRecord (this is described in the spec), and materialize JSON module as SyntheticModuleRecord.
4. Fix MIMETypeRegistry::isSupportedJSONMIMEType. "text/json" is explicitly listed in [1], so we should say true for that.
5. Dynamic import also gets assertions via its second parameter.

One test262 test is failing just because our harness is not handling it well (so this is not a bug in JSON module implementation).
WPT failures are due to old module loader's behavior (so, fixing it requires update of module loader implementation, not related to
JSON module itself).

[1]: https://mimesniff.spec.whatwg.org/#json-mime-type

* JSTests/test262/config.yaml:
* JSTests/test262/expectations.yaml:
* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/charset-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/content-type-checking-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/cors-crossorigin-requests-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/integrity-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/load-error-events-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/empty-assertion-clause-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/invalid-type-assertion-error-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/unsupported-assertion-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/cors-crossorigin-requests-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/integrity-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/load-error-events-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/module-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.sharedworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/valid-content-type-expected.txt:
* LayoutTests/platform/gtk/TestExpectations:
* Source/JavaScriptCore/API/JSAPIGlobalObject.mm:
(JSC::JSAPIGlobalObject::moduleLoaderImportModule):
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/builtins/ModuleLoader.js:
(requestSatisfy):
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::Heap):
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/heap/HeapSubspaceTypes.h:
* Source/JavaScriptCore/jsc.cpp:
(GlobalObject::moduleLoaderImportModule):
(GlobalObject::moduleLoaderFetch):
* Source/JavaScriptCore/parser/ModuleAnalyzer.cpp:
(JSC::ModuleAnalyzer::appendRequestedModule):
* Source/JavaScriptCore/parser/ModuleAnalyzer.h:
* Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp:
(JSC::tryCreateAssertion):
(JSC::ImportDeclarationNode::analyzeModule):
(JSC::ExportAllDeclarationNode::analyzeModule):
(JSC::ExportNamedDeclarationNode::analyzeModule):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseImportAssertions):
* Source/JavaScriptCore/parser/SourceProvider.h:
* Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp:
(JSC::AbstractModuleRecord::appendRequestedModule):
(JSC::AbstractModuleRecord::link):
(JSC::AbstractModuleRecord::evaluate):
(JSC::AbstractModuleRecord::dump):
* Source/JavaScriptCore/runtime/AbstractModuleRecord.h:
(JSC::AbstractModuleRecord::requestedModules const):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::retrieveAssertionsFromDynamicImportOptions):
* Source/JavaScriptCore/runtime/Completion.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildrenImpl):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::syntheticModuleRecordStructure const):
* Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSONObject.cpp:
(JSC::JSONParse):
(JSC::JSONParseWithException):
* Source/JavaScriptCore/runtime/JSONObject.h:
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/runtime/ScriptFetchParameters.h:
(JSC::ScriptFetchParameters::ScriptFetchParameters):
(JSC::ScriptFetchParameters::type const):
(JSC::ScriptFetchParameters::integrity const):
(JSC::ScriptFetchParameters::isTopLevelModule const):
(JSC::ScriptFetchParameters::create):
(JSC::ScriptFetchParameters::~ScriptFetchParameters): Deleted.
* Source/JavaScriptCore/runtime/SyntheticModuleRecord.cpp: Added.
(JSC::SyntheticModuleRecord::createStructure):
(JSC::SyntheticModuleRecord::create):
(JSC::SyntheticModuleRecord::SyntheticModuleRecord):
(JSC::SyntheticModuleRecord::destroy):
(JSC::SyntheticModuleRecord::finishCreation):
(JSC::SyntheticModuleRecord::visitChildrenImpl):
(JSC::SyntheticModuleRecord::link):
(JSC::SyntheticModuleRecord::evaluate):
(JSC::SyntheticModuleRecord::tryCreateWithExportNamesAndValues):
(JSC::SyntheticModuleRecord::tryCreateDefaultExportSyntheticModule):
(JSC::SyntheticModuleRecord::parseJSONModule):
* Source/JavaScriptCore/runtime/SyntheticModuleRecord.h: Added.
* Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::tryCreate):
* Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp:
(WebCore::CachedModuleScriptLoader::create):
(WebCore::CachedModuleScriptLoader::CachedModuleScriptLoader):
* Source/WebCore/bindings/js/CachedModuleScriptLoader.h:
* Source/WebCore/bindings/js/ModuleScriptLoader.h:
(WebCore::ModuleScriptLoader::parameters):
(WebCore::ModuleScriptLoader::ModuleScriptLoader):
* Source/WebCore/bindings/js/ScriptController.cpp:
(WebCore::ScriptController::loadModuleScriptInWorld):
(WebCore::ScriptController::loadModuleScript):
(WebCore::ScriptController::evaluateModule):
* Source/WebCore/bindings/js/ScriptController.h:
* Source/WebCore/bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::fetch):
(WebCore::ScriptModuleLoader::importModule):
(WebCore::ScriptModuleLoader::notifyFinished):
* Source/WebCore/bindings/js/ScriptModuleLoader.h:
* Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp:
(WebCore::WorkerModuleScriptLoader::create):
(WebCore::WorkerModuleScriptLoader::WorkerModuleScriptLoader):
* Source/WebCore/bindings/js/WorkerModuleScriptLoader.h:
* Source/WebCore/bindings/js/WorkerScriptFetcher.h:
* Source/WebCore/dom/LoadableModuleScript.cpp:
(WebCore::LoadableModuleScript::LoadableModuleScript):
* Source/WebCore/dom/ModuleFetchParameters.h:
(WebCore::ModuleFetchParameters::create):
(WebCore::ModuleFetchParameters::ModuleFetchParameters):
(WebCore::ModuleFetchParameters::integrity const): Deleted.
(WebCore::ModuleFetchParameters::isTopLevelModule const): Deleted.
* Source/WebCore/platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isSupportedJSONMIMEType):
* Source/WebCore/workers/WorkerOrWorkletScriptController.cpp:
(WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule):
* Source/WebCore/workers/WorkerThread.cpp:
(WebCore::WorkerThread::evaluateScriptIfNecessary):
* Tools/TestWebKitAPI/Tests/WebCore/MIMETypeRegistry.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/253234@main
  • Loading branch information
Constellation committed Aug 8, 2022
1 parent 6f10652 commit cebdad8ac8691b85db85bb79f54543cae829ed7c
Show file tree
Hide file tree
Showing 75 changed files with 767 additions and 274 deletions.
@@ -11,15 +11,15 @@ flags:
array-grouping: useArrayGroupMethod
Object.hasOwn: useHasOwn
ShadowRealm: useShadowRealm
import-assertions: useImportAssertion
json-modules: useImportAssertion
skip:
features:
- Atomics.waitAsync
# https://bugs.webkit.org/show_bug.cgi?id=174931
- regexp-lookbehind
- regexp-v-flag
- resizable-arraybuffer
- import-assertions
- json-modules
- class-static-block
- callable-boundary-realms
- FinalizationRegistry.prototype.cleanupSome
@@ -2040,6 +2040,8 @@ test/language/module-code/early-dup-top-function-generator.js:
module: 'Test262: This statement should not be evaluated.'
test/language/module-code/early-dup-top-function.js:
module: 'Test262: This statement should not be evaluated.'
test/language/module-code/eval-gtbndng-indirect-faux-assertion.js:
raw: "SyntaxError: Unexpected identifier 'x'. import call expects one or two arguments."
test/language/module-code/parse-err-hoist-lex-fun.js:
module: 'Test262: This statement should not be evaluated.'
test/language/module-code/parse-err-hoist-lex-gen.js:
@@ -5440,3 +5440,8 @@ streams/readable-byte-stream-controller-worker.html [ Skip ]
webkit.org/b/241104 fast/block/fill-available-with-no-specified-containing-block-height.html [ ImageOnlyFailure ]
webkit.org/b/241104 fast/block/fill-available-with-absolute-position.html [ ImageOnlyFailure ]
webkit.org/b/241104 fast/css/fill-available-with-percent-height-no-quirk.html [ ImageOnlyFailure ]

# Flaky because of network ordering
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/charset.html [ Pass Failure ]
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/cors-crossorigin-requests.html [ Pass Failure ]
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/cors-crossorigin-requests.html [ Pass Failure ]
@@ -1,9 +1,8 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: ReferenceError: Can't find variable: unreachable
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: ReferenceError: Can't find variable: unreachable

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
Harness Error (FAIL), message = ReferenceError: Can't find variable: unreachable


@@ -1,14 +1,12 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'application/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'text/html css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

NOTRUN text/css
NOTRUN application/css
NOTRUN text/html+css
NOTRUN text/css;boundary=something
NOTRUN text/css;foo=bar
FAIL text/css assert_unreached: Reached unreachable code
PASS application/css
PASS text/html+css
FAIL text/css;boundary=something assert_unreached: Reached unreachable code
FAIL text/css;foo=bar assert_unreached: Reached unreachable code

@@ -1,11 +1,11 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
Blocked access to external URL http://www2.localhost:8800/html/semantics/scripting-1/the-script-element/css-module/resources/basic.css?pipe=header(Access-Control-Allow-Origin,*)
Blocked access to external URL http://www2.localhost:8800/html/semantics/scripting-1/the-script-element/css-module/resources/parse-error.css?pipe=header(Access-Control-Allow-Origin,*)
Blocked access to external URL http://www2.localhost:8800/html/semantics/scripting-1/the-script-element/css-module/resources/basic.css
css-module-crossorigin



FAIL Imported CSS module, cross-origin with CORS assert_equals: Unexpected _log value expected "imported CSS: #test { background-color: rgb(255, 0, 0); }" but got "10-0"
FAIL Imported CSS module, cross-origin, missing CORS ACAO header assert_equals: Unexpected _log value expected "error" but got "10-0"
FAIL Imported CSS module with parse error, cross-origin, with CORS assert_equals: Unexpected _log value expected "imported CSS rules count: 0" but got "10-0"
FAIL Imported CSS module, cross-origin with CORS assert_equals: Unexpected _log value expected "imported CSS: #test { background-color: rgb(255, 0, 0); }" but got ""
PASS Imported CSS module, cross-origin, missing CORS ACAO header
FAIL Imported CSS module with parse error, cross-origin, with CORS assert_equals: Unexpected _log value expected "imported CSS rules count: 0" but got ""

@@ -1,5 +1,5 @@

PASS A static import CSS Module within a web worker should not load and should not attempt to fetch the module.
FAIL A static import CSS Module within a web worker should not load and should not attempt to fetch the module. assert_equals: Shouldn't have tried fetching CSS module in worker expected 0 but got 1
FAIL A dynamic import CSS Module within a web worker should not load and should not attempt to fetch the module. assert_equals: Shouldn't have tried fetching CSS module in worker expected 0 but got 1
PASS An attempt to load a CSS module as a worker should fail.

@@ -5,6 +5,6 @@ I am a test div.
I am a test div.
I am a test div.

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
Harness Error (FAIL), message = ReferenceError: Can't find variable: unreachable


@@ -1,4 +1,4 @@

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

FAIL The integrity attribute must be verified on the top-level of a module loading a CSS module and allow it to execute when it matches assert_array_equals: The module and its dependency must have executed lengths differ, expected array ["integrity-matches,css:#test { background-color: rgb(255, 0, 0); }"] length 1, got [] length 0
PASS The integrity attribute must be verified on the top-level of a module loading a CSS module and not allow it to execute when there's a mismatch

@@ -1,20 +1,14 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.
CONSOLE MESSAGE: TypeError: 'text/css' is not a valid JavaScript MIME type.

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

NOTRUN inline, 200, parser-inserted
NOTRUN inline, 404, parser-inserted
NOTRUN src, 200, parser-inserted
NOTRUN src, 404, parser-inserted
NOTRUN src, 200, not parser-inserted
NOTRUN src, 404, not parser-inserted
NOTRUN inline, 200, not parser-inserted
NOTRUN inline, 404, not parser-inserted
FAIL inline, 200, parser-inserted assert_unreached: Error event should not be fired. Reached unreachable code
PASS inline, 404, parser-inserted
FAIL src, 200, parser-inserted assert_unreached: Error event should not be fired. Reached unreachable code
PASS src, 404, parser-inserted
FAIL src, 200, not parser-inserted assert_unreached: Error event should not be fired. Reached unreachable code
PASS src, 404, not parser-inserted
FAIL inline, 200, not parser-inserted assert_unreached: Error event should not be fired. Reached unreachable code
PASS inline, 404, not parser-inserted

@@ -1,6 +1,3 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

FAIL Test that no error occurs when an empty import assertion clause is provided. assert_array_equals: lengths differ, expected array ["hello", "empty-assertion-clause"] length 2, got [object "SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration."] length 1
PASS Test that no error occurs when an empty import assertion clause is provided.

@@ -1,11 +1,3 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

FAIL Test that invalid module type assertion leads to TypeError on window. assert_equals: expected function "function TypeError() {
[native code]
}" but got function "function SyntaxError() {
[native code]
}"
FAIL Test that invalid module type assertion leads to TypeError on window. assert_equals: expected 4 but got 8

@@ -1,6 +1,3 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

FAIL Test that no error occurs when an unsupported import assertion is provided. assert_array_equals: lengths differ, expected array ["hello", "unsupported-assertion"] length 2, got [object "SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration."] length 1
PASS Test that no error occurs when an unsupported import assertion is provided.

@@ -1,9 +1,5 @@

FAIL UTF-8 BOM should be stripped when decoding JSON module script promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
FAIL UTF-16BE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16BE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
[native code]
}" ("SyntaxError")
FAIL UTF-16LE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16LE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
[native code]
}" ("SyntaxError")
PASS UTF-8 BOM should be stripped when decoding JSON module script
FAIL UTF-16BE BOM should result in parse error in JSON module script assert_unreached: Should have rejected: Expected parse error from UTF-16BE BOM Reached unreachable code
FAIL UTF-16LE BOM should result in parse error in JSON module script assert_unreached: Should have rejected: Expected parse error from UTF-16LE BOM Reached unreachable code

@@ -1,9 +1,5 @@

FAIL UTF-8 BOM should be stripped when decoding JSON module script promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
FAIL UTF-16BE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16BE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
[native code]
}" ("SyntaxError")
FAIL UTF-16LE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16LE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
[native code]
}" ("SyntaxError")
PASS UTF-8 BOM should be stripped when decoding JSON module script
FAIL UTF-16BE BOM should result in parse error in JSON module script assert_unreached: Should have rejected: Expected parse error from UTF-16BE BOM Reached unreachable code
FAIL UTF-16LE BOM should result in parse error in JSON module script assert_unreached: Should have rejected: Expected parse error from UTF-16LE BOM Reached unreachable code

@@ -1,9 +1,5 @@

FAIL UTF-8 BOM should be stripped when decoding JSON module script promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
FAIL UTF-16BE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16BE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
[native code]
}" ("SyntaxError")
FAIL UTF-16LE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16LE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
[native code]
}" ("SyntaxError")
PASS UTF-8 BOM should be stripped when decoding JSON module script
FAIL UTF-16BE BOM should result in parse error in JSON module script assert_unreached: Should have rejected: Expected parse error from UTF-16BE BOM Reached unreachable code
FAIL UTF-16LE BOM should result in parse error in JSON module script assert_unreached: Should have rejected: Expected parse error from UTF-16LE BOM Reached unreachable code

@@ -1,9 +1,7 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

PASS JSON module should be loaded as utf-8 when charset=utf8 is specified
FAIL JSON module should be loaded as utf-8 when charset=shift-jis is specified assert_equals: expected "śćążź" but got "ナ崙\ufffd\ufffdシナコ"
FAIL JSON module should be loaded as utf-8 when charset=windows-1252 is specified assert_equals: expected "śćążź" but got "śćążź"
PASS JSON module should be loaded as utf-8 when charset=utf-7 is specified
PASS JSON module should be loaded as utf-8 even if it is encoded in windows-1250 and served with a windows-1250 charset response header

@@ -1,11 +1,8 @@
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
CONSOLE MESSAGE: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.
json-module-crossorigin



FAIL Imported JSON module, cross-origin with CORS assert_equals: Unexpected _log value expected "imported JSON: 42" but got "10-0"
FAIL Imported JSON module, cross-origin, missing CORS ACAO header assert_equals: Unexpected _log value expected "error" but got "10-0"
FAIL Imported JSON module with parse error, cross-origin, with CORS assert_equals: Unexpected _log value expected "0-0" but got "10-0"
FAIL Imported JSON module, cross-origin with CORS assert_equals: Unexpected _log value expected "imported JSON: 42" but got ""
PASS Imported JSON module, cross-origin, missing CORS ACAO header
FAIL Imported JSON module with parse error, cross-origin, with CORS assert_equals: Unexpected _log value expected "0-0" but got ""

@@ -1,4 +1,4 @@

Harness Error (FAIL), message = SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration.

PASS The integrity attribute must be verified on the top-level of a module loading a JSON module and allow it to execute when it matches
PASS The integrity attribute must be verified on the top-level of a module loading a JSON module and not allow it to execute when there's a mismatch

@@ -1,5 +1,5 @@

FAIL Javascript importing JSON Module should load within the context of a service worker promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration."
PASS Javascript importing JSON Module should load within the context of a service worker
PASS Trying to register a service worker with a top-level JSON Module should fail
PASS JSON Module dynamic import should not load within the context of a service worker

0 comments on commit cebdad8

Please sign in to comment.