blob: 79e21cb7614ad43d29797348fb40371ec2c01691 [file] [log] [blame]
onactivate = (e) => e.waitUntil(clients.claim());
async function doTest(event)
{
if (!event.data.startsWith("USERAGENT")) {
event.source.postMessage("FAIL: received unexpected message from client");
return;
}
if (event.data === "USERAGENT-NAVIGATOR") {
event.source.postMessage(navigator.userAgent);
return;
}
if (event.data === "USERAGENT-FETCH") {
var response = await fetch("/fetch/api/resources/inspect-headers.py?headers=User-Agent")
event.source.postMessage(response.headers.get("x-request-user-agent"));
return;
}
event.source.postMessage("FAIL: Unknown test");
}
self.addEventListener("message", doTest);