summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/browsing-topics/resources/fetch-topics-header-not-visible-in-service-worker-helper.tentative.https.html
blob: e9cb8144e0a17807863879fc140665af3e6767ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!doctype html>
<body>
  <script>
    var current_url = window.location.href;
    var fetch_url = current_url.substring(0, current_url.lastIndexOf("/")) + '/empty.html'

    navigator.serviceWorker.addEventListener('message', e => {
      if (e.data.fetchUrl == fetch_url) {
        if (e.data.topicsHeader === 'null') {
          window.opener.postMessage(
            {testResult: 'Service worker intercepted no topics header'}, '*');
        } else {
          window.opener.postMessage(
            {testResult: 'Service worker intercepted topics header'}, '*');
        }
      }
    });

    fetch(fetch_url, {browsingTopics: true});
  </script>
</body>