Update web-platform-tests to revision b'fef1c092193085ce2fa64fd116484ba0f3c0dbb1'

This commit is contained in:
WPT Sync Bot 2021-02-26 08:19:22 +00:00
parent 45f5d84d1b
commit 6b8f08a140
543 changed files with 24225 additions and 722 deletions

View file

@ -0,0 +1,22 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async test => {
const result = await import("./export-hello.js", { assert: { } });
assert_equals(result.default, "hello");
}, "Dynamic import with an empty assert clause should succeed");
promise_test(async test => {
const result = await import("./export-hello.js", { assert: { unsupportedAssertionKey: "unsupportedAssertionValue"} });
assert_equals(result.default, "hello");
}, "Dynamic import with an unsupported import assertion should succeed");
promise_test(test => {
return promise_rejects_js(test, TypeError,
import("./export-hello.js", { assert: { type: "notARealType"} } ),
"Dynamic import with an unsupported type assertion should fail");
}, "Dynamic import with an unsupported type assertion should fail");
</script>

View file

@ -0,0 +1,68 @@
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script>
promise_test(async test => {
await promise_rejects_js(test, TypeError,
import("./module.json"),
"Dynamic import of a JSON module without a type assertion should fail");
// This time the import should succeed because we're using the correct
// import even though the previous attempt with the same specifier failed.
const result = await import("./module.json", { assert: { type: "json" } });
assert_true(result.default.test);
}, "Importing a specifier that previously failed due to an incorrect type assertion can succeed if the correct assertion is later given");
promise_test(async test => {
// Append a URL fragment to the specifier so that this is independent
// from the previous test.
const result = await import("./module.json#2", { assert: { type: "json" } });
assert_true(result.default.test);
await promise_rejects_js(test, TypeError,
import("./module.json#2"),
"Dynamic import should fail with the type assertion missing even if the same specifier previously succeeded");
}, "Importing a specifier that previously succeeded with the correct type assertion should fail if the incorrect assertion is later given");
promise_test(async test => {
const uuid_token = token();
// serve-json-then-js.py gives us JSON the first time
const result_json = await import(`../serve-json-then-js.py?key=${uuid_token}`, { assert: { type: "json" } });
assert_equals(result_json.default.hello, "world");
// Import using the same specifier again; this time we get JS, which
// should succeed since we're not asserting a non-JS type this time.
const result_js = await import(`../serve-json-then-js.py?key=${uuid_token}`);
assert_equals(result_js.default, "hello");
}, "Two modules of different type with the same specifier can load if the server changes its responses");
promise_test(async test => {
const uuid_token = token();
// serve-json-then-js.py gives us JSON the first time
await promise_rejects_js(test, TypeError,
import(`../serve-json-then-js.py?key=${uuid_token}`),
"Dynamic import of JS with a JSON type assertion should fail");
// Import using the same specifier/module type pair again; this time we get JS,
// but the import should still fail because the module map entry for this
// specifier/module type pair already contains a failure.
await promise_rejects_js(test, TypeError,
import(`../serve-json-then-js.py?key=${uuid_token}`),
"import should always fail if the same specifier/type assertion pair failed previously");
}, "An import should always fail if the same specifier/type assertion pair failed previously");
promise_test(async test => {
const uuid_token = token();
// serve-json-then-js.py gives us JSON the first time
const result_json = await import(`../serve-json-then-js.py?key=${uuid_token}`, { assert: { type: "json" } });
assert_equals(result_json.default.hello, "world");
// If this were to do another fetch, the import would fail because
// serve-json-then-js.py would give us JS this time. But, the module map
// entry for this specifier/module type pair already exists, so we
// successfully reuse the entry instead of fetching again.
const result_json_2 = await import(`../serve-json-then-js.py?key=${uuid_token}`, { assert: { type: "json" } });
assert_equals(result_json_2.default.hello, "world");
}, "If an import previously succeeded for a given specifier/type assertion pair, future uses of that pair should yield the same result");
</script>

View file

@ -0,0 +1,21 @@
# Respond with valid JSON to the first request with the given key,
# and with valid JavaScript to the second. Used for testing scenarios where
# the same request URL results in different responses on subsequent requests.
def main(request, response):
try:
stash_key = request.GET.first(b"key")
run_count = request.server.stash.take(stash_key)
if not run_count:
run_count = 0
if run_count == 0:
response.headers.set(b"Content-Type", b"text/json")
response.content = '{"hello": "world"}'
else:
response.headers.set(b"Content-Type", b"application/javascript")
response.content = "export default 'hello';"
request.server.stash.put(stash_key, run_count + 1)
except:
response.set_error(400, u"Not enough parameters")