summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/windows/post-message/first-party-to-third-party-cross-partition-same-origin.sub.html
blob: 490b647fa4ac7e4e7b409336aa2f25ef0fec6c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!doctype html>
<meta charset=utf-8>
<title>postMessage: First-Party to Third-Party, Cross-Partition, Same-Origin</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) open Site 1 Frame.
// Step 3. (Site 1 Frame) send "Site 1 Frame" message to Site 1 Window.
// Step 4. (Site 1 Window) receive "Site 1 Frame" message and exit.

async_test(t => {
  // Step 4
  const listener = t.step_func(e => {
    if (e.data === "Site 1 Frame") {
      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-third-party-cross-partition-same-origin-window.sub.html", "", "noopener=false");
  t.add_cleanup(() => site2Window.close());
}, "postMessage: First-Party to Third-Party, Cross-Partition, Same-Origin");
</script>
</body>