diff options
Diffstat (limited to 'toolkit/components/antitracking/StorageAccess.cpp')
-rw-r--r-- | toolkit/components/antitracking/StorageAccess.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/toolkit/components/antitracking/StorageAccess.cpp b/toolkit/components/antitracking/StorageAccess.cpp index c18efb2b4c..9a3b6f7e2c 100644 --- a/toolkit/components/antitracking/StorageAccess.cpp +++ b/toolkit/components/antitracking/StorageAccess.cpp @@ -766,11 +766,23 @@ bool ShouldAllowAccessFor(nsIChannel* aChannel, nsIURI* aURI, RefPtr<BrowsingContext> targetBC; rv = loadInfo->GetTargetBrowsingContext(getter_AddRefs(targetBC)); - if (!targetBC || NS_WARN_IF(NS_FAILED(rv))) { + if (NS_WARN_IF(NS_FAILED(rv))) { LOG(("Failed to get the channel's target browsing context")); return false; } + // If we cannot get the target browsing context from the loadInfo, the channel + // could be a fetch request from a worker scope. In this case, we get the + // target browsing context from the worker associated browsing context + // instead. + if (!targetBC) { + rv = loadInfo->GetWorkerAssociatedBrowsingContext(getter_AddRefs(targetBC)); + } + if (!targetBC || NS_WARN_IF(NS_FAILED(rv))) { + LOG(("No browsing context is available for the channel.")); + return false; + } + if (Document::StorageAccessSandboxed(targetBC->GetSandboxFlags())) { LOG(("Our document is sandboxed")); *aRejectedReason = blockedReason; |