[tbb-commits] [tor-browser/tor-browser-45.4.0esr-6.5-1] Bug 20043: Isolate SharedWorker script requests to first party
gk at torproject.org
gk at torproject.org
Thu Oct 6 07:44:20 UTC 2016
commit 22e6c335a74f08d37dd0e2daec9951dd4d0cc89d
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date: Thu Sep 22 05:49:07 2016 +0000
Bug 20043: Isolate SharedWorker script requests to first party
---
dom/workers/WorkerPrivate.cpp | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
index 830712e..2ac0c0f 100644
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -4396,6 +4396,25 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindow* aWindow,
getter_AddRefs(loadInfo.mChannel));
NS_ENSURE_SUCCESS(rv, rv);
+ // If this is a SharedWorker and we have an isolation key, use it as the
+ // DocumentURI for this channel. Ensures we get the right first-party domain.
+ if ((aWorkerType == WorkerTypeShared || aWorkerType == WorkerTypeService) &&
+ !loadInfo.mIsolationKey.IsEmpty()) {
+ nsCOMPtr<nsIHttpChannelInternal> channelInternal(do_QueryInterface(loadInfo.mChannel));
+ if (channelInternal) {
+ nsCString documentURISpec("https://");
+ documentURISpec.Append(loadInfo.mIsolationKey);
+ nsCOMPtr<nsIURI> documentURI;
+ nsresult rv = NS_NewURI(getter_AddRefs(documentURI), documentURISpec);
+ if (NS_SUCCEEDED(rv)) {
+ channelInternal->SetDocumentURI(documentURI);
+ } else {
+ NS_WARNING("Unable to set the documentURI for SharedWorker's "
+ "loading channel.");
+ }
+ }
+ }
+
rv = NS_GetFinalChannelURI(loadInfo.mChannel,
getter_AddRefs(loadInfo.mResolvedScriptURI));
NS_ENSURE_SUCCESS(rv, rv);
More information about the tbb-commits
mailing list