Base URL: Simplify WPT

This CL simplifies a test that some incorrect usages of `async`, and a
few function indirections that are not necessary.

R=domenic@chromium.org

Bug: 1478463
Change-Id: I439c5fcf11ac5a26a0e3a452db48537fb7d21eac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4926189
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1208024}
diff --git a/html/infrastructure/urls/base-url/document-base-url-changes-about-srcdoc-2.https.html b/html/infrastructure/urls/base-url/document-base-url-changes-about-srcdoc-2.https.html
index 14e712c..dab8d21 100644
--- a/html/infrastructure/urls/base-url/document-base-url-changes-about-srcdoc-2.https.html
+++ b/html/infrastructure/urls/base-url/document-base-url-changes-about-srcdoc-2.https.html
@@ -3,16 +3,20 @@
 <script src="/resources/testharnessreport.js"></script>
 <script src="/common/get-host-info.sub.js"></script>
 
+<iframe src='about:blank'></iframe>
+
 <script>
 // If document.open's behavior is modified to remove the url-rewriting behavior,
 // then this test can be deleted (https://github.com/whatwg/html/issues/3989).
 setup({ explicit_done: true });
 
+// This function is called by directly by the child iframe (above), with the
+// child iframe's document. The child iframe's document contains an about:srcdoc iframe.
 window.start = childDocument => {
   const grandchildDocument =
     childDocument.getElementById('foo').contentDocument;
 
-  test(t => {
+  test(() => {
     assert_equals(childDocument.URL, 'about:blank',
       'Child document starting URL');
     assert_equals(grandchildDocument.URL, 'about:srcdoc',
@@ -45,27 +49,19 @@
 
   done();
 };
-</script>
 
-<iframe src='about:blank'></iframe>
+let subframe_doc = document.querySelector('iframe').contentDocument;
+subframe_doc.body.innerHTML = '<iframe srcdoc="foo" id="foo"></iframe>';
+promise_test(async t => {
+  const grandchildIframe = subframe_doc.querySelector('iframe');
+  await new Promise(resolve => {
+    grandchildIframe.onload = resolve;
+  });
 
-<script>
-  window.onload = () => {
-    let subframe_doc = document.querySelector('iframe').contentDocument;
-    subframe_doc.body.innerHTML = '<iframe srcdoc="foo" id="foo"></iframe>';
-    promise_test((test) => {
-      return new Promise(async resolve => {
-      // We need a timeout since the srcdoc frame takes time to setup and
-      // doesn't fire a loadstop.
-      test.step_timeout(resolve, 100);
-      }).then(() => {
-        assert_equals(
-            subframe_doc.getElementById('foo').contentDocument.URL,
-            'about:srcdoc');
-        let script = subframe_doc.createElement('script');
-        script.innerHTML = 'parent.start(document);';
-        subframe_doc.body.appendChild(script);
-      });
-    }, "wrapper promise test for timeout.");
-  };
+  assert_equals(grandchildIframe.contentDocument.URL, 'about:srcdoc');
+
+  let script = subframe_doc.createElement('script');
+  script.innerHTML = 'parent.start(document);';
+  subframe_doc.body.appendChild(script);
+}, "wrapper promise test for timeout.");
 </script>