Bug 1081537 - Fall back to the addon global (if one exists) in GetEntryDocument. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Fri, 17 Oct 2014 17:19:19 +0200
changeset 235365 0016f0b28acb3173184b5ada38990ce98b44a8cc
parent 235364 788ff9d05938d01c66c5fedfa450699a531408b9
child 235366 76686694c568a13a9e1a7b1efed2c5632bd81c06
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1081537
milestone36.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 1081537 - Fall back to the addon global (if one exists) in GetEntryDocument. r=bz
dom/base/ScriptSettings.cpp
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -126,17 +126,26 @@ nsIGlobalObject*
 GetEntryGlobal()
 {
   return ScriptSettingsStack::EntryGlobal();
 }
 
 nsIDocument*
 GetEntryDocument()
 {
-  nsCOMPtr<nsPIDOMWindow> entryWin = do_QueryInterface(GetEntryGlobal());
+  nsIGlobalObject* global = GetEntryGlobal();
+  nsCOMPtr<nsPIDOMWindow> entryWin = do_QueryInterface(global);
+
+  // If our entry global isn't a window, see if it's an addon scope associated
+  // with a window. If it is, the caller almost certainly wants that rather
+  // than null.
+  if (!entryWin) {
+    entryWin = xpc::AddonWindowOrNull(global->GetGlobalJSObject());
+  }
+
   return entryWin ? entryWin->GetExtantDoc() : nullptr;
 }
 
 nsIGlobalObject*
 GetIncumbentGlobal()
 {
   // We need the current JSContext in order to check the JS for
   // scripted frames that may have appeared since anyone last