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
Родитель 36e2a81120
Коммит 3268a57801
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -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;
}