summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/browsing-topics/resources/fetch-topics.js
blob: 71064a90c5b04ce6fa7f154da440c2dcc62a3602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
self.addEventListener('message', event => {
  if (event.data.fetchUrl) {
    clients.matchAll().then((clients) => {
      fetch(event.data.fetchUrl, {browsingTopics: true}).then((response) => {
        response.text().then((topics_header) => {
            // clients[0] is the most recently focused one
            clients[0].postMessage({
              topicsHeader: topics_header
            });
          });
      });
    });
  }
});