Bug 1370263: Null check document URI before matching content scripts. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Mon, 05 Jun 2017 10:26:06 -0700
changeset 410515 f904e3d130ab951280c19ab2f32384fe30374bce
parent 410514 ab4ef8ca799e413049ff66c26328f409b15eb223
child 410516 60bbd8e76c33101fb0d4d6b69f5ec7920904f546
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1370263
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1370263: Null check document URI before matching content scripts. r=mixedpuppy MozReview-Commit-ID: IB8HMmukD1h
toolkit/components/extensions/ExtensionPolicyService.cpp
--- a/toolkit/components/extensions/ExtensionPolicyService.cpp
+++ b/toolkit/components/extensions/ExtensionPolicyService.cpp
@@ -239,17 +239,19 @@ ExtensionPolicyService::CheckRequest(nsI
 // Checks a document, just after the document element has been inserted, for
 // matching content scripts or extension principals, and loads them if
 // necessary.
 void
 ExtensionPolicyService::CheckDocument(nsIDocument* aDocument)
 {
   nsCOMPtr<nsPIDOMWindowOuter> win = aDocument->GetWindow();
   if (win) {
-    CheckContentScripts(win.get(), false);
+    if (win->GetDocumentURI()) {
+      CheckContentScripts(win.get(), false);
+    }
 
     nsIPrincipal* principal = aDocument->NodePrincipal();
 
     nsAutoString addonId;
     Unused << principal->GetAddonId(addonId);
 
     RefPtr<WebExtensionPolicy> policy = GetByID(addonId);
     if (policy) {
@@ -274,17 +276,17 @@ ExtensionPolicyService::CheckWindow(nsPI
   }
 
   nsCOMPtr<nsIURI> aboutBlank;
   NS_ENSURE_SUCCESS_VOID(NS_NewURI(getter_AddRefs(aboutBlank),
                                    "about:blank"));
 
   nsCOMPtr<nsIURI> uri = doc->GetDocumentURI();
   bool equal;
-  if (NS_FAILED(uri->EqualsExceptRef(aboutBlank, &equal)) || !equal) {
+  if (!uri || NS_FAILED(uri->EqualsExceptRef(aboutBlank, &equal)) || !equal) {
     return;
   }
 
   CheckContentScripts(aWindow, false);
 }
 
 void
 ExtensionPolicyService::CheckContentScripts(const DocInfo& aDocInfo, bool aIsPreload)