Merge pull request #8874 from w3c/sync_11b17e5486dfec34d78ce5b75527f9fc75ea7cd7
Update JS module tests now that repeated instantiation failures of a module are no longer required to throw the same value
diff --git a/html/semantics/scripting-1/the-script-element/module/instantiation-error-1.html b/html/semantics/scripting-1/the-script-element/module/instantiation-error-1.html
index 1cb0799..57b40f5 100644
--- a/html/semantics/scripting-1/the-script-element/module/instantiation-error-1.html
+++ b/html/semantics/scripting-1/the-script-element/module/instantiation-error-1.html
@@ -6,25 +6,19 @@
<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");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
+ log.push(ev.message);
+ });
+
window.addEventListener("load", test_load.step_func_done(ev => {
- assert_equals(log.length, 10);
- assert_equals(log[0].constructor, SyntaxError);
- assert_equals(log[1], 1);
- assert_equals(log[2].constructor, SyntaxError);
- assert_equals(log[3], 2);
- assert_equals(log[4].constructor, SyntaxError);
- assert_equals(log[5], 3);
- assert_equals(log[6].constructor, SyntaxError);
- assert_equals(log[7], 4);
- assert_equals(log[8].constructor, SyntaxError);
- assert_equals(log[9], 5);
+ const msg = log[0];
+ assert_array_equals(log, [msg, 1, msg, 2, msg, 3, msg, 4, msg, 5]);
}));
function unreachable() { log.push("unexpected"); }
diff --git a/html/semantics/scripting-1/the-script-element/module/instantiation-error-2.html b/html/semantics/scripting-1/the-script-element/module/instantiation-error-2.html
index d7151f2..27ba006 100644
--- a/html/semantics/scripting-1/the-script-element/module/instantiation-error-2.html
+++ b/html/semantics/scripting-1/the-script-element/module/instantiation-error-2.html
@@ -6,25 +6,19 @@
<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");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
+ log.push(ev.message);
+ });
+
window.addEventListener("load", test_load.step_func_done(ev => {
- assert_equals(log.length, 10);
- assert_equals(log[0].constructor, SyntaxError);
- assert_equals(log[1], 1);
- assert_equals(log[2].constructor, SyntaxError);
- assert_equals(log[3], 2);
- assert_equals(log[4].constructor, SyntaxError);
- assert_equals(log[5], 3);
- assert_equals(log[6].constructor, SyntaxError);
- assert_equals(log[7], 4);
- assert_equals(log[8].constructor, SyntaxError);
- assert_equals(log[9], 5);
+ const msg = log[0];
+ assert_array_equals(log, [msg, 1, msg, 2, msg, 3, msg, 4, msg, 5]);
}));
function unreachable() { log.push("unexpected"); }
diff --git a/html/semantics/scripting-1/the-script-element/module/instantiation-error-3.html b/html/semantics/scripting-1/the-script-element/module/instantiation-error-3.html
index 739bf0e..e03fcc0 100644
--- a/html/semantics/scripting-1/the-script-element/module/instantiation-error-3.html
+++ b/html/semantics/scripting-1/the-script-element/module/instantiation-error-3.html
@@ -6,21 +6,19 @@
<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");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
+ log.push(ev.message);
+ });
+
window.addEventListener("load", test_load.step_func_done(ev => {
- assert_equals(log.length, 6);
- assert_equals(log[0].constructor, SyntaxError);
- assert_equals(log[1], 1);
- assert_equals(log[2].constructor, SyntaxError);
- assert_equals(log[3], 2);
- assert_equals(log[4].constructor, SyntaxError);
- assert_equals(log[5], 3);
+ const msg = log[0];
+ assert_array_equals(log, [msg, 1, msg, 2, msg, 3]);
}));
function unreachable() { log.push("unexpected"); }
diff --git a/html/semantics/scripting-1/the-script-element/module/instantiation-error-4.html b/html/semantics/scripting-1/the-script-element/module/instantiation-error-4.html
index b6be1db..238e883 100644
--- a/html/semantics/scripting-1/the-script-element/module/instantiation-error-4.html
+++ b/html/semantics/scripting-1/the-script-element/module/instantiation-error-4.html
@@ -7,18 +7,18 @@
setup({allow_uncaught_exception: true});
window.log = [];
-
- window.addEventListener("error", ev => log.push(ev.error));
-
const test_load = async_test(
"Test that loading a graph in which a module is already " +
- "errored results in that module's error.");
+ "errored results in an error.");
+
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
+ log.push(ev.message);
+ });
+
window.addEventListener("load", test_load.step_func_done(ev => {
- assert_equals(log.length, 4);
- assert_equals(log[0].constructor, SyntaxError);
- assert_equals(log[1], 1);
- assert_equals(log[2].constructor, SyntaxError);
- assert_equals(log[3], 2);
+ const msg = log[0];
+ assert_array_equals(log, [msg, 1, msg, 2]);
}));
function unreachable() { log.push("unexpected"); }
diff --git a/html/semantics/scripting-1/the-script-element/module/instantiation-error-5.html b/html/semantics/scripting-1/the-script-element/module/instantiation-error-5.html
index 5afd011..de2b6ba 100644
--- a/html/semantics/scripting-1/the-script-element/module/instantiation-error-5.html
+++ b/html/semantics/scripting-1/the-script-element/module/instantiation-error-5.html
@@ -6,20 +6,19 @@
<script>
setup({allow_uncaught_exception: true});
- window.log = [];
-
- window.addEventListener("error", ev => log.push(ev.error));
-
const test_load = async_test(
"Test that loading a graph in which a module is already " +
- "errored results in that module's error.");
+ "errored results an error.");
+
+ window.log = [];
+ window.addEventListener("error", ev => {
+ test_load.step(() => assert_equals(ev.error.constructor, SyntaxError));
+ log.push(ev.message);
+ });
+
window.addEventListener("load", test_load.step_func_done(ev => {
- assert_equals(log.length, 4);
- assert_equals(log[0].constructor, SyntaxError);
- assert_equals(log[1], 1);
- assert_equals(log[2].constructor, SyntaxError);
- assert_equals(log[3], 2);
- assert_not_equals(log[0], log[2], "errors should be different");
+ const msg = log[0];
+ assert_array_equals(log, [msg, 1, msg, 2]);
}));
function unreachable() { log.push("unexpected"); }