Bug 630242 - Reduce occurrences of "WARNING: No outer window available!" in debug mochitests by tweaking ghost window detection code. r=smaug
authorJustin Lebar <justin.lebar@gmail.com>
Tue, 09 Oct 2012 15:17:53 -0400
changeset 109777 d58233470ee5b69fea448c2babbbb4766e129767
parent 109776 e061305143b6c7615947777531edede64cc7aced
child 109778 3cc4987101b8d859a509b45cc091136329f6ba56
push id16192
push userjlebar@mozilla.com
push dateTue, 09 Oct 2012 19:18:12 +0000
treeherdermozilla-inbound@d58233470ee5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs630242
milestone19.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 630242 - Reduce occurrences of "WARNING: No outer window available!" in debug mochitests by tweaking ghost window detection code. r=smaug
dom/base/nsWindowMemoryReporter.cpp
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -63,20 +63,25 @@ GetWindowURI(nsIDOMWindow *aWindow)
     uri = doc->GetDocumentURI();
   }
 
   if (!uri) {
     nsCOMPtr<nsIScriptObjectPrincipal> scriptObjPrincipal =
       do_QueryInterface(aWindow);
     NS_ENSURE_TRUE(scriptObjPrincipal, NULL);
 
-    nsIPrincipal *principal = scriptObjPrincipal->GetPrincipal();
-
-    if (principal) {
-      principal->GetURI(getter_AddRefs(uri));
+    // GetPrincipal() will print a warning if the window does not have an outer
+    // window, so check here for an outer window first.  This code is
+    // functionally correct if we leave out the GetOuterWindow() check, but we
+    // end up printing a lot of warnings during debug mochitests.
+    if (pWindow->GetOuterWindow()) {
+      nsIPrincipal* principal = scriptObjPrincipal->GetPrincipal();
+      if (principal) {
+        principal->GetURI(getter_AddRefs(uri));
+      }
     }
   }
 
   return uri.forget();
 }
 
 static void
 AppendWindowURI(nsGlobalWindow *aWindow, nsACString& aStr)