Update web-platform-tests to revision 14cfa4d648cc1c853b4153268df672d21425f8c1

This commit is contained in:
Josh Matthews 2017-10-30 09:31:22 -04:00
parent 1b73cf3352
commit 75736751d9
1213 changed files with 19434 additions and 12344 deletions

View file

@ -1,21 +0,0 @@
<!DOCTYPE html>
<title>Basic dynamic imports</title>
<link rel="author" title="Kouhei Ueno" href="mailto:kouhei@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="module">
promise_test(t => {
return promise_rejects(t, new SyntaxError, import("../syntaxerror.js"));
}, "Dynamic imports should reject if the imported tree has a syntax error.");
promise_test(t => {
return promise_rejects(t, new SyntaxError, import("../instantiation-error-1.js"));
}, "Dynamic imports should reject if the imported tree has an instantiation error.");
promise_test(t => {
return promise_rejects(t, new Error, import("../throw-error.js")).then(() => {
assert_true(window.before_throwing_error,
"the module script should run to a point where it throws exception");
assert_equals(undefined, window.after_throwing_error,
"the module script should not run after it throws exception");
});
}, "Dynamic imports should reject if the imported tree has an evaluation error.");
</script>

View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<title>import(): error cases occuring during fetching</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="module">
const cases = [
["wrong MIME type", "../errorhandling-wrongMimetype.js?pipe=header(Content-Type,text/plain)"],
["wrong MIME type of a dependency", "../errorhandling-wrongMimetype-import.js"],
["404", "../resources/404-but-js.asis"],
["404 of a dependency", "../resources/imports-404-but-js.js"],
["500", "../resources/500-but-js.asis"],
["500 of a dependency", "../resources/imports-500-but-js.js"],
["cross-origin module (without CORS)", "http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/imports-a.js"],
["cross-origin module dependency (without CORS)", "../resources/imports-b-cross-origin.sub.js"]
];
for (const [label, specifier] of cases) {
promise_test(t => {
return promise_rejects(t, new TypeError, import(specifier));
}, "import() must reject when there is a " + label);
promise_test(async t => {
// The use of ?x is used to separate tests so they don't interfere with each other.
// (However, it shouldn't matter anyway, in a spec-compliant implementation.)
const suffix = (specifier.includes("?") ? "&" : "?") + "x";
const promise1 = import(specifier + suffix);
const promise2 = import(specifier + suffix);
await promise_rejects(t, new TypeError, promise1, "It must reject the first time");
await promise_rejects(t, new TypeError, promise2, "It must reject the second time");
const error1 = await promise1.catch(e => e);
const error2 = await promise2.catch(e => e);
assert_not_equals(error1, error2, "The error objects must be different");
}, "import() must reject with a different error object for each import when there is a " + label);
}
</script>

View file

@ -0,0 +1,53 @@
<!DOCTYPE html>
<title>import(): error cases caused by the imported module script</title>
<link rel="author" title="Kouhei Ueno" href="mailto:kouhei@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="module">
const cases = [
["parse error", "../syntaxerror.js", new SyntaxError],
["bad module specifier", "does-not-start-with-dot.js", new TypeError, { differentErrorObjects: true }],
["bad module specifier in a dependency", "../bad-module-specifier.js", new TypeError],
["instantiation error", "../instantiation-error-1.js", new SyntaxError],
["evaluation error", "../throw-error.js", new Error]
];
for (const [label, specifier, error, { differentErrorObjects } = {}] of cases) {
promise_test(t => {
return promise_rejects(t, error, import(specifier));
}, "import() must reject when there is a " + label);
const errorObjectsLabel = differentErrorObjects ? "different error objects" : "the same error object";
promise_test(async t => {
// The use of ?x is used to separate tests so they don't interfere with each other.
// (However, it shouldn't matter anyway, in a spec-compliant implementation.)
const promise1 = import(specifier + "?x");
const promise2 = import(specifier + "?x");
await promise_rejects(t, error, promise1, "It must reject the first time");
await promise_rejects(t, error, promise2, "It must reject the second time");
const error1 = await promise1.catch(e => e);
const error2 = await promise2.catch(e => e);
if (differentErrorObjects) {
assert_not_equals(error1, error2, "The error objects must be different");
} else {
assert_equals(error1, error2, "The error objects must be equal");
}
}, `import() must reject with ${errorObjectsLabel} for each import when there is a ${label}`);
}
promise_test(t => {
delete window.before_throwing_error;
delete window.after_throwing_error;
return promise_rejects(t, new Error, import("../throw-error.js?y")).then(() => {
assert_true(window.before_throwing_error,
"the module script should run to a point where it throws exception");
assert_equals(window.after_throwing_error, undefined,
"the module script should not run after it throws exception");
});
}, "import()ing a module with an evaluation error must stop evaluation");
</script>

View file

@ -1,4 +1,4 @@
import foo from "./errorhandling-wrongMimetype.js?pipe=header(X-Content-Type-Options,nosniff),header(Content-Type,text/plain)";
import foo from "./errorhandling-wrongMimetype.js?pipe=header(Content-Type,text/plain)";
// We don't expect this code to run, the import above should fail!
// If we do run though, don't trigger an error that the testharness

View file

@ -35,7 +35,7 @@
var test_wrongMimetype_root = async_test("External root module with non-script mimetype");
var script_wrongMimetype_root = document.createElement("script");
script_wrongMimetype_root.type = "module";
script_wrongMimetype_root.src = "errorhandling-wrongMimetype.js?pipe=header(Content-Type,text/plain),header(X-Content-Type-Options,nosniff)";
script_wrongMimetype_root.src = "errorhandling-wrongMimetype.js?pipe=header(Content-Type,text/plain)";
script_wrongMimetype_root.addEventListener("error", test_wrongMimetype_root.step_func(function () {
test_wrongMimetype_root.done();
}));

View file

@ -0,0 +1 @@
export let importMetaOnDependentModule = import.meta;

View file

@ -0,0 +1,2 @@
export let importMetaOnRootModule = import.meta;
export { importMetaOnDependentModule } from "./import-meta-dependent.js";

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="module">
import { importMetaOnRootModule, importMetaOnDependentModule }
from "./import-meta-root.js";
var base = location.href.slice(0, location.href.lastIndexOf('/'));
test(() => {
assert_equals(import.meta.url, location.href);
}, "import.meta.url in a root inline script");
test(() => {
assert_equals(importMetaOnRootModule.url,
base + "/import-meta-root.js");
}, "import.meta.url in a root external script");
test(() => {
assert_equals(importMetaOnDependentModule.url,
base + "/import-meta-dependent.js");
}, "import.meta.url in a dependent external script");
</script>

View file

@ -0,0 +1,4 @@
HTTP/1.1 404 Not Found
Content-Type: text/javascript
window.ran404 = true;

View file

@ -0,0 +1,4 @@
HTTP/1.1 500 Not Found
Content-Type: text/javascript
window.ran500 = true;

View file

@ -0,0 +1 @@
import "http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/imports-b.js";