Bug 1081537 - Fall back to the addon global (if one exists) in GetEntryDocument. r=bz

This commit is contained in:
Bobby Holley
2014-10-17 17:19:19 +02:00
parent edc8ff873b
commit 683c8d27d7

View File

@@ -131,7 +131,16 @@ GetEntryGlobal()
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;
}