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

    navigator.serviceWorker.addEventListener('message', e => {
      if (e.data.topicsHeader === 'NO_TOPICS_HEADER') {
        window.opener.postMessage({testResult: 'Topics fetch initiated from service worker did not include the topics header'}, '*');
      } else {
        window.opener.postMessage({testResult: 'Topics fetch initiated from service worker included the topics header'}, '*');
      }
    });

    navigator.serviceWorker.controller.postMessage({
      fetchUrl: fetch_url
    });
  </script>
</body>