summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/private-network-access/resources/fetcher.html
blob: 000a5cc25bb72b334d41ff05e7b8f22691f48f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<meta charset="utf-8">
<title>Fetcher</title>
<script>
  window.addEventListener("message", function (event) {
    const { url, options } = event.data;
    fetch(url, options)
        .then(async function(response) {
          const body = await response.text();
          const message = {
            ok: response.ok,
            type: response.type,
            body: body,
          };
          parent.postMessage(message, "*");
        })
        .catch(error => {
          parent.postMessage({ error: error.toString() }, "*");
        });
  });
</script>