summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackademix2020-01-07 21:43:38 +0100
committerhackademix2020-01-07 21:43:38 +0100
commitce6e5a54a00322332188eddc2a358288db7d20c3 (patch)
treeae2aaae7255f0f0237bb9b595df1c18c022796c7
parent029f585b2e954018d28117c3f74672d8be103419 (diff)
downloadnoscript-ce6e5a54a00322332188eddc2a358288db7d20c3.tar.gz
noscript-ce6e5a54a00322332188eddc2a358288db7d20c3.tar.xz
noscript-ce6e5a54a00322332188eddc2a358288db7d20c3.zip
Cross-browser request properties normalization.
-rw-r--r--src/bg/RequestGuard.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js
index e57fbba..1ff4269 100644
--- a/src/bg/RequestGuard.js
+++ b/src/bg/RequestGuard.js
@@ -263,6 +263,15 @@ var RequestGuard = (() => {
return redirected;
}
+ let normalizeRequest = UA.isMozilla ? () => {} : request => {
+ if ("initiator" in request && !("originUrl" in request)) {
+ request.originUrl = request.initiator;
+ if (request.type !== "main_frame" && !("documentUrl" in request)) {
+ request.documentUrl = request.initiator;
+ }
+ }
+ };
+
function intersectCapabilities(perms, request) {
let {frameId, frameAncestors, tabId} = request;
if (frameId !== 0 && ns.sync.cascadeRestrictions) {
@@ -282,6 +291,7 @@ var RequestGuard = (() => {
const ABORT = {cancel: true}, ALLOW = {};
const listeners = {
onBeforeRequest(request) {
+ normalizeRequest(request);
try {
let redirected = initPendingRequest(request);
let {policy} = ns;
@@ -328,6 +338,7 @@ var RequestGuard = (() => {
return ALLOW;
},
onHeadersReceived(request) {
+ normalizeRequest(request);
let result = ALLOW;
let promises = [];
// called for main_frame, sub_frame and object
@@ -386,6 +397,7 @@ var RequestGuard = (() => {
return result;
},
onResponseStarted(request) {
+ normalizeRequest(request);
debug("onResponseStarted", request);
let {requestId, url, tabId, frameId, type} = request;
if (type === "main_frame") {