Bug 863246 - Use system principal to load debugger scripts r=billm,bkelly draft
authorChung-Sheng Fu <cfu@mozilla.com>
Mon, 07 Aug 2017 15:55:39 +0800
changeset 654064 c185be0d4d2180dd3dd7d0fbcfdd1035f3b4ddf3
parent 654063 888f7ce8f9db809ad5abbe6340af74e9dfb1d73b
child 654065 56f3bd471a4e21f40a052d808d993c593bed96f3
push id76471
push userbmo:cfu@mozilla.com
push dateMon, 28 Aug 2017 08:30:33 +0000
reviewersbillm, bkelly
bugs863246
milestone57.0a1
Bug 863246 - Use system principal to load debugger scripts r=billm,bkelly MozReview-Commit-ID: DPvbR1As2UV
dom/workers/ScriptLoader.cpp
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -889,20 +889,29 @@ private:
     return NS_OK;
   }
 
   nsresult
   LoadScript(uint32_t aIndex)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aIndex < mLoadInfos.Length());
+    MOZ_ASSERT_IF(IsMainWorkerScript(), mWorkerScriptType != DebuggerScript);
 
     WorkerPrivate* parentWorker = mWorkerPrivate->GetParent();
 
-    nsIPrincipal* principal = mWorkerPrivate->GetPrincipal();
+    // For JavaScript debugging, the devtools server must run on the same
+    // thread as the debuggee, indicating the worker uses content principal.
+    // However, in Bug 863246, web content will no longer be able to load
+    // resource:// URIs by default, so we need system principal to load
+    // debugger scripts.
+    nsIPrincipal* principal = (mWorkerScriptType == DebuggerScript) ?
+                              nsContentUtils::GetSystemPrincipal() :
+                              mWorkerPrivate->GetPrincipal();
+
     nsCOMPtr<nsILoadGroup> loadGroup = mWorkerPrivate->GetLoadGroup();
     MOZ_DIAGNOSTIC_ASSERT(principal);
 
     NS_ENSURE_TRUE(NS_LoadGroupMatchesPrincipal(loadGroup, principal),
                    NS_ERROR_FAILURE);
 
     // Figure out our base URI.
     nsCOMPtr<nsIURI> baseURI = GetBaseURI(mIsMainScript, mWorkerPrivate);