1
0
Fork 0
firefox/dom/serviceworkers/test/simple_fetch_worker.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

18 lines
379 B
JavaScript

// A simple worker script that forward intercepted url to the controlled window.
function responseMsg(msg) {
self.clients
.matchAll({
includeUncontrolled: true,
type: "window",
})
.then(clients => {
if (clients && clients.length) {
clients[0].postMessage(msg);
}
});
}
onfetch = function (e) {
responseMsg(e.request.url);
};