<!doctype html>
<meta charset=utf-8>
<title>postMessage: First-Party to First-Party, Cross-Partition</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
// Here's the set-up for this test:
// Step 1. (Site 1 Window) set up listener and open Site 2 Window.
// Step 2. (Site 2 Window) send "Site 2 Window" message to Site 1 Window.
// Step 3. (Site 1 Window) receive "Site 2 Window" message and exit.

async_test(t => {
  // Step 3
  const listener = t.step_func(e => {
    if (e.data === "Site 2 Window") {
      t.done();
    }
  });
  // Step 1
  window.addEventListener("message", listener);
  const site2Window = window.open("http://{{hosts[alt][]}}:{{ports[http][0]}}/html/browsers/windows/post-message/resources/first-party-to-first-party-cross-partition-window.html", "", "noopener=false");
  t.add_cleanup(() => site2Window.close());
}, "postMessage: First-Party to First-Party, Cross-Partition");
</script>
</body>
