Bug 951991 - Implement GetEntryGlobal. r=smaug
This commit is contained in:
@@ -122,28 +122,12 @@ ScriptSettingsStackEntry::~ScriptSettingsStackEntry()
|
||||
ScriptSettingsStack::Pop(this);
|
||||
}
|
||||
|
||||
// This mostly gets the entry global, but doesn't entirely match the spec in
|
||||
// certain edge cases. It's good enough for some purposes, but not others. If
|
||||
// you want to call this function, ping bholley and describe your use-case.
|
||||
nsIGlobalObject*
|
||||
BrokenGetEntryGlobal()
|
||||
GetEntryGlobal()
|
||||
{
|
||||
// We need the current JSContext in order to check the JS for
|
||||
// scripted frames that may have appeared since anyone last
|
||||
// manipulated the stack. If it's null, that means that there
|
||||
// must be no entry global on the stack.
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
if (!cx) {
|
||||
MOZ_ASSERT(ScriptSettingsStack::EntryGlobal() == nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nsJSUtils::GetDynamicScriptGlobal(cx);
|
||||
return ScriptSettingsStack::EntryGlobal();
|
||||
}
|
||||
|
||||
// Note: When we're ready to expose it, GetEntryGlobal will look similar to
|
||||
// GetIncumbentGlobal below.
|
||||
|
||||
nsIGlobalObject*
|
||||
GetIncumbentGlobal()
|
||||
{
|
||||
@@ -171,6 +155,22 @@ GetIncumbentGlobal()
|
||||
return ScriptSettingsStack::IncumbentGlobal();
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
GetCurrentGlobal()
|
||||
{
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
if (!cx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSObject *global = JS::CurrentGlobalOrNull(cx);
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return xpc::GetNativeForGlobal(global);
|
||||
}
|
||||
|
||||
nsIPrincipal*
|
||||
GetWebIDLCallerPrincipal()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user