summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/fetch/connection-pool/resources/network-partition-about-blank-checker.html
blob: 7a8b61323752d2be0e76f70ff3524986ad9f68eb (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
31
32
33
34
35
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>about:blank Network Partition Checker</title>
  <meta name="help" href="https://fetch.spec.whatwg.org/#network-partition-keys">
  <meta name="timeout" content="normal">
</head>
<body>
<script>
  async function fetch_and_reply() {
    // Load about:blank in a new tab, and inject the network partition checking code into it.
    var win;
    try {
      win = window.open();
      var url = 'SUBRESOURCE_PREFIX:&dispatch=fetch_file&path=fetch/connection-pool/resources/network-partition-checker.html&sandbox=true';
      var response = await fetch(url, {credentials: 'omit', mode: 'cors'});
      win.document.write(await response.text());
    } catch (e) {
      win.close();
      window.parent.postMessage({result: 'error', details: e.message}, '*');
      return;
    }

    // Listen for first message from the new window and pass it back to the parent.
    function message_listener(event) {
      window.parent.postMessage(event.data, '*');
      win.close();
    }
    window.addEventListener('message', message_listener, {once: true});
  }
  fetch_and_reply();
</script>
</body>
</html>