Bug 606371 - Use scopeChain and AccessCheck to determine if a script is chrome [r=mrbkap a=blocking-fennec]

This commit is contained in:
Mark Finkle 2010-10-22 01:15:21 -04:00
Родитель c1917fad5f
Коммит 30ea160b50
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -105,6 +105,12 @@
#include "WrapperFactory.h" #include "WrapperFactory.h"
#include "nsGlobalWindow.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 #ifdef MOZ_JSDEBUGGER
#include "jsdIDebuggerService.h" #include "jsdIDebuggerService.h"
#endif #endif
@ -947,8 +953,9 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
// Check the amount of time this script has been running, or if the // Check the amount of time this script has been running, or if the
// dialog is disabled. // dialog is disabled.
JSObject* global = ::JS_GetGlobalForScopeChain(cx);
PRBool isTrackingChromeCodeTime = PRBool isTrackingChromeCodeTime =
::JS_IsSystemObject(cx, ::JS_GetGlobalObject(cx)); global && xpc::AccessCheck::isChrome(global->getCompartment());
if (duration < (isTrackingChromeCodeTime ? if (duration < (isTrackingChromeCodeTime ?
sMaxChromeScriptRunTime : sMaxScriptRunTime)) { sMaxChromeScriptRunTime : sMaxScriptRunTime)) {
return JS_TRUE; return JS_TRUE;