summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/request/destination/resources/fetch-destination-worker-iframe.js
blob: 76345839eadfeb75d07134919af80983b0e61531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
self.addEventListener('fetch', function(event) {
    if (event.request.url.includes('dummy')) {
        event.waitUntil(async function() {
            let destination = new URL(event.request.url).searchParams.get("dest");
            let clients = await self.clients.matchAll({"includeUncontrolled": true});
            clients.forEach(function(client) {
                if (client.url.includes("fetch-destination-iframe")) {
                    if (event.request.destination == destination) {
                        client.postMessage("PASS");
                    } else {
                        client.postMessage("FAIL");
                    }
                }
            })
        }());
    }
    event.respondWith(fetch(event.request));
});