summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bg/RequestGuard.js13
-rw-r--r--src/content/content.js14
2 files changed, 25 insertions, 2 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js
index 1ff4269..2f5a615 100644
--- a/src/bg/RequestGuard.js
+++ b/src/bg/RequestGuard.js
@@ -228,7 +228,18 @@ var RequestGuard = (() => {
key: Policy.requestKey(url, type, documentUrl || "", /^(media|object|frame)$/.test(type)),
type, url, documentUrl, originUrl
};
- if (tabId < 0) return;
+ if (tabId < 0) {
+ if (type === "script" && url.startsWith("https://") && documentUrl && documentUrl.startsWith("https://")) {
+ // service worker / importScripts()?
+ let payload = {request, allowed, policyType, serviceWorker: Sites.origin(documentUrl)};
+ let recipient = {frameId: 0};
+ for (let tab of await browser.tabs.query({url: ["http://*/*", "https://*/*"]})) {
+ recipient.tabId = tab.id;
+ Messages.send("seen", payload, recipient);
+ }
+ }
+ return;
+ }
if (pending) request.initialUrl = pending.initialUrl;
if (type !== "sub_frame") { // we couldn't deliver it to frameId, since it's generally not loaded yet
try {
diff --git a/src/content/content.js b/src/content/content.js
index 74e1d95..3862a58 100644
--- a/src/content/content.js
+++ b/src/content/content.js
@@ -32,7 +32,19 @@ var seen = {
Messages.addHandler({
seen(event) {
- let {allowed, policyType, request, ownFrame} = event;
+ let {allowed, policyType, request, ownFrame, serviceWorker} = event;
+ if (serviceWorker) {
+ for (let e of seen.list) {
+ let {request} = e;
+ if (e.serviceWorker === serviceWorker ||
+ (request.type === "main_frame" || request.type === "sub_frame") &&
+ new URL(request.url).origin === serviceWorker) {
+ seen.record(event);
+ break;
+ }
+ }
+ return;
+ }
if (window.top === window) {
seen.record(event);
}