Revert "Revert "WPT: Allow `window.onload` to contain multiple `test()`s"" (#38806)

This reverts commit 5c571b86bc98819157b584132bca1b80ca4503cb.

DO NOT MERGE: run `./wpt test-jobs --all` to see if it passes

Adjust test to test for two assertions

https://github.com/web-platform-tests/wpt/pull/38806#issuecomment-1453747441

Revert "DO NOT MERGE: run `./wpt test-jobs --all` to see if it passes"

This reverts commit 889140448d8a34cd1e17ef39aa15f8ca26ff2f0a.

Update comments

- Add @foolip's suggestion from https://github.com/web-platform-tests/wpt/pull/38806#discussion_r1126193183
- Also, update comment at the top with better phrasing.

change referenced PR/CL
diff --git a/content-security-policy/style-src/inline-style-allowed-while-cloning-objects.sub.html b/content-security-policy/style-src/inline-style-allowed-while-cloning-objects.sub.html
index e996994..f702e6e 100644
--- a/content-security-policy/style-src/inline-style-allowed-while-cloning-objects.sub.html
+++ b/content-security-policy/style-src/inline-style-allowed-while-cloning-objects.sub.html
@@ -8,119 +8,108 @@
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script>
-        setup({ explicit_done: true });
-
         var t = async_test("Test that violation report event was fired");
         window.addEventListener("securitypolicyviolation", t.step_func_done(function(e) {
             assert_equals(e.violatedDirective, "style-src-attr");
         }));
         window.onload = function() {
-            try {
-                runTests();
-            } finally {
-                done();
-            }
+          window.nodes = document.getElementById('nodes');
+          window.node1 = document.getElementById('node1');
+          window.node1.style.background = "yellow";
+          window.node1.style.color = "red";
+          window.node2 = document.getElementById('node1').cloneNode(true);
+          window.node2.id = "node2";
+          window.node3 = document.getElementById('node3');
+          window.node3.style.background = "blue";
+          window.node3.style.color = "green";
+          window.node4 = document.getElementById('node3').cloneNode(false);
+          window.node4.id = "node4";
+          window.node4.innerHTML = "Node #4";
+          nodes.appendChild(node1);
+          nodes.appendChild(node2);
+          nodes.appendChild(node3);
+          nodes.appendChild(node4);
+          test(function() {
+              assert_equals(node1.style.background.match(/yellow/)[0], "yellow")
+          });
+          test(function() {
+              assert_equals(node2.style.background.match(/yellow/)[0], "yellow")
+          });
+          test(function() {
+              assert_equals(node3.style.background.match(/blue/)[0], "blue")
+          });
+          test(function() {
+              assert_equals(node4.style.background.match(/blue/)[0], "blue")
+          });
+          test(function() {
+              assert_equals(node1.style.color, "red")
+          });
+          test(function() {
+              assert_equals(node2.style.color, "red")
+          });
+          test(function() {
+              assert_equals(node3.style.color, "green")
+          });
+          test(function() {
+              assert_equals(node4.style.color, "green")
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(node1).background, window.getComputedStyle(node2).background)
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(node3).background, window.getComputedStyle(node4).background)
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(node1).color, window.getComputedStyle(node2).color)
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(node3).color, window.getComputedStyle(node4).color)
+          });
+          window.ops = document.getElementById('ops');
+          ops.style.color = 'red';
+          window.clonedOps = ops.cloneNode(true);
+          window.violetOps = document.getElementById('violetOps');
+          violetOps.style.background = 'rgb(238, 130, 238)';
+          document.getElementsByTagName('body')[0].appendChild(clonedOps);
+          test(function() {
+              assert_equals(ops.style.background, "")
+          });
+          test(function() {
+              assert_equals(ops.style.color, "red")
+          });
+          test(function() {
+              assert_equals(clonedOps.style.background, "")
+          });
+          test(function() {
+              assert_equals(violetOps.style.background.match(/rgb\(238, 130, 238\)/)[0], "rgb(238, 130, 238)")
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(clonedOps).background, window.getComputedStyle(ops).background)
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(clonedOps).color, window.getComputedStyle(ops).color)
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(ops).background, window.getComputedStyle(violetOps).background)
+          });
+          test(function() {
+              assert_equals(window.getComputedStyle(clonedOps).background, window.getComputedStyle(violetOps).background)
+          });
+          test(function() {
+              assert_equals(ops.id, "ops")
+          });
+          test(function() {
+              assert_equals(ops.id, clonedOps.id)
+          });
+          test(function() {
+              let el = document.getElementById("svg");
+              assert_equals(el.getAttribute("style"), "");
+              el.style.background = violetOps.style.background;
+              assert_not_equals(el.style.background, "");
+              let clone = el.cloneNode(true);
+              assert_equals(el.style.background, clone.style.background)
+          }, "non-HTML namespace");
         };
-
-        function runTests() {
-            window.nodes = document.getElementById('nodes');
-            window.node1 = document.getElementById('node1');
-            window.node1.style.background = "yellow";
-            window.node1.style.color = "red";
-            window.node2 = document.getElementById('node1').cloneNode(true);
-            window.node2.id = "node2";
-            window.node3 = document.getElementById('node3');
-            window.node3.style.background = "blue";
-            window.node3.style.color = "green";
-            window.node4 = document.getElementById('node3').cloneNode(false);
-            window.node4.id = "node4";
-            window.node4.innerHTML = "Node #4";
-            nodes.appendChild(node1);
-            nodes.appendChild(node2);
-            nodes.appendChild(node3);
-            nodes.appendChild(node4);
-            test(function() {
-                assert_equals(node1.style.background.match(/yellow/)[0], "yellow")
-            });
-            test(function() {
-                assert_equals(node2.style.background.match(/yellow/)[0], "yellow")
-            });
-            test(function() {
-                assert_equals(node3.style.background.match(/blue/)[0], "blue")
-            });
-            test(function() {
-                assert_equals(node4.style.background.match(/blue/)[0], "blue")
-            });
-            test(function() {
-                assert_equals(node1.style.color, "red")
-            });
-            test(function() {
-                assert_equals(node2.style.color, "red")
-            });
-            test(function() {
-                assert_equals(node3.style.color, "green")
-            });
-            test(function() {
-                assert_equals(node4.style.color, "green")
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(node1).background, window.getComputedStyle(node2).background)
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(node3).background, window.getComputedStyle(node4).background)
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(node1).color, window.getComputedStyle(node2).color)
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(node3).color, window.getComputedStyle(node4).color)
-            });
-            window.ops = document.getElementById('ops');
-            ops.style.color = 'red';
-            window.clonedOps = ops.cloneNode(true);
-            window.violetOps = document.getElementById('violetOps');
-            violetOps.style.background = 'rgb(238, 130, 238)';
-            document.getElementsByTagName('body')[0].appendChild(clonedOps);
-            test(function() {
-                assert_equals(ops.style.background, "")
-            });
-            test(function() {
-                assert_equals(ops.style.color, "red")
-            });
-            test(function() {
-                assert_equals(clonedOps.style.background, "")
-            });
-            test(function() {
-                assert_equals(violetOps.style.background.match(/rgb\(238, 130, 238\)/)[0], "rgb(238, 130, 238)")
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(clonedOps).background, window.getComputedStyle(ops).background)
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(clonedOps).color, window.getComputedStyle(ops).color)
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(ops).background, window.getComputedStyle(violetOps).background)
-            });
-            test(function() {
-                assert_equals(window.getComputedStyle(clonedOps).background, window.getComputedStyle(violetOps).background)
-            });
-            test(function() {
-                assert_equals(ops.id, "ops")
-            });
-            test(function() {
-                assert_equals(ops.id, clonedOps.id)
-            });
-            test(function() {
-                let el = document.getElementById("svg");
-                assert_equals(el.getAttribute("style"), "");
-                el.style.background = violetOps.style.background;
-                assert_not_equals(el.style.background, "");
-                let clone = el.cloneNode(true);
-                assert_equals(el.style.background, clone.style.background)
-            }, "non-HTML namespace");
-        }
-
     </script>
 </head>
 
diff --git a/css/cssom-view/negativeMargins.html b/css/cssom-view/negativeMargins.html
index 0616e8b..0deb7ca 100644
--- a/css/cssom-view/negativeMargins.html
+++ b/css/cssom-view/negativeMargins.html
@@ -9,7 +9,6 @@
   Hello
 </div>
 <script>
- setup({explicit_done:true});
  window.onload = function () {
    var outer = document.getElementById('outer');
    var inner = document.getElementById('inner');
@@ -26,7 +25,6 @@
                          [inner, outer, document.body, document.querySelector('html')],
                          "elementsFromPoint should get sequence [inner, outer, body, html]");
    });
-   done();
  };
 </script>
 </body>
diff --git a/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html b/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html
index 239fa6d..c2a6def 100644
--- a/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html
+++ b/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html
@@ -12,8 +12,6 @@
 
 <script>
 "use strict";
-setup({ explicit_done: true });
-
 window.onload = () => {
   const target = frames[0];
   const origProto = Object.getPrototypeOf(target);
@@ -33,7 +31,5 @@
   testSettingImmutablePrototypeToNewValueOnly(
     "Became cross-origin via document.domain", target, origProto,
     "the original value from before going cross-origin", { isSameOriginDomain: false });
-
-  done();
 };
 </script>
diff --git a/infrastructure/README.md b/infrastructure/README.md
index 7d0ec55..9e25c40 100644
--- a/infrastructure/README.md
+++ b/infrastructure/README.md
@@ -2,7 +2,7 @@
 infrastructure is operating correctly:
 
  * The tests in assumptions/ are designed to test UA assumptions
-   documented in [assumptions.md](/docs/_writing-tests/assumptions.md).
+   documented in [assumptions.md](/docs/writing-tests/assumptions.md).
 
  * The tests in server/ are designed to test the WPT server configuration
 
diff --git a/infrastructure/expected-fail/window-onload-test.html b/infrastructure/expected-fail/window-onload-test.html
new file mode 100644
index 0000000..b0514bc
--- /dev/null
+++ b/infrastructure/expected-fail/window-onload-test.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<script>
+window.onload = () => {
+  test((t) => {
+    assert_true(true,'This should pass');
+  }, 'test 1');
+  test((t) => {
+    assert_true(false,'This should FAIL');
+  }, 'test 2');
+  test((t) => {
+    assert_true(false,'This should FAIL');
+  }, 'test 3');
+
+  promise_test(async t => {
+    assert_true(false,'This should FAIL');
+  },'promise 1');
+  promise_test(async t => {
+    assert_true(false,'This should FAIL');
+  },'promise 2');
+  promise_test(async t => {
+    assert_true(false,'This should FAIL');
+  },'promise 3');
+};
+</script>
diff --git a/resources/test/tests/unit/late-test.html b/resources/test/tests/unit/late-test.html
index 693d7e3..c9f8ec6 100644
--- a/resources/test/tests/unit/late-test.html
+++ b/resources/test/tests/unit/late-test.html
@@ -10,11 +10,12 @@
 <p>This test simulates an automated test running scenario, where the test
 results emitted by testharness.js may be interpreted after some delay. It is
 intended to demonstrate that in such cases, any additional tests which are
-executed during that delay are <em>not</em> included in the dataset.</p>
+executed during that delay are included in the dataset.</p>
 
-<p>Although these "late" tests are likely an indication of a mistake in test
-design, they cannot be detected deterministically, so in the interest of
-stability, they should be silently tolerated.</p>
+<p>Although these "late tests" are likely an indication of a mistake in test
+design, they are also recorded. Previously, "late tests" were ignored.
+This test changed to assert "late tests" were no longer ignored after
+https://github.com/web-platform-tests/wpt/pull/38806 was introduced.</p>
 <script>
 async_test(function(t) {
     var source = [
@@ -27,7 +28,7 @@
         "test(function() {}, 'acceptable test');",
         "onload = function() {",
         "  done();",
-        "  test(function() {}, 'this test is late and should be ignored');",
+        "  test(function() {}, 'test registered in onload handler');",
         "};",
         "</" + "script>"
     ].join("\n");
@@ -37,8 +38,9 @@
     window.childReady = t.step_func(function(childWindow) {
         childWindow.add_completion_callback(t.step_func(function(tests, status) {
             t.step_timeout(t.step_func(function() {
-                assert_equals(tests.length, 1);
+                assert_equals(tests.length, 2);
                 assert_equals(tests[0].name, "acceptable test");
+                assert_equals(tests[1].name, "test registered in onload handler");
                 assert_equals(status.status, status.OK);
                 t.done();
             }), 0);
diff --git a/resources/testharness.js b/resources/testharness.js
index 497ae23..bc7fb89 100644
--- a/resources/testharness.js
+++ b/resources/testharness.js
@@ -91,7 +91,12 @@
         }
 
         on_event(window, 'load', function() {
+          setTimeout(() => {
             this_obj.all_loaded = true;
+            if (tests.all_done()) {
+              tests.complete();
+            }
+          },0);
         });
 
         on_event(window, 'message', function(event) {