Bug 1643189 [wpt PR 23964] - Origin isolation: refactor and deduplicate web platform tests, a=testonly
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Mon, 22 Jun 2020 10:42:28 +0000
changeset 536843 9eebe1e610fbb45c77f71ec64993e5b2501c28f1
parent 536842 b4e7bfe7b46443e30cd5eee09a8fa6ce38b81c90
child 536844 fc5c49e3cb0811cf34651625937ef77153e925f3
push id119680
push userwptsync@mozilla.com
push dateTue, 23 Jun 2020 11:08:22 +0000
treeherderautoland@7ca3d4bada73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1643189, 23964, 1042415, 2229435, 777962
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1643189 [wpt PR 23964] - Origin isolation: refactor and deduplicate web platform tests, a=testonly Automatic update from web-platform-tests Origin isolation: refactor and deduplicate web platform tests (#23964) Now that I've written a bunch of them, I'm confident in building some abstractions to deduplicate the testing code. This additionally adds jsdoc documentation for all of the exported functions in helpers.mjs. Bug: 1042415 Change-Id: I3e2220708f4d5afff5a815de876971db3f689826 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2229435 Reviewed-by: James MacLean <wjmaclean@chromium.org> Commit-Queue: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/master@{#777962} Co-authored-by: Domenic Denicola <domenic@chromium.org> -- wpt-commits: 3720a98370fbb9e4ffea6a102cb29b54ca2e189c wpt-pr: 23964
testing/web-platform/tests/origin-isolation/going-back.sub.https.html
testing/web-platform/tests/origin-isolation/insecure-http.sub.html
testing/web-platform/tests/origin-isolation/parent-no-child-bad-subdomain.sub.https.html
testing/web-platform/tests/origin-isolation/parent-no-child-yes-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-no-child-yes-subdomain.sub.https.html
testing/web-platform/tests/origin-isolation/parent-no-child-yes-with-params-subdomain.sub.https.html
testing/web-platform/tests/origin-isolation/parent-no-child1-no-child2-yes-children-different.sub.https.html
testing/web-platform/tests/origin-isolation/parent-no-child1-no-child2-yes-children-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-no-child1-yes-child2-no-children-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child-no-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child-no-subdomain.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child-yes-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child-yes-subdomain.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-no-children-different.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-no-children-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-yes-children-different.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-yes-children-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-no-children-same.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-yes-children-different.sub.https.html
testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-yes-children-same.sub.https.html
testing/web-platform/tests/origin-isolation/removing-iframes.sub.https.html
testing/web-platform/tests/origin-isolation/resources/helpers.mjs
--- a/testing/web-platform/tests/origin-isolation/going-back.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/going-back.sub.https.html
@@ -2,129 +2,61 @@
 <meta charset="utf-8">
 <title>Parent is isolated, child1 is not isolated, child1 navigates to a different site, child2 gets inserted and is isolated, child1 navigates back</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, navigateIframe, waitForIframe, sendWasmModule,
-         setBothDocumentDomains, sendWasmModuleBetween, accessDocumentBetween }
-       from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  navigateIframe,
+  waitForIframe,
+  setBothDocumentDomains,
+  testDifferentAgentClusters,
+  testSameAgentCluster,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frame1, frameWindow2;
+let frame1;
 promise_setup(async () => {
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frame1 = document.querySelector("iframe");
+  frame1 = await insertIframe("{{hosts[][www]}}");
 });
 
 // Since they're different-origin, the parent's isolation request is respected,
 // as is the child's non-request. So the parent ends up in the origin-keyed
 // agent cluster and the child ends up in the site-keyed one.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Before navigation: parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow1);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Before navigation: parent to child1: setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 0], "Before navigation: parent to child1");
 
 // Navigate the iframe to a different site. These, of course, must not be in the
 // same agent cluster.
 
 promise_test(async () => {
   await navigateIframe(frame1, "{{hosts[alt][]}}");
 }, "Navigation");
 
 // Now insert a second iframe, pointing to the same place as the first one
 // originally did, but this time with origin isolation enabled. Because of the
 // historical map of agent cluster keys for the browsing context group, the new
 // iframe should still end up in the site-keyed agent cluster.
 
 promise_test(async () => {
-  frameWindow2 = await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}", "?1");
 }, "Inserting a second iframe");
 
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "After navigation: parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow2);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "After navigation: parent to child2: setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 1], "After navigation: parent to child2");
 
 // Now navigate the first iframe back. The resulting Document should be put in
 // the site agent cluster, together with the second iframe's Document.
 
 promise_test(async () => {
   const waitPromise = waitForIframe(frame1);
   history.back();
   await waitPromise;
 
-  await setBothDocumentDomains(frameWindow1);
+  await setBothDocumentDomains(frames[0]);
 }, "Going back in history (navigating back the first iframe)");
 
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "After back: parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow2);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "After back: parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "After back: parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow1);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "After back: parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "After back: parent to child1");
+testDifferentAgentClusters([self, 1], "After back: parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/insecure-http.sub.html
+++ b/testing/web-platform/tests/origin-isolation/insecure-http.sub.html
@@ -2,31 +2,18 @@
 <meta charset="utf-8">
 <title>Parent requests isolation, child requests isolation, child is a subdomain of the parent, but all over insecure HTTP</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testSameAgentCluster } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}", "?1");
 });
 
 // All isolation requests are ignored, since this is over insecure HTTP.
 // So both end up in the site-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "message event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  // Must not throw
-  frameWindow.document;
-}, "setting document.domain must give sync access");
+testSameAgentCluster([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child-bad-subdomain.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child-bad-subdomain.sub.https.html
@@ -2,32 +2,21 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, child attempts to isolate but uses a bad header value, child is a subdomain of the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testSameAgentCluster } from "./resources/helpers.mjs";
 
+let frameIndex = 0;
 for (const badValue of ["", "?0", "true", "\"?1\"", "1", "?2", "(?1)"]) {
-  let frameWindow;
   promise_test(async () => {
-    frameWindow = await insertIframe("{{hosts[][www]}}", badValue);
+    await insertIframe("{{hosts[][www]}}", badValue);
   }, `"${badValue}": frame insertion`);
 
   // Since the header values are bad there should be no isolation
-
-  promise_test(async () => {
-    const whatHappened = await sendWasmModule(frameWindow);
-
-    assert_equals(whatHappened, "WebAssembly.Module message received");
-  }, `"${badValue}": message event must occur for`);
-
-  promise_test(async () => {
-    await setBothDocumentDomains(frameWindow);
-
-    // Must not throw
-    frameWindow.document;
-  }, `"${badValue}": setting document.domain must give sync access`);
+  testSameAgentCluster([self, frameIndex], `"${badValue}"`);
+  ++frameIndex;
 }
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child-yes-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child-yes-same.sub.https.html
@@ -2,31 +2,18 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, child is isolated, child is same-origin to the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testSameAgentCluster } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][]}}", "?1");
+  await insertIframe("{{hosts[][]}}", "?1");
 });
 
 // Since they're same-origin, and the parent loaded without isolation, the
 // child's request for isolation gets ignored, and both end up site-keyed.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "message event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  // Must not throw
-  frameWindow.document;
-}, "setting document.domain must give sync access");
+testSameAgentCluster([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child-yes-subdomain.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child-yes-subdomain.sub.https.html
@@ -2,33 +2,19 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, child is isolated, child is a subdomain of the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testDifferentAgentClusters } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}", "?1");
 });
 
 // Since they're different-origin, the child's isolation request is respected,
 // so the parent ends up in the site-keyed agent cluster and the child in the
 // origin-keyed one.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "messageerror");
-}, "messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow.document;
-  });
-}, "setting document.domain should no-op instead of giving sync access");
+testDifferentAgentClusters([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child-yes-with-params-subdomain.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child-yes-with-params-subdomain.sub.https.html
@@ -2,33 +2,19 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, child is isolated using parameters on its structured header, child is a subdomain of the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testDifferentAgentClusters } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][www]}}", "?1;param1;param2=value2");
+  await insertIframe("{{hosts[][www]}}", "?1;param1;param2=value2");
 });
 
 // Since they're different-origin, the child's isolation request is respected,
 // so the parent ends up in the site-keyed agent cluster and the child in the
 // origin-keyed one.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "messageerror");
-}, "messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow.document;
-  });
-}, "setting document.domain should no-op instead of giving sync access");
+testDifferentAgentClusters([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child1-no-child2-yes-children-different.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child1-no-child2-yes-children-different.sub.https.html
@@ -2,76 +2,32 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, subdomain child 1 is not isolated, different-subdomain child 2 is isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
   // Order of loading should not matter, but we make it sequential to ensure the
   // tests are deterministic.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frameWindow2 = await insertIframe("{{hosts[][www1]}}", "?1");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www1]}}", "?1");
 });
 
 
 // Since everybody is different-origin, everyone's requests/non-requests get
 // respected.
 //
 // So, the parent and child 1 end up in the site-keyed agent cluster, and child
 // 2 ends up in its own origin-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "Parent to child1: message event must occur");
-
-promise_test(async () => {
-  // Must not throw
-  frameWindow1.document;
-}, "Parent to child1: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "child1 to child2: messageerror event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "SecurityError");
-}, "child1 to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "messageerror");
-}, "child2 to child1: messageerror event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "SecurityError");
-}, "child2 to child1: setting document.domain must not give sync access");
+testSameAgentCluster([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testDifferentAgentClusters([0, 1], "child1 to child2");
+testDifferentAgentClusters([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child1-no-child2-yes-children-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child1-no-child2-yes-children-same.sub.https.html
@@ -2,74 +2,27 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, subdomain child 1 is not isolated, same-subdomain child 2 is isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import { insertIframe, testSameAgentCluster } from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
-  // Must be sequential, not parallel: frameWindow1 must load first.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frameWindow2 = await insertIframe("{{hosts[][www]}}", "?1");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  // Must be sequential, not parallel: the non-isolated frame must load first.
+  await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www]}}", "?1");
 });
 
 
 // Since they're different-origin, the parent's isolation non-request is
-// respected, as is frameWindow1's non-request. frameWindow2 requests isolation
-// but is ignored, since frameWindow1 is in the same browsing context group.
+// respected, as is child 1's non-request. child 2 requests isolation
+// but is ignored, since child 1 is in the same browsing context group.
 //
 // So, everyone ends up in the site-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "Parent to child1: message event must occur");
-
-promise_test(async () => {
-  // Must not throw
-  frameWindow1.document;
-}, "Parent to child1: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "Parent to child2: message event must occur");
-
-promise_test(async () => {
-  // Must not throw
-  frameWindow2.document;
-}, "Parent to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testSameAgentCluster([self, 0], "Parent to child1");
+testSameAgentCluster([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-no-child1-yes-child2-no-children-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-no-child1-yes-child2-no-children-same.sub.https.html
@@ -2,77 +2,32 @@
 <meta charset="utf-8">
 <title>Parent is not isolated, subdomain child 1 is isolated, same-subdomain child 2 is not isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
-  // Must be sequential, not parallel: frameWindow1 must load first.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}", "?1");
-  frameWindow2 = await insertIframe("{{hosts[][www]}}");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  // Must be sequential, not parallel: the isolated frame must load first.
+  await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}");
 });
 
 
 // Since they're different-origin, the parent's isolation non-request is
-// respected, as is frameWindow1's request. frameWindow2's non-request is
-// ignored, since frameWindow1 is in the same browsing context group.
+// respected, as is child 1's request. child 2's non-request is
+// ignored, since child 1 is in the same browsing context group.
 //
 // So, the parent ends up in the site-keyed agent cluster, and both children end
 // up in an origin-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child-no-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child-no-same.sub.https.html
@@ -2,31 +2,18 @@
 <meta charset="utf-8">
 <title>Parent is isolated, child is not isolated, child is same-origin to the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testSameAgentCluster } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][]}}");
+  await insertIframe("{{hosts[][]}}");
 });
 
 // Since they're same-origin, and the parent loaded with isolation, the
 // child's non-request for isolation gets ignored, and both end up origin-keyed.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "message event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  // Must not throw
-  frameWindow.document;
-}, "setting document.domain must give sync access");
+testSameAgentCluster([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child-no-subdomain.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child-no-subdomain.sub.https.html
@@ -2,33 +2,19 @@
 <meta charset="utf-8">
 <title>Parent is isolated, child is not isolated, child is a subdomain of the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testDifferentAgentClusters } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www]}}");
 });
 
 // Since they're different-origin, the parent's isolation request is respected,
 // as is the child's non-request. So the parent ends up in the origin-keyed
 // agent cluster and the child ends up in the site-keyed one.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "messageerror");
-}, "messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow.document;
-  });
-}, "setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child-yes-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child-yes-same.sub.https.html
@@ -2,31 +2,18 @@
 <meta charset="utf-8">
 <title>Parent is isolated, child is not isolated, child is same-origin to the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testSameAgentCluster } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][]}}", "?1");
+  await insertIframe("{{hosts[][]}}", "?1");
 });
 
 // Both request isolation, and they're same-origin, so they both end up in the
 // same origin-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "message event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  // Must not throw
-  frameWindow.document;
-}, "setting document.domain must give sync access");
+testSameAgentCluster([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child-yes-subdomain.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child-yes-subdomain.sub.https.html
@@ -2,33 +2,19 @@
 <meta charset="utf-8">
 <title>Parent is isolated, child is not isolated, child is a subdomain of the parent</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains } from "./resources/helpers.mjs";
+import { insertIframe, testDifferentAgentClusters } from "./resources/helpers.mjs";
 
-let frameWindow;
 promise_setup(async () => {
-  frameWindow = await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}", "?1");
 });
 
 // Both request isolation, so the parent ends up in one origin-keyed agent
 // cluster (the base domain's origin), and the child ends up in a different
 // origin-keyed agent cluster (the www subdomain's origin).
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow);
-
-  assert_equals(whatHappened, "messageerror");
-}, "messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow.document;
-  });
-}, "setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 0]);
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-no-children-different.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-no-children-different.sub.https.html
@@ -2,77 +2,32 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is not isolated, different-subdomain child 2 is not isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
   // Order of loading should not matter, but we make it sequential to ensure the
   // tests are deterministic.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frameWindow2 = await insertIframe("{{hosts[][www1]}}");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www1]}}");
 });
 
 
 // Since everybody is different-origin, everyone's requests/non-requests get
 // respected.
 //
 // So, the parent ends up in its origin-keyed agent cluster, and child 1 and
 // child 2 both end up in the site-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-no-children-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-no-children-same.sub.https.html
@@ -2,77 +2,32 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is not isolated, same-subdomain child 2 is not isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
   // Order of loading should not matter, but we make it sequential to ensure the
   // tests are deterministic.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frameWindow2 = await insertIframe("{{hosts[][www]}}");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www]}}");
 });
 
 
 // Since everybody is different-origin, everyone's requests/non-requests get
 // respected.
 //
 // So, the parent ends up in its origin-keyed agent cluster, and child 1 and
 // child 2 both end up in the site-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-yes-children-different.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-yes-children-different.sub.https.html
@@ -2,78 +2,33 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is not isolated, different-subdomain child 2 is isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
   // Order of loading should not matter, but we make it sequential to ensure the
   // tests are deterministic.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frameWindow2 = await insertIframe("{{hosts[][www1]}}", "?1");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www1]}}", "?1");
 });
 
 
 // Since everybody is different-origin, everyone's requests/non-requests get
 // respected.
 //
 // So, the parent ends up in its origin-keyed agent cluster, child 1 ends up in
 // the site-keyed agent cluster, and child 2 ends up in a different origin-keyed
 // agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "child1 to child2: messageerror event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "SecurityError");
-}, "child1 to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "messageerror");
-}, "child2 to child1: messageerror event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "SecurityError");
-}, "child2 to child1: setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testDifferentAgentClusters([0, 1], "child1 to child2");
+testDifferentAgentClusters([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-yes-children-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-no-child2-yes-children-same.sub.https.html
@@ -2,77 +2,32 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is not isolated, same-subdomain child 2 is isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
-  // Must be sequential, not parallel: frameWindow1 must load first.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frameWindow2 = await insertIframe("{{hosts[][www]}}", "?1");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  // Must be sequential, not parallel: the non-isolaed frame must load first.
+  await insertIframe("{{hosts[][www]}}");
+  await insertIframe("{{hosts[][www]}}", "?1");
 });
 
 
 // Since they're different-origin, the parent's isolation request is respected,
-// as is frameWindow1's non-request. frameWindow2 requests isolation but is
-// ignored, since frameWindow1 is in the same browsing context group.
+// as is child 1's non-request. child 2 requests isolation but is
+// ignored, since child 1 is in the same browsing context group.
 //
 // So, the parent ends up in the origin-keyed agent cluster, and both children
 // ends up in the site-keyed one.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-no-children-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-no-children-same.sub.https.html
@@ -2,77 +2,32 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is isolated, same-subdomain child 2 is not isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
-  // Must be sequential, not parallel: frameWindow1 must load first.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}", "?1");
-  frameWindow2 = await insertIframe("{{hosts[][www]}}");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  // Must be sequential, not parallel: the isolated frame must load first.
+  await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}");
 });
 
 
 // Since they're different-origin, the parent's isolation request is respected,
-// as is frameWindow1's request. frameWindow2's non-request is ignored, since
-// frameWindow1 is in the same browsing context group.
+// as is child 1's request. child 2's non-request is ignored, since
+// child 1 is in the same browsing context group.
 //
 // So, the parent ends up in the origin-keyed agent cluster, and both children
 // ends up in a different origin-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-yes-children-different.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-yes-children-different.sub.https.html
@@ -2,78 +2,33 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is isolated, different-subdomain child 2 is isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
   // Order of loading should not matter, but we make it sequential to ensure the
   // tests are deterministic.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}", "?1");
-  frameWindow2 = await insertIframe("{{hosts[][www1]}}", "?1");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www1]}}", "?1");
 });
 
 
 // Since everybody is different-origin, everyone's requests get
 // respected.
 //
 // So, the parent ends up in its origin-keyed agent cluster, child 1 ends up in
 // a second origin-keyed agent cluster, and child 2 ends up in a third
 // origin-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "child1 to child2: messageerror event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "SecurityError");
-}, "child1 to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "messageerror");
-}, "child2 to child1: messageerror event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "SecurityError");
-}, "child2 to child1: setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testDifferentAgentClusters([0, 1], "child1 to child2");
+testDifferentAgentClusters([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-yes-children-same.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/parent-yes-child1-yes-child2-yes-children-same.sub.https.html
@@ -2,77 +2,33 @@
 <meta charset="utf-8">
 <title>Parent is isolated, subdomain child 1 is isolated, same-subdomain child 2 is not isolated</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, sendWasmModule, setBothDocumentDomains,
-         sendWasmModuleBetween, accessDocumentBetween } from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frameWindow1, frameWindow2;
 promise_setup(async () => {
-  // Must be sequential, not parallel: frameWindow1 must load first.
-  frameWindow1 = await insertIframe("{{hosts[][www]}}", "?1");
-  frameWindow2 = await insertIframe("{{hosts[][www]}}", "?1");
-
-  await setBothDocumentDomains(frameWindow1);
-  await setBothDocumentDomains(frameWindow2);
+  // Order of loading should not matter, but we make it sequential to ensure the
+  // tests are deterministic.
+  await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www]}}", "?1");
 });
 
 
 // Since they're different-origin, the parent's isolation request is respected,
-// as is frameWindow1's request. frameWindow2's request is redundant, since
-// frameWindow1 is in the same browsing context group.
+// as is child 1's request. child 2's request is redundant, since
+// child 1 is in the same browsing context group.
 //
 // So, the parent ends up in the origin-keyed agent cluster, and both children
 // ends up in a different origin-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child1: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Parent to child1: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child1 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow1, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child1 to child2: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child1: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child1: setting document.domain must give sync access");
+testDifferentAgentClusters([self, 0], "Parent to child1");
+testDifferentAgentClusters([self, 1], "Parent to child2");
+testSameAgentCluster([0, 1], "child1 to child2");
+testSameAgentCluster([1, 0], "child2 to child1");
 </script>
--- a/testing/web-platform/tests/origin-isolation/removing-iframes.sub.https.html
+++ b/testing/web-platform/tests/origin-isolation/removing-iframes.sub.https.html
@@ -2,98 +2,39 @@
 <meta charset="utf-8">
 <title>Parent is isolated, child1 is not isolated, child1 navigates to a different site, child2 gets inserted and is isolated, child1 navigates back</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 
 <div id="log"></div>
 
 <script type="module">
-import { insertIframe, navigateIframe, waitForIframe, sendWasmModule,
-         setBothDocumentDomains, sendWasmModuleBetween, accessDocumentBetween }
-       from "./resources/helpers.mjs";
+import {
+  insertIframe,
+  testSameAgentCluster,
+  testDifferentAgentClusters,
+} from "./resources/helpers.mjs";
 
-let frame1, frameWindow1, frameWindow2, frameWindow3;
+let frame1;
 promise_setup(async () => {
-  frameWindow1 = await insertIframe("{{hosts[][www]}}");
-  frame1 = document.querySelector("iframe");
+  frame1 = await insertIframe("{{hosts[][www]}}");
 });
 
 // Since they're different-origin, the parent's isolation request is respected,
 // as is the child's non-request. So the parent ends up in the origin-keyed
 // agent cluster and the child ends up in the site-keyed one.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow1);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Before: messageerror event must occur");
-
-promise_test(async () => {
-  await setBothDocumentDomains(frameWindow1);
-
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow1.document;
-  });
-}, "Before: setting document.domain must not give sync access");
+testDifferentAgentClusters([self, 0], "Before");
 
 promise_test(async () => {
   frame1.remove();
 
-  frameWindow2 = await insertIframe("{{hosts[][www]}}", "?1");
-  frameWindow3 = await insertIframe("{{hosts[][www1]}}");
-
-  await setBothDocumentDomains(frameWindow2);
-  await setBothDocumentDomains(frameWindow3);
+  await insertIframe("{{hosts[][www]}}", "?1");
+  await insertIframe("{{hosts[][www1]}}");
 }, "Remove the iframe and insert new ones");
 
 // Because of the historical presence of a non-isolated {{hosts[][www]}} iframe,
-// the origin isolation request for frameWindow2 will be ignored. So,
-// frameWindow2 and frameWindow3 both end up in the site-keyed agent cluster.
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow2);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child2: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow2.document;
-  });
-}, "Parent to child2: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModule(frameWindow3);
-
-  assert_equals(whatHappened, "messageerror");
-}, "Parent to child3: messageerror event must occur");
-
-promise_test(async () => {
-  assert_throws_dom("SecurityError", DOMException, () => {
-    frameWindow3.document;
-  });
-}, "Parent to child3: setting document.domain must not give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow2, 1);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child2 to child3: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow2, 1);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child2 to child3: setting document.domain must give sync access");
-
-promise_test(async () => {
-  const whatHappened = await sendWasmModuleBetween(frameWindow3, 0);
-
-  assert_equals(whatHappened, "WebAssembly.Module message received");
-}, "child3 to child2: message event must occur");
-
-promise_test(async () => {
-  const whatHappened = await accessDocumentBetween(frameWindow3, 0);
-
-  assert_equals(whatHappened, "accessed document successfully");
-}, "child3 to child2: setting document.domain must give sync access");
+// the origin isolation request for child 2 will be ignored. So,
+// child 2 and child 3 both end up in the site-keyed agent cluster.
+testDifferentAgentClusters([self, 0], "Parent to child2");
+testDifferentAgentClusters([self, 1], "Parent to child3");
+testSameAgentCluster([0, 1], "child2 to child3");
+testSameAgentCluster([1, 0], "child3 to child2");
 </script>
--- a/testing/web-platform/tests/origin-isolation/resources/helpers.mjs
+++ b/testing/web-platform/tests/origin-isolation/resources/helpers.mjs
@@ -1,86 +1,236 @@
-export function insertIframe(hostname, header) {
+/**
+ * Inserts an iframe usable for origin isolation testing, and returns a promise
+ * fulfilled when the iframe is loaded and its document.domain is set. The
+ * iframe will point to the send-origin-isolation-header.py file, on the
+ * designated hostname
+ * @param {string} hostname - The hostname used to calculate the iframe's src=""
+ * @param {string=} header - The value of the Origin-Isolation header that the
+ *   iframe will set. Omit this to set no header.
+ * @returns {HTMLIFrameElement} The created iframe element
+ */
+export async function insertIframe(hostname, header) {
   const iframe = document.createElement("iframe");
   const navigatePromise = navigateIframe(iframe, hostname, header);
   document.body.append(iframe);
-  return navigatePromise;
+  await navigatePromise;
+  await setBothDocumentDomains(iframe.contentWindow);
+  return iframe;
 }
 
+/**
+ * Navigates an iframe to a page for origin isolation testing, similar to
+ * insertIframe but operating on an existing iframe.
+ * @param {HTMLIFrameElement} iframeEl - The <iframe> element to navigate
+ * @param {string} hostname - The hostname used to calculate the iframe's new
+ *   src=""
+ * @param {string=} header - The value of the Origin-Isolation header that the
+ *   newly-navigated-to page will set. Omit this to set no header.
+ * @returns {Promise} a promise fulfilled when the load event fires, or rejected
+ *   if the error event fires
+ */
 export function navigateIframe(iframeEl, hostname, header) {
-  const url = getURL(hostname, header);
+  const url = getIframeURL(hostname, header);
 
   const waitPromise = waitForIframe(iframeEl, url);
   iframeEl.src = url;
   return waitPromise;
 }
 
+/**
+ * Returns a promise that is fulfilled when an iframe's load event fires, or
+ * rejected when its error event fires.
+ * @param {HTMLIFrameElement} iframeEl - The <iframe> element to wait on
+ * @param {string} destinationForErrorMessage - A string used in the promise
+ *   rejection error message, if the error event fires
+ * @returns {Promise} a promise fulfilled when the load event fires, or rejected
+ *   if the error event fires
+ */
 export function waitForIframe(iframeEl, destinationForErrorMessage) {
   return new Promise((resolve, reject) => {
-    iframeEl.addEventListener("load", () => resolve(iframeEl.contentWindow));
+    iframeEl.addEventListener("load", () => resolve());
     iframeEl.addEventListener(
       "error",
       () => reject(new Error(`Could not navigate to ${destinationForErrorMessage}`))
     );
   });
 }
 
-function getURL(hostname, header) {
+/**
+ * Expands into a pair of promise_test() calls to ensure that two Windows are in
+ * the same agent cluster, by checking both that we can send a
+ * WebAssembly.Module, and that we can synchronously access the DOM.
+ * @param {Array} testFrames - An array of either the form [self, frameIndex] or
+ *   [frameIndex1, frameIndex2], indicating the two Windows under test. E.g.
+ *   [self, 0] or [0, 1].
+ * @param {string=} testLabelPrefix - A prefix used in the test names. This can
+ *   be omitted if testSameAgentCluster is only used once in a test file.
+ */
+export function testSameAgentCluster(testFrames, testLabelPrefix) {
+  const prefix = testLabelPrefix === undefined ? "" : `${testLabelPrefix}: `;
+
+  if (testFrames[0] === self) {
+    // Between parent and a child at the index given by testFrames[1]
+
+    promise_test(async () => {
+      const frameWindow = frames[testFrames[1]];
+      const whatHappened = await sendWasmModule(frameWindow);
+
+      assert_equals(whatHappened, "WebAssembly.Module message received");
+    }, `${prefix}message event must occur`);
+
+    promise_test(async () => {
+      const frameWindow = frames[testFrames[1]];
+
+      // Must not throw
+      frameWindow.document;
+    }, `${prefix}setting document.domain must give sync access`);
+  } else {
+    // Between the two children at the index given by testFrames[0] and
+    // testFrames[1]
+
+    promise_test(async () => {
+      const whatHappened = await sendWasmModuleBetween(testFrames);
+
+      assert_equals(whatHappened, "WebAssembly.Module message received");
+    }, `${prefix}message event must occur`);
+
+    promise_test(async () => {
+      const whatHappened = await accessDocumentBetween(testFrames);
+
+      assert_equals(whatHappened, "accessed document successfully");
+    }, `${prefix}setting document.domain must give sync access`);
+  }
+}
+
+/**
+ * Expands into a pair of promise_test() calls to ensure that two Windows are in
+ * different agent clusters, by checking both that we cannot send a
+ * WebAssembly.Module, and that we cannot synchronously access the DOM.
+ * @param {Array} testFrames - An array of either the form [self, frameIndex] or
+ *   [frameIndex1, frameIndex2], indicating the two Windows under test. E.g.
+ *   [self, 0] or [0, 1].
+ * @param {string=} testLabelPrefix - A prefix used in the test names. This can
+ *   be omitted if testDifferentAgentClusters is only used once in a test file.
+ */
+export function testDifferentAgentClusters(testFrames, testLabelPrefix) {
+  const prefix = testLabelPrefix === undefined ? "" : `${testLabelPrefix}: `;
+
+  if (testFrames[0] === self) {
+    // Between parent and a child at the index given by testFrames[1]
+
+    promise_test(async () => {
+      const frameWindow = frames[testFrames[1]];
+      const whatHappened = await sendWasmModule(frameWindow);
+
+      assert_equals(whatHappened, "messageerror");
+    }, `${prefix}messageerror event must occur`);
+
+    promise_test(async () => {
+      const frameWindow = frames[testFrames[1]];
+
+      assert_throws_dom("SecurityError", DOMException, () => {
+        frameWindow.document;
+      });
+    }, `${prefix}setting document.domain must not give sync access`);
+  } else {
+    // Between the two children at the index given by testFrames[0] and
+    // testFrames[1]
+
+    promise_test(async () => {
+      const whatHappened = await sendWasmModuleBetween(testFrames);
+
+      assert_equals(whatHappened, "messageerror");
+    }, `${prefix}messageerror event must occur`);
+
+    promise_test(async () => {
+      const whatHappened = await accessDocumentBetween(testFrames);
+
+      assert_equals(whatHappened, "SecurityError");
+    }, `${prefix}setting document.domain must not give sync access`);
+  }
+}
+
+/**
+ * Sends a WebAssembly.Module instance to the given Window, and waits for it to
+ * send back a message indicating whether it got the module or got a
+ * messageerror event. (This relies on the given Window being derived from
+ * insertIframe or navigateIframe.)
+ * @param {Window} frameWindow - The destination Window
+ * @returns {Promise} A promise which will be fulfilled with either
+ *   "WebAssembly.Module message received" or "messageerror"
+ */
+export async function sendWasmModule(frameWindow) {
+  // This function is coupled to ./send-origin-isolation-header.py, which ensures
+  // that sending such a message will result in a message back.
+  frameWindow.postMessage(await createWasmModule(), "*");
+  return waitForMessage(frameWindow);
+}
+
+/**
+ * Sets document.domain (to itself) for both the current Window and the given
+ * Window. The latter relies on the given Window being derived from insertIframe
+ * or navigateIframe.
+ * @param frameWindow - The other Window whose document.domain is to be set
+ * @returns {Promise} A promise which will be fulfilled after both
+ *   document.domains are set
+ */
+export async function setBothDocumentDomains(frameWindow) {
+  // By setting both this page's document.domain and the iframe's
+  // document.domain to the same value, we ensure that they can synchronously
+  // access each other, unless they are origin-isolated.
+  // NOTE: document.domain being unset is different than it being set to its
+  // current value. It is a terrible API.
+  document.domain = document.domain;
+
+  // This function is coupled to ./send-origin-isolation-header.py, which ensures
+  // that sending such a message will result in a message back.
+  frameWindow.postMessage({ command: "set document.domain", newDocumentDomain: document.domain }, "*");
+  const whatHappened = await waitForMessage(frameWindow);
+  assert_equals(whatHappened, "document.domain is set");
+}
+
+function getIframeURL(hostname, header) {
   const url = new URL("send-origin-isolation-header.py", import.meta.url);
   url.hostname = hostname;
   if (header !== undefined) {
     url.searchParams.set("header", header);
   }
 
   return url.href;
 }
 
-// This function is coupled to ./send-origin-isolation-header.py, which ensures
-// that sending such a message will result in a message back.
-export async function sendWasmModule(frameWindow) {
-  frameWindow.postMessage(await createWasmModule(), "*");
-  return waitForMessage(frameWindow);
-}
+async function sendWasmModuleBetween(testFrames) {
+  const sourceFrame = frames[testFrames[0]];
+  const indexIntoParentFrameOfDestination = testFrames[1];
 
-export async function sendWasmModuleBetween(frameWindow, indexIntoParentFrameOfDestination) {
-  frameWindow.postMessage({ command: "send WASM module", indexIntoParentFrameOfDestination }, "*");
-  return waitForMessage(frameWindow);
+  sourceFrame.postMessage({ command: "send WASM module", indexIntoParentFrameOfDestination }, "*");
+  return waitForMessage(sourceFrame);
 }
 
-export async function accessDocumentBetween(frameWindow, indexIntoParentFrameOfDestination) {
-  frameWindow.postMessage({ command: "access document", indexIntoParentFrameOfDestination }, "*");
-  return waitForMessage(frameWindow);
-}
+async function accessDocumentBetween(testFrames) {
+  const sourceFrame = frames[testFrames[0]];
+  const indexIntoParentFrameOfDestination = testFrames[1];
 
-// This function is coupled to ./send-origin-isolation-header.py, which ensures
-// that sending such a message will result in a message back.
-export async function setBothDocumentDomains(frameWindow) {
-  // By setting both this page's document.domain and the iframe's document.domain to the same
-  // value, we ensure that they can synchronously access each other, unless they are
-  // origin-isolated.
-  // NOTE: document.domain being unset is different than it being set to its current value.
-  // It is a terrible API.
-  document.domain = document.domain;
-
-  frameWindow.postMessage({ command: "set document.domain", newDocumentDomain: document.domain }, "*");
-  const whatHappened = await waitForMessage(frameWindow);
-  assert_equals(whatHappened, "document.domain is set");
+  sourceFrame.postMessage({ command: "access document", indexIntoParentFrameOfDestination }, "*");
+  return waitForMessage(sourceFrame);
 }
 
 function waitForMessage(expectedSource) {
   return new Promise(resolve => {
     const handler = e => {
       if (e.source === expectedSource) {
         resolve(e.data);
         window.removeEventListener("message", handler);
       }
     };
     window.addEventListener("message", handler);
   });
 }
 
-// Any WebAssembly.Module will work fine for our tests; we just want to find out if it gives
-// message or messageerror. So, we reuse one from the /wasm/ tests.
+// Any WebAssembly.Module will work fine for our tests; we just want to find out
+// if it gives message or messageerror. So, we reuse one from the /wasm/ tests.
 async function createWasmModule() {
   const response = await fetch("/wasm/serialization/module/resources/incrementer.wasm");
   const ab = await response.arrayBuffer();
   return WebAssembly.compile(ab);
 }