summaryrefslogtreecommitdiffstats
path: root/dom/serviceworkers/test/page_post_controlled.html
blob: 27694c0027b6fb6b8a7807828e4f5eb989473ada (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
<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
  window.parent.postMessage({
    controlled: !!navigator.serviceWorker.controller
  }, "*");

  addEventListener("message", e => {
    if (e.data == "create nested iframe") {
      const iframe = document.createElement('iframe');
      document.body.appendChild(iframe);
      iframe.src = location.href;
    } else {
      window.parent.postMessage(e.data, "*");
    }
  });
</script>
</body>
</html>