Bug 1489301 - Part 2: Fix broken [Func] condition assuming Window object, r=bzbarsky

This condition unwraps the global to a window, and doesn't check before
dereferencing. This is no longer valid now that the corresponding interfaces
are exposed on BackstagePass.

Differential Revision: https://phabricator.services.mozilla.com/D9402
This commit is contained in:
Nika Layzell 2018-10-21 20:38:41 -04:00
parent 91ec325721
commit 91cec0e775

View File

@ -3095,7 +3095,8 @@ nsGlobalWindowInner::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aName
nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj)
{
// For now, have to deal with XPConnect objects here.
return xpc::WindowOrNull(aObj)->IsChromeWindow() &&
nsGlobalWindowInner* win = xpc::WindowOrNull(aObj);
return win && win->IsChromeWindow() &&
nsContentUtils::ObjectPrincipal(aObj) == nsContentUtils::GetSystemPrincipal();
}