Bug 1211967 - Fix how we report errors when loading a worker from a data url, r=bz, a=lizzard
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 27 Oct 2015 10:17:17 -0700
changeset 298288 e2c0b15aed6b5f20c427ce753e56d0f0ccad594b
parent 298287 b0f5fa1535dd89740f3226c21d39801c074e1960
child 298289 c017ca15c40c99776c84f40c100cb5c578b8ae66
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lizzard
bugs1211967
milestone43.0a2
Bug 1211967 - Fix how we report errors when loading a worker from a data url, r=bz, a=lizzard
dom/workers/ScriptLoader.cpp
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -971,17 +971,23 @@ private:
 
     nsIPrincipal* principal = mWorkerPrivate->GetPrincipal();
     if (!principal) {
       WorkerPrivate* parentWorker = mWorkerPrivate->GetParent();
       MOZ_ASSERT(parentWorker, "Must have a parent!");
       principal = parentWorker->GetPrincipal();
     }
 
-    aLoadInfo.mMutedErrorFlag.emplace(!principal->Subsumes(channelPrincipal));
+    // We don't mute the main worker script becase we've already done
+    // same-origin checks on them so we should be able to see their errors.
+    // Note that for data: url, where we allow it through the same-origin check
+    // but then give it a different origin.
+    aLoadInfo.mMutedErrorFlag.emplace(IsMainWorkerScript()
+                                        ? false 
+                                        : !principal->Subsumes(channelPrincipal));
 
     // Make sure we're not seeing the result of a 404 or something by checking
     // the 'requestSucceeded' attribute on the http channel.
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request);
     if (httpChannel) {
       bool requestSucceeded;
       rv = httpChannel->GetRequestSucceeded(&requestSucceeded);
       NS_ENSURE_SUCCESS(rv, rv);