summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/valid-content-type.html
blob: 162f2d6afcaf6fb4a23f4736286fe97e8ab05b28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<meta charset=utf-8>
<title>JSON modules: Content-Type</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
function check(t, v) {
  t.step(() => {
    assert_equals(typeof v, "object");
    assert_array_equals(Object.keys(v), ["test"]);
    assert_equals(v.test, true);
    t.done();
  });
}
const t1 = async_test("text/json");
const t2 = async_test("application/json");
const t3 = async_test("text/html+json");
const t4 = async_test("image/svg+json");
const t5 = async_test("text/json;boundary=something");
const t6 = async_test("text/json;foo=bar");
</script>
<script type="module" onerror="t1.step(() => assert_unreached(event))">
import v from "../serve-with-content-type.py?fn=json-module-assertions/module.json&ct=text/json" assert { type: "json"};
check(t1, v);
</script>
<script type="module" onerror="t2.step(() => assert_unreached(event))">
import v from "../serve-with-content-type.py?fn=json-module-assertions/module.json&ct=application/json" assert { type: "json"};
check(t2, v);
</script>
<script type="module" onerror="t3.step(() => assert_unreached(event))">
import v from "../serve-with-content-type.py?fn=json-module-assertions/module.json&ct=text/html%2Bjson" assert { type: "json"};
check(t3, v);
</script>
<script type="module" onerror="t4.step(() => assert_unreached(event))">
import v from "../serve-with-content-type.py?fn=json-module-assertions/module.json&ct=image/svg%2Bjson" assert { type: "json"};
check(t4, v);
</script>
<script type="module" onerror="t5.step(() => assert_unreached(event))">
import v from "../serve-with-content-type.py?fn=json-module-assertions/module.json&ct=text/json;boundary=something" assert { type: "json"};
check(t5, v);
</script>
<script type="module" onerror="t6.step(() => assert_unreached(event))">
import v from "../serve-with-content-type.py?fn=json-module-assertions/module.json&ct=text/json;foo=bar" assert { type: "json"};
check(t6, v);
</script>