| <!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/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/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/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/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/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/module.json&ct=text/json;foo=bar" assert { type: "json"}; |
| check(t6, v); |
| </script> |