summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/partitioned-service-worker-nested-iframe-parent.html
blob: f748e2f78d91d06f0c91ec40d031bf199bebbac6 (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
28
29
30
<!DOCTYPE html>
<title>Service Worker: Middle nested iframe for partitioned service workers</title>
<script src="./test-helpers.sub.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="./partitioned-utils.js"></script>

<body>
Middle of the nested iframes (3p ancestor or B in A1-B-A2).
<script>

async function onLoad() {
  // The innermost iframe will recieve a message from the
  // ServiceWorker and pass it to this iframe. We need to
  // then pass that message to the main frame to complete
  // the test.
  self.addEventListener('message', evt => {
      window.parent.postMessage(evt.data, '*');
  });

  // Embed the innermost iframe and set-up the service worker there.
  const innermost_iframe_url = new URL('./partitioned-service-worker-nested-iframe-child.html',
    get_host_info().HTTPS_ORIGIN + self.location.pathname);
  var frame = document.createElement('iframe');
  frame.src = innermost_iframe_url;
  document.body.appendChild(frame);
}

self.addEventListener('load', onLoad);
</script>
</body>