mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision a46616a5b18e83587ddbbed756c7b96cbb4b015d
This commit is contained in:
parent
3f07cfec7c
commit
578498ba24
4001 changed files with 159517 additions and 30260 deletions
|
@ -0,0 +1,3 @@
|
|||
import "string-without-dot-slash-prefix";
|
||||
import "./this.js";
|
||||
log.push("bad-module-specifier");
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of compilation errors, 1</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that syntax errors lead to SyntaxError events on window, " +
|
||||
"and that exceptions are remembered.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 5);
|
||||
assert_equals(log[0].constructor, SyntaxError);
|
||||
assert_true(log.every(exn => exn === log[0]));
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./syntaxerror.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror-nested.js" onerror="unreachable()"></script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of compilation errors, 2</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that syntax errors lead to SyntaxError events on window, " +
|
||||
"and that exceptions are remembered.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 5);
|
||||
assert_equals(log[0].constructor, SyntaxError);
|
||||
assert_true(log.every(exn => exn === log[0]));
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./syntaxerror-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./syntaxerror.js" onerror="unreachable()"></script>
|
|
@ -6,7 +6,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>html-script-module-crossOrigin-import-NoCORS</h1>
|
||||
<script type="module">
|
||||
<script type="module" onerror="document._log.push('error');">
|
||||
|
||||
import { foo } from "http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/crossorigin-scripterror.js";
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>html-script-module-crossOrigin-root-NoCORS</h1>
|
||||
<script type="module" src="http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/crossorigin-scripterror.js"></script>
|
||||
<script type="module" src="http://{{domains[www2]}}:{{ports[http][0]}}/html/semantics/scripting-1/the-script-element/module/crossorigin-scripterror.js" onerror="document._log.push('error');"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,24 +7,24 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>html-script-module-crossOrigin</h1>
|
||||
<iframe id="root-NoCORS" src="crossorigin-root-different.sub.html"></iframe>
|
||||
<iframe id="root-WithCORS" src="crossorigin-root-same.sub.html"></iframe>
|
||||
<iframe id="root-NoCORS" src="crossorigin-root-different.sub.html"></iframe>
|
||||
<iframe id="root-BlockedMissingHeader" src="crossorigin-root-missingheader.sub.html"></iframe>
|
||||
<iframe id="root-BlockedWrongHeader" src="crossorigin-root-wrongheader.sub.html"></iframe>
|
||||
<iframe id="import-NoCORS" src="crossorigin-import-different.sub.html"></iframe>
|
||||
<iframe id="import-WithCORS" src="crossorigin-import-same.sub.html"></iframe>
|
||||
<iframe id="import-NoCORS" src="crossorigin-import-different.sub.html"></iframe>
|
||||
<iframe id="import-BlockedMissingHeader" src="crossorigin-import-missingheader.sub.html"></iframe>
|
||||
<iframe id="import-BlockedWrongHeader" src="crossorigin-import-wrongheader.sub.html"></iframe>
|
||||
<script>
|
||||
|
||||
var tests = [
|
||||
{ "obj": async_test("Root module, Error in CORS-different-origin script"), "id": "root-NoCORS", "expected": "running,0-0" },
|
||||
{ "obj": async_test("Root module, Error in CORS-same-origin script"), "id": "root-WithCORS", "expected": "running,8-1" },
|
||||
{ "obj": async_test("Root module, Blocked script download, missing CORS ACAO header"), "id": "root-BlockedMissingHeader", "expected": "error" },
|
||||
{ "obj": async_test("Root module, Blocked script download, missing CORS ACAO header"), "id": "root-NoCORS", "expected": "error" },
|
||||
{ "obj": async_test("Root module, Blocked script download, crossorigin attribute with missing CORS ACAO header"), "id": "root-BlockedMissingHeader", "expected": "error" },
|
||||
{ "obj": async_test("Root module, Blocked script download, mismatched CORS ACAO header"), "id": "root-BlockedWrongHeader", "expected": "error" },
|
||||
{ "obj": async_test("Imported module, Error in CORS-different-origin script"), "id": "import-NoCORS", "expected": "running,0-0" },
|
||||
{ "obj": async_test("Imported module, Error in CORS-same-origin script"), "id": "import-WithCORS", "expected": "running,8-1" },
|
||||
{ "obj": async_test("Imported module, Blocked script download, missing CORS ACAO header"), "id": "import-BlockedMissingHeader", "expected": "error" },
|
||||
{ "obj": async_test("Imported module, Blocked script download, missing CORS ACAO header"), "id": "import-NoCORS", "expected": "error" },
|
||||
{ "obj": async_test("Imported module, Blocked script download, crossorigin attribute with missing CORS ACAO header"), "id": "import-BlockedMissingHeader", "expected": "error" },
|
||||
{ "obj": async_test("Imported module, Blocked script download, mismatched CORS ACAO header"), "id": "import-BlockedWrongHeader", "expected": "error" },
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="module" src="set-currentScript-on-window.js"></script>
|
||||
<script type="module">
|
||||
import { currentScriptOnImportedModule } from "./currentscript.js";
|
||||
|
||||
test(() => {
|
||||
assert_equals(document.currentScript, null, "document.currentScript on inline scripts should be null");
|
||||
assert_equals(currentScriptOnImportedModule, null, "document.currentScript on imported scripts should be null");
|
||||
assert_equals(window.currentScriptRecorded, null, "document.currentScript on external module scripts should be null");
|
||||
}, "currentScript on script type=module should be all null");
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
export let currentScriptOnImportedModule = window.document.currentScript;
|
|
@ -0,0 +1,3 @@
|
|||
log.push("cycle-tdz-access-a");
|
||||
import { Y } from "./cycle-tdz-access.js";
|
||||
export var X = Y;
|
|
@ -0,0 +1,3 @@
|
|||
log.push("cycle-tdz-access");
|
||||
import { X } from "./cycle-tdz-access-a.js";
|
||||
export let Y = X;
|
|
@ -0,0 +1,2 @@
|
|||
export {x} from "./cycle-unresolvable.js";
|
||||
log.push("cycle-unresolvable-a");
|
|
@ -0,0 +1,2 @@
|
|||
export {x} from "./cycle-unresolvable-a.js";
|
||||
log.push("cycle-unresolvable");
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Module importing syntax error script and slow script should not crash UA</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="module">
|
||||
setup({allow_uncaught_exception: true});
|
||||
window.log = [];
|
||||
</script>
|
||||
<script type="module">
|
||||
import "./syntaxerror.js";
|
||||
import "./resources/delayed-modulescript.py";
|
||||
|
||||
window.loaded = true;
|
||||
</script>
|
||||
<script type="module">
|
||||
test(() => {
|
||||
assert_false(loaded);
|
||||
}, "module graph with a syntax error should not evaulate but should not crash UA.");
|
||||
</script>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of evaluation errors, 1</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that exceptions during evaluation lead to error events on " +
|
||||
"window, and that exceptions are remembered.\n");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[1];
|
||||
assert_array_equals(log, ["throw", exn, exn, exn, exn]);
|
||||
assert_true(exn.foo);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="throw.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="throw.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="throw.js" async onerror="unreachable()"></script>
|
||||
<script type="module" src="throw.js" nomodule onerror="unreachable()"></script>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of evaluation errors, 2</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that ill-founded cyclic dependencies cause ReferenceError " +
|
||||
"during evaluation, which leads to error events on window, and that " +
|
||||
"exceptions are remembered.\n");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[1];
|
||||
assert_array_equals(log, ["cycle-tdz-access-a", exn, exn, exn]);
|
||||
assert_equals(exn.constructor, ReferenceError);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="cycle-tdz-access.js" async onerror="unreachable()"></script>
|
||||
<script type="module" src="cycle-tdz-access.js" nomodule onerror="unreachable()"></script>
|
||||
<script type="module" src="cycle-tdz-access.js" onerror="unreachable()"></script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of evaluation errors, 3</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that exceptions during evaluation lead to error events on " +
|
||||
"window, and that exceptions are remembered.\n");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[1];
|
||||
assert_array_equals(log, ["throw", exn, exn, exn, exn, exn]);
|
||||
assert_true(exn.foo);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./throw.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw-nested.js" onerror="unreachable()"></script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of evaluation errors, 4</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that exceptions during evaluation lead to error events on " +
|
||||
"window, and that exceptions are remembered.\n");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[1];
|
||||
assert_array_equals(log, ["throw", exn, exn, exn, exn, exn]);
|
||||
assert_true(exn.foo);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./throw-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw-nested.js" onerror="unreachable()"></script>
|
||||
<script type="module" src="./throw.js" onerror="unreachable()"></script>
|
|
@ -41,8 +41,8 @@
|
|||
var test_parsedUnordered1 = async_test("Unordered module script execution (parsed, unordered #1)");
|
||||
var test_parsedUnordered2 = async_test("Unordered module script execution (parsed, unordered #2)");
|
||||
</script>
|
||||
<script type="module" src="execOrder-parsedUnordered1.js"></script>
|
||||
<script type="module" src="execOrder-parsedUnordered2.js"></script>
|
||||
<script type="module" src="execorder-parsedunordered1.js"></script>
|
||||
<script type="module" src="execorder-parsedunordered2.js"></script>
|
||||
<script>
|
||||
/////
|
||||
// End test_parsedUnordered*
|
||||
|
@ -53,8 +53,8 @@
|
|||
/////
|
||||
var test_dynamicUnordered1 = async_test("Unordered module script execution (dynamic, unordered #1)");
|
||||
var test_dynamicUnordered2 = async_test("Unordered module script execution (dynamic, unordered #2)");
|
||||
create_script("execOrder-dynamicUnordered1.js", { module: true });
|
||||
create_script("execOrder-dynamicUnordered2.js", { module: true });
|
||||
create_script("execorder-dynamicunordered1.js", { module: true });
|
||||
create_script("execorder-dynamicunordered2.js", { module: true });
|
||||
/////
|
||||
// End test_dynamicUnordered*
|
||||
/////
|
||||
|
@ -68,13 +68,13 @@
|
|||
test_parsedOrdered.done();
|
||||
}));
|
||||
</script>
|
||||
<script src="execOrder-parsedOrdered2.js" defer></script>
|
||||
<script src="execorder-parsedordered2.js" defer></script>
|
||||
<script type="module">
|
||||
test_parsedOrdered.step(function() {
|
||||
assert_execCount(0, 3, "Inline module-typed script element should have fired third");
|
||||
});
|
||||
</script>
|
||||
<script src="execOrder-parsedOrdered4.js" defer></script>
|
||||
<script src="execorder-parsedordered4.js" defer></script>
|
||||
<script>
|
||||
test_parsedOrdered.step(function() {
|
||||
assert_execCount(0, 1, "Inline untyped script element should have fired first");
|
||||
|
@ -91,9 +91,9 @@
|
|||
assert_execCount(1, 5, "onload should have fired fifth (last)");
|
||||
test_dynamicOrdered.done();
|
||||
}));
|
||||
create_script("execOrder-dynamicOrdered2.js", { asyncOrdered: true, module: false });
|
||||
create_script("execOrder-dynamicOrdered3.js", { asyncOrdered: true, module: true });
|
||||
create_script("execOrder-dynamicOrdered4.js", { asyncOrdered: true, module: false });
|
||||
create_script("execorder-dynamicordered2.js", { asyncOrdered: true, module: false });
|
||||
create_script("execorder-dynamicordered3.js", { asyncOrdered: true, module: true });
|
||||
create_script("execorder-dynamicordered4.js", { asyncOrdered: true, module: false });
|
||||
test_dynamicOrdered.step(function() {
|
||||
assert_execCount(1, 1, "Inline untyped script element should have fired first");
|
||||
});
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
log.push("export-something-nested");
|
||||
export * from "./export-something.js";
|
|
@ -0,0 +1,3 @@
|
|||
log.push("export-something");
|
||||
export let foo = 42;
|
||||
export function set_foo(x) { foo = x };
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of fetch errors, 1</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that failure to fetch root leads to error event on script.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, ["script"]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="./no-such-file.js" onerror="log.push('script')"></script>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of fetch errors, 2</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that failure to fetch dependency leads to error event on script.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, ["script"]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="./fetch-error-2.js" onerror="log.push('script')"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import "./no-such-file.js"
|
||||
import "./this.js";
|
|
@ -0,0 +1,5 @@
|
|||
log.push("import-something-namespace");
|
||||
log.push(m.foo);
|
||||
m.set_foo(43);
|
||||
log.push(m.foo);
|
||||
import * as m from "./export-something.js";
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="module">
|
||||
import { delayedLoaded } from "./resources/delayed-modulescript.py";
|
||||
import { A } from "./404.js";
|
||||
window.loadSuccess = delayedLoaded;
|
||||
</script>
|
||||
<script type="module">
|
||||
test(function () {
|
||||
assert_equals(window.loadSuccess, undefined,
|
||||
"module tree w/ its sub graph 404 should fail to load without crashing");
|
||||
}, "Import a module graph w/ sub-graph 404.");
|
||||
</script>
|
|
@ -1,5 +1,6 @@
|
|||
import { CycleA } from "./imports-cycle-a.js";
|
||||
|
||||
test_importCycle.step(function () {
|
||||
assert_unreached("This module should not have loaded!");
|
||||
assert_equals(CycleA, "CycleA");
|
||||
test_importCycle.done();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { SelfInner } from "./imports-self-inner.js";
|
||||
|
||||
test_importSelf.step(function () {
|
||||
assert_unreached("This module should not have loaded!");
|
||||
assert_equals(SelfInner, "SelfInner");
|
||||
test_importSelf.done();
|
||||
});
|
||||
|
|
|
@ -52,13 +52,13 @@
|
|||
</script>
|
||||
|
||||
<script>
|
||||
var test_importSelf = async_test("Import a module that tries to import itself");
|
||||
var test_importSelf = async_test("Import a module that validly imports itself");
|
||||
</script>
|
||||
<script type="module" src="imports-self.js" onerror="test_importSelf.done();"></script>
|
||||
<script type="module" src="imports-self.js"></script>
|
||||
|
||||
<script>
|
||||
var test_importCycle = async_test("Import a module with a cyclical module dependency");
|
||||
var test_importCycle = async_test("Import a module with a valid cyclical module dependency");
|
||||
</script>
|
||||
<script type="module" src="imports-cycle.js" onerror="test_importCycle.done();"></script>
|
||||
<script type="module" src="imports-cycle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of instantiation errors, 1</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that missing exports lead to SyntaxError events on window and " +
|
||||
"load events on script, and that exceptions are remembered");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2, exn, 3, exn, 4, exn, 5]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./missing-export.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./missing-export.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
||||
<script type="module" src="./missing-export-nested.js"
|
||||
onerror="unreachable()" onload="log.push(3)"></script>
|
||||
<script type="module" src="./missing-export.js"
|
||||
onerror="unreachable()" onload="log.push(4)"></script>
|
||||
<script type="module" src="./missing-export-nested.js"
|
||||
onerror="unreachable()" onload="log.push(5)"></script>
|
|
@ -0,0 +1 @@
|
|||
import something from "./instantiation-error-1.js";
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of instantiation errors, 2</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that missing exports lead to SyntaxError events on window and " +
|
||||
"load events on script, and that exceptions are remembered");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2, exn, 3, exn, 4, exn, 5]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./missing-export-nested.js"
|
||||
onerror="unreachable()" onload="log.push(1)"></script>
|
||||
<script type="module" src="./missing-export-nested.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
||||
<script type="module" src="./missing-export.js"
|
||||
onerror="unreachable()" onload="log.push(3)"></script>
|
||||
<script type="module" src="./missing-export-nested.js"
|
||||
onerror="unreachable()" onload="log.push(4)"></script>
|
||||
<script type="module" src="./missing-export.js"
|
||||
onerror="unreachable()" onload="log.push(5)"></script>
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of instantiation errors, 3</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that unresolvable cycles lead to SyntaxError events on window " +
|
||||
"and load events on script, and that exceptions are remembered");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
const exn = log[0];
|
||||
assert_array_equals(log, [exn, 1, exn, 2, exn, 3]);
|
||||
assert_equals(exn.constructor, SyntaxError);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./cycle-unresolvable.js"
|
||||
onerror="unreachable()" onload="log.push(1)" nomodule></script>
|
||||
<script type="module" src="./cycle-unresolvable-a.js"
|
||||
onerror="unreachable()" onload="log.push(2)"></script>
|
||||
<script type="module" src="./cycle-unresolvable.js"
|
||||
onerror="unreachable()" onload="log.push(3)" async></script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Late namespace request</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test the situation where a module is instantiated without the " +
|
||||
"need for a namespace object, but later on a different module " +
|
||||
"requests the namespace.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log,
|
||||
["export-something",
|
||||
"import-something-namespace", 42, 43]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="export-something.js"></script>
|
||||
<script type="module" src="import-something-namespace.js"></script>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Late star-export request</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test the situation where a module is instantiated without a use of " +
|
||||
"its star-exports, but later on a different module requests them.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, [
|
||||
"export-something", "export-something-nested",
|
||||
"import-something-namespace", 42, 43]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="export-something-nested.js"></script>
|
||||
<script type="module">
|
||||
log.push("import-something-namespace");
|
||||
log.push(foo);
|
||||
set_foo(43);
|
||||
log.push(foo);
|
||||
import {foo, set_foo} from "./export-something-nested.js";
|
||||
</script>
|
|
@ -0,0 +1,2 @@
|
|||
import "./missing-export.js";
|
||||
log.push("nested-missing-export");
|
|
@ -0,0 +1,2 @@
|
|||
import something from "./missing-export.js";
|
||||
log.push("missing-export");
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Once as module script, once as classic script</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that evaluating something as classic script does not prevent " +
|
||||
"it from being evaluated as module script.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, [window, undefined]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="this.js"></script>
|
||||
<script src="this.js"></script>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Once as classic script, once as module script</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that evaluating something as classic script does not prevent " +
|
||||
"it from being evaluated as module script.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, [window, undefined]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="this.js"></script>
|
||||
<script src="this.js"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import "./missing-export.js";
|
||||
log.push("missing-export-nested");
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<title>The 'nomodule' attribute</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that 'nomodule' has the desired effect on classic scripts, but " +
|
||||
"no effect on module scripts.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, [undefined]);
|
||||
}));
|
||||
|
||||
</script>
|
||||
<script type="module" src="this.js" nomodule></script>
|
||||
<script src="this.js" nomodule></script>
|
|
@ -0,0 +1,7 @@
|
|||
import time
|
||||
|
||||
def main(request, response):
|
||||
delay = float(request.GET.first("ms", 500))
|
||||
time.sleep(delay / 1E3);
|
||||
|
||||
return [("Content-type", "text/javascript")], "export let delayedLoaded = true;"
|
|
@ -0,0 +1,93 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Module scripts with for and event attributes</title>
|
||||
<link rel="author" title="Matheus Kerschbaum" href="mailto:matjk7@gmail.com">
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var expected = [
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
];
|
||||
var run = expected.map(function() { return false });
|
||||
</script>
|
||||
<script for="wİndow" event="onload" type="module">
|
||||
run[0] = true;
|
||||
</script>
|
||||
<script for="window" event="onload x" type="module">
|
||||
run[1] = true;
|
||||
</script>
|
||||
<script for="window" event="onload(x" type="module">
|
||||
run[2] = true;
|
||||
</script>
|
||||
<script for="window" event="onload(x)" type="module">
|
||||
run[3] = true;
|
||||
</script>
|
||||
<script for="window" event="onclick" type="module">
|
||||
run[4] = true;
|
||||
</script>
|
||||
<script for="" event="onload" type="module">
|
||||
run[5] = true;
|
||||
</script>
|
||||
<script for="window" event="" type="module">
|
||||
run[6] = true;
|
||||
</script>
|
||||
<script for="" event="" type="module">
|
||||
run[7] = true;
|
||||
</script>
|
||||
<script for=" window" event="onload" type="module">
|
||||
run[8] = true;
|
||||
</script>
|
||||
<script for="window " event="onload" type="module">
|
||||
run[9] = true;
|
||||
</script>
|
||||
<script for="window" event=" onload" type="module">
|
||||
run[10] = true;
|
||||
</script>
|
||||
<script for="window" event="onload " type="module">
|
||||
run[11] = true;
|
||||
</script>
|
||||
<script for=" window " event=" onload " type="module">
|
||||
run[12] = true;
|
||||
</script>
|
||||
<script for=" window " event=" onload() " type="module">
|
||||
run[13] = true;
|
||||
</script>
|
||||
<script for="object" event="handler" type="module">
|
||||
run[14] = true;
|
||||
</script>
|
||||
<script event="handler" type="module">
|
||||
run[15] = true;
|
||||
</script>
|
||||
<script for="object" type="module">
|
||||
run[16] = true;
|
||||
</script>
|
||||
<script type="module">
|
||||
test(function() {
|
||||
for (var i = 0; i < run.length; ++i) {
|
||||
test(function() {
|
||||
var script = document.querySelectorAll("script[for], script[event]")[i];
|
||||
assert_equals(run[i], expected[i],
|
||||
"script for=" + format_value(script.getAttribute("for")) +
|
||||
" event=" + format_value(script.getAttribute("event")));
|
||||
}, "Script " + i);
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
window.currentScriptRecorded = document.currentScript;
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Single evaluation, 1</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that a module is evaluated only once, and that 'this' is " +
|
||||
"undefined (because of strict mode).");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, [undefined, "this-nested"]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="this.js"></script>
|
||||
<script type="module" src="this.js"></script>
|
||||
<script type="module" src="this-nested.js"></script>
|
||||
<script type="module" src="this.js"></script>
|
||||
<script type="module" src="this-nested.js"></script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Single evaluation, 2</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
window.log = [];
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that a module is evaluated only once, and that 'this' is " +
|
||||
"undefined (because of strict mode).");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_array_equals(log, [undefined, "this-nested"]);
|
||||
}));
|
||||
</script>
|
||||
<script type="module" src="this-nested.js"></script>
|
||||
<script type="module" src="this-nested.js"></script>
|
||||
<script type="module" src="this.js"></script>
|
||||
<script type="module" src="this-nested.js"></script>
|
||||
<script type="module" src="this.js"></script>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Cyclic graph with slow imports</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="module">
|
||||
import { loaded } from "./slow-module-graph-a.js";
|
||||
|
||||
test(() => {
|
||||
assert_true(loaded);
|
||||
}, "module graph with cycles load even if part of the graph loads slow");
|
||||
</script>
|
|
@ -0,0 +1,3 @@
|
|||
import "./slow-module-graph-b.js";
|
||||
import "./resources/delayed-modulescript.py"
|
||||
export let loaded = true;
|
|
@ -0,0 +1 @@
|
|||
import "./slow-module-graph-a.js";
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of invalid specifiers</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
|
||||
window.log = [];
|
||||
|
||||
window.addEventListener("error", ev => log.push(ev.error));
|
||||
|
||||
const test_load = async_test(
|
||||
"Test that invalid module specifier leads to TypeError on window.");
|
||||
window.addEventListener("load", test_load.step_func_done(ev => {
|
||||
assert_equals(log.length, 1);
|
||||
assert_equals(log[0].constructor, TypeError);
|
||||
}));
|
||||
|
||||
function unreachable() { log.push("unexpected"); }
|
||||
</script>
|
||||
<script type="module" src="./bad-module-specifier.js" onerror="unreachable()"></script>
|
|
@ -0,0 +1,2 @@
|
|||
import "./syntaxerror.js";
|
||||
log.push("nested-syntaxerror");
|
|
@ -0,0 +1,2 @@
|
|||
log.push("syntaxerror");
|
||||
%!#$@#$@#$@
|
|
@ -0,0 +1,2 @@
|
|||
import "./this.js";
|
||||
log.push("this-nested");
|
|
@ -0,0 +1 @@
|
|||
log.push(this);
|
|
@ -0,0 +1,2 @@
|
|||
import "./throw.js";
|
||||
log.push("throw-nested");
|
|
@ -0,0 +1,2 @@
|
|||
log.push("throw");
|
||||
throw {foo: true}
|
|
@ -11,31 +11,27 @@
|
|||
</head>
|
||||
<body>
|
||||
<script>
|
||||
let supportsNoModule = "noModule" in document.getElementsByTagName("script")[0];
|
||||
|
||||
waitForLoadEvent = new Promise((resolve) => {
|
||||
window.onload = resolve;
|
||||
});
|
||||
|
||||
waitForAsyncScript = () => {
|
||||
return new Promise((resolve) => {
|
||||
waitForLoadEvent.then(() => setTimeout(resolve, 200));
|
||||
});
|
||||
}
|
||||
|
||||
let readyForSecondTest;
|
||||
promise_test(() => {
|
||||
window.executed = false;
|
||||
let loaded = false;
|
||||
let errored = false;
|
||||
|
||||
let script = document.createElement('script');
|
||||
|
||||
script.src = './resources/set-script-executed.js';
|
||||
script.onload = () => loaded = true;
|
||||
script.onerror = () => errored = true;
|
||||
script.noModule = false;
|
||||
document.body.appendChild(script);
|
||||
|
||||
return waitForAsyncScript().then(() => {
|
||||
return waitForLoadEvent.then(() => {
|
||||
assert_true(supportsNoModule);
|
||||
assert_true(executed);
|
||||
assert_true(loaded);
|
||||
assert_false(errored);
|
||||
|
@ -54,7 +50,8 @@ promise_test(() => {
|
|||
script.noModule = true;
|
||||
document.body.appendChild(script);
|
||||
|
||||
return waitForAsyncScript().then(() => {
|
||||
return waitForLoadEvent.then(() => {
|
||||
assert_true(supportsNoModule);
|
||||
assert_false(executed);
|
||||
assert_false(loaded);
|
||||
assert_false(errored);
|
||||
|
|
|
@ -36,11 +36,6 @@ test(() => {
|
|||
assert_false(errored);
|
||||
}, 'A synchronously loaded external classic script with nomodule content attribute must not run');
|
||||
|
||||
|
||||
waitForLoadEvent = new Promise((resolve) => {
|
||||
window.onload = resolve;
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue