From 30ea160b5007eb6f843c91dc8d94969832318458 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Fri, 22 Oct 2010 01:15:21 -0400 Subject: [PATCH] Bug 606371 - Use scopeChain and AccessCheck to determine if a script is chrome [r=mrbkap a=blocking-fennec] --- dom/base/nsJSEnvironment.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index d7e1de5661a..b62cd496b09 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -105,6 +105,12 @@ #include "WrapperFactory.h" #include "nsGlobalWindow.h" +#ifdef XP_MACOSX +// AssertMacros.h defines 'check' and conflicts with AccessCheck.h +#undef check +#endif +#include "AccessCheck.h" + #ifdef MOZ_JSDEBUGGER #include "jsdIDebuggerService.h" #endif @@ -947,8 +953,9 @@ nsJSContext::DOMOperationCallback(JSContext *cx) // Check the amount of time this script has been running, or if the // dialog is disabled. + JSObject* global = ::JS_GetGlobalForScopeChain(cx); PRBool isTrackingChromeCodeTime = - ::JS_IsSystemObject(cx, ::JS_GetGlobalObject(cx)); + global && xpc::AccessCheck::isChrome(global->getCompartment()); if (duration < (isTrackingChromeCodeTime ? sMaxChromeScriptRunTime : sMaxScriptRunTime)) { return JS_TRUE;