Bug 1486057: Skip uninitialized windows when injecting content scripts. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Sat, 25 Aug 2018 14:00:03 -0700
changeset 481871 292e35a4377f5f6c5534dad4f4df349010de41b9
parent 481870 7eb7606a2b12990e8ef5e470db27838d5f5af612
child 481872 24a110d82c0f52e757878dbfa7b0c62f2bd0b2fa
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersmixedpuppy
bugs1486057
milestone63.0a1
Bug 1486057: Skip uninitialized windows when injecting content scripts. r=mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D4286
toolkit/components/extensions/ExtensionPolicyService.cpp
--- a/toolkit/components/extensions/ExtensionPolicyService.cpp
+++ b/toolkit/components/extensions/ExtensionPolicyService.cpp
@@ -373,16 +373,19 @@ ExtensionPolicyService::InjectContentScr
   for (auto iter = mMessageManagers.ConstIter(); !iter.Done(); iter.Next()) {
     ContentFrameMessageManager* mm = iter.Get()->GetKey();
 
     nsCOMPtr<nsIDocShell> docShell = mm->GetDocShell(IgnoreErrors());
     NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
 
     auto result = ForEachDocShell(docShell, [&](nsIDocShell* aDocShell) -> nsresult {
       nsCOMPtr<nsPIDOMWindowOuter> win = aDocShell->GetWindow();
+      if (!win->GetDocumentURI()) {
+        return NS_OK;
+      }
       DocInfo docInfo(win);
 
       using RunAt = dom::ContentScriptRunAt;
       using Scripts = AutoTArray<RefPtr<WebExtensionContentScript>, 8>;
 
       constexpr uint8_t n = uint8_t(RunAt::EndGuard_);
       Scripts scripts[n];