Handle exception when accessing navigator.serviceWorker on sandboxed frames.
This commit is contained in:
parent
64935445ff
commit
b5c7e971bb
|
@ -198,13 +198,16 @@ ns.on("capabilities", () => {
|
|||
}
|
||||
|
||||
if (!ns.canScript) {
|
||||
|
||||
if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
|
||||
(async () => {
|
||||
for (let r of await navigator.serviceWorker.getRegistrations()) {
|
||||
await r.unregister();
|
||||
}
|
||||
})();
|
||||
try {
|
||||
if ("serviceWorker" in navigator && navigator.serviceWorker.controller) {
|
||||
(async () => {
|
||||
for (let r of await navigator.serviceWorker.getRegistrations()) {
|
||||
await r.unregister();
|
||||
}
|
||||
})();
|
||||
}
|
||||
} catch (e) {
|
||||
debug(e);
|
||||
}
|
||||
onScriptDisabled();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* NoScript - a Firefox extension for whitelist driven safe JavaScript execution
|
||||
*
|
||||
* Copyright (C) 2005-2021 Giorgio Maone <https://maone.net>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function testBlob() {
|
||||
if ((location.origin === "https://noscript.net" || location.origin === "null" || location.href.startsWith("data:")) && top !== window ) {
|
||||
if (!testBlob.log) testBlob.log = "";
|
||||
testBlob.log += `${document.readyState} - ${document.URL} - Policy: ${JSON.stringify(ns.policy)}<br>`;
|
||||
if (document.body) {
|
||||
document.body.style.backgroundColor = "yellow";
|
||||
let log = document.body.appendChild(document.createElement("div"));
|
||||
log.textContent = testBlob.log;
|
||||
testBlog.log = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
testBlob();
|
||||
addEventListener("DOMContentLoaded", testBlob);
|
||||
|
||||
patchWorkers(() => { self.patched = true; console.log("NoScript-patched worker", self, location) }); // DEV_ONLY
|
Loading…
Reference in New Issue