-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Add some initial tests for JSON modules.
- Loading branch information
Showing
9 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
html/semantics/scripting-1/the-script-element/json-module/array.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["en", "try"] |
1 change: 1 addition & 0 deletions
1
html/semantics/scripting-1/the-script-element/json-module/false.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
false |
26 changes: 26 additions & 0 deletions
26
html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>JSON modules: invalid Content-Type</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id=log></div> | ||
<script> | ||
const content_types = [ | ||
"application/json+protobuf", | ||
"application/json+blah", | ||
"text/x-json", | ||
"text/json+blah", | ||
"application/blahjson", | ||
"image/json", | ||
]; | ||
for (const content_type of content_types) { | ||
async_test(t => { | ||
const script = document.createElement("script"); | ||
script.onerror = t.step_func_done(); | ||
script.onload = t.unreached_func("Should not load"); | ||
script.type = "module"; | ||
script.src = `module.json?pipe=header(Content-Type,${content_type})`; | ||
document.body.appendChild(script); | ||
}, content_type); | ||
} | ||
</script> |
14 changes: 14 additions & 0 deletions
14
html/semantics/scripting-1/the-script-element/json-module/non-object.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// META: global=window,worker | ||
|
||
for (const value of [null, true, false, "string"]) { | ||
promise_test(async t => { | ||
const result = await import(`./${value}.json`); | ||
assert_equals(result, value); | ||
}, `Non-object: ${value}`); | ||
} | ||
|
||
promise_test(async t => { | ||
const result = await import("./array.json"); | ||
assert_array_equals(result, ["en", "try"]); | ||
}, "Non-object: array"); | ||
|
1 change: 1 addition & 0 deletions
1
html/semantics/scripting-1/the-script-element/json-module/null.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
null |
2 changes: 1 addition & 1 deletion
2
html/semantics/scripting-1/the-script-element/json-module/parse-error.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
html/semantics/scripting-1/the-script-element/json-module/string.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"string" |
1 change: 1 addition & 0 deletions
1
html/semantics/scripting-1/the-script-element/json-module/true.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
true |
File renamed without changes.