Revision d658cadf
Added by koszko almost 2 years ago
content/main.js | ||
---|---|---|
304 | 304 |
start_data_urls_sanitizing(doc); |
305 | 305 |
} |
306 | 306 |
|
307 |
async function disable_service_workers() |
|
308 |
{ |
|
309 |
if (!navigator.serviceWorker) |
|
310 |
return; |
|
311 |
|
|
312 |
const registrations = await navigator.serviceWorker.getRegistrations(); |
|
313 |
if (registrations.length === 0) |
|
314 |
return; |
|
315 |
|
|
316 |
console.warn("Service Workers detected on this page! Unregistering and reloading"); |
|
317 |
|
|
318 |
try { |
|
319 |
await Promise.all(registrations.map(r => r.unregister())); |
|
320 |
} finally { |
|
321 |
location.reload(); |
|
322 |
} |
|
323 |
|
|
324 |
/* Never actually return! */ |
|
325 |
return new Promise(() => 0); |
|
326 |
} |
|
327 |
|
|
307 | 328 |
if (!is_privileged_url(document.URL)) { |
308 | 329 |
let policy_received_callback = () => undefined; |
309 | 330 |
let policy; |
... | ... | |
343 | 364 |
|
344 | 365 |
const doc_ready = Promise.all([ |
345 | 366 |
policy.allow ? Promise.resolve() : sanitize_document(document, policy), |
367 |
policy.allow ? Promise.resolve() : disable_service_workers(), |
|
346 | 368 |
wait_loaded(document) |
347 | 369 |
]); |
348 | 370 |
|
Also available in: Unified diff
disable service workers when scripts are blocked