blob: 964ddd40b29925e2f3896debd86cb1357cc56d69 [file] [log] [blame]
var postMessageFetchEventsOrder = [];
async function doTest(event)
{
if (event.data === "postMessageBeforeFetch") {
postMessageFetchEventsOrder.push("postMessageBeforeFetch");
return;
}
if (event.data === "postMessageAfterFetch") {
postMessageFetchEventsOrder.push("postMessageAfterFetch");
event.source.postMessage(postMessageFetchEventsOrder);
postMessageFetchEventsOrder = [];
}
}
self.addEventListener("message", doTest);
async function doFetch(event)
{
if (event.request.url.includes("betweenPostMessages"))
postMessageFetchEventsOrder.push("fetch");
event.respondWith(new Response("Intercepted"));
}
self.addEventListener("fetch", doFetch);