summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/main.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/content/main.js b/content/main.js
index cc7692a..6478ea0 100644
--- a/content/main.js
+++ b/content/main.js
@@ -304,6 +304,27 @@ http-equiv="Content-Security-Policy" content="${make_csp_rule(policy)}"\
start_data_urls_sanitizing(doc);
}
+async function disable_service_workers()
+{
+ if (!navigator.serviceWorker)
+ return;
+
+ const registrations = await navigator.serviceWorker.getRegistrations();
+ if (registrations.length === 0)
+ return;
+
+ console.warn("Service Workers detected on this page! Unregistering and reloading");
+
+ try {
+ await Promise.all(registrations.map(r => r.unregister()));
+ } finally {
+ location.reload();
+ }
+
+ /* Never actually return! */
+ return new Promise(() => 0);
+}
+
if (!is_privileged_url(document.URL)) {
let policy_received_callback = () => undefined;
let policy;
@@ -343,6 +364,7 @@ if (!is_privileged_url(document.URL)) {
const doc_ready = Promise.all([
policy.allow ? Promise.resolve() : sanitize_document(document, policy),
+ policy.allow ? Promise.resolve() : disable_service_workers(),
wait_loaded(document)
]);