Bug 1351935 P1 Make Client.navigate() support cross-origin loads. r=smaug
authorBen Kelly <ben@wanderview.com>
Mon, 10 Apr 2017 21:30:24 -0400
changeset 560296 2606285d497d32baba5efb7af2a247301596b677
parent 560295 f8e5f13e4dbcb2de36a9b476a953d5c6a0cfa9ff
child 560297 3f5856b402d69e79bc45e4dcdee649a407c2b53a
push id53365
push userjichen@mozilla.com
push dateTue, 11 Apr 2017 08:35:12 +0000
reviewerssmaug
bugs1351935
milestone55.0a1
Bug 1351935 P1 Make Client.navigate() support cross-origin loads. r=smaug
dom/workers/ServiceWorkerWindowClient.cpp
--- a/dom/workers/ServiceWorkerWindowClient.cpp
+++ b/dom/workers/ServiceWorkerWindowClient.cpp
@@ -375,21 +375,16 @@ public:
     nsCOMPtr<nsIURI> baseUrl;
     nsCOMPtr<nsIURI> url;
     nsresult rv = ParseUrl(getter_AddRefs(baseUrl), getter_AddRefs(url));
 
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return RejectPromise(NS_ERROR_TYPE_ERR);
     }
 
-    rv = principal->CheckMayLoad(url, true, false);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return RejectPromise(rv);
-    }
-
     nsGlobalWindow* window;
     rv = Navigate(url, principal, &window);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return RejectPromise(rv);
     }
 
     nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
     nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
@@ -494,29 +489,28 @@ private:
     nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
     if (NS_WARN_IF(!docShell)) {
       return NS_ERROR_TYPE_ERR;
     }
 
     nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
     nsresult rv = docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
+      return NS_ERROR_TYPE_ERR;
     }
 
     loadInfo->SetTriggeringPrincipal(aPrincipal);
-    loadInfo->SetReferrer(doc->GetOriginalURI());
     loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
-    loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContentAndReplace);
+    loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContent);
     loadInfo->SetSourceDocShell(docShell);
     rv =
       docShell->LoadURI(aUrl, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, true);
 
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
+      return NS_ERROR_TYPE_ERR;
     }
 
     *aWindow = window;
     return NS_OK;
   }
 };
 
 already_AddRefed<Promise>