mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 733872 - Use JS_GetObjectPrototype in XPCWrappedNativeScope::SetGlobal; r=bholley
This commit is contained in:
parent
168be1c4e1
commit
05ab4b800a
@ -1,6 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
@ -255,30 +254,12 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal,
|
||||
mScriptObjectPrincipal = sop;
|
||||
|
||||
// Lookup 'globalObject.Object.prototype' for our wrapper's proto
|
||||
{
|
||||
AutoJSErrorAndExceptionEater eater(ccx); // scoped error eater
|
||||
|
||||
jsval val;
|
||||
jsid idObj = mRuntime->GetStringID(XPCJSRuntime::IDX_OBJECT);
|
||||
jsid idProto = mRuntime->GetStringID(XPCJSRuntime::IDX_PROTOTYPE);
|
||||
|
||||
// When creating a new scope to boostrap a new global, we don't yet have
|
||||
// an XPCWrappedNative associated with the global object. However, the
|
||||
// resolve hook on the JSClass assumes there is one. So we need to avoid
|
||||
// resolving anything on the global object until things get a bit further
|
||||
// along. As such, we manually resolve |Object| before accessing it below.
|
||||
JSBool didResolve;
|
||||
|
||||
if (JS_ResolveStandardClass(ccx, aGlobal, idObj, &didResolve) &&
|
||||
JS_GetPropertyById(ccx, aGlobal, idObj, &val) &&
|
||||
!JSVAL_IS_PRIMITIVE(val) &&
|
||||
JS_GetPropertyById(ccx, JSVAL_TO_OBJECT(val), idProto, &val) &&
|
||||
!JSVAL_IS_PRIMITIVE(val)) {
|
||||
mPrototypeJSObject = JSVAL_TO_OBJECT(val);
|
||||
} else {
|
||||
NS_ERROR("Can't get globalObject.Object.prototype");
|
||||
}
|
||||
}
|
||||
JSObject *objectPrototype =
|
||||
JS_GetObjectPrototype(ccx.GetJSContext(), aGlobal);
|
||||
if (objectPrototype)
|
||||
mPrototypeJSObject = objectPrototype;
|
||||
else
|
||||
NS_ERROR("Can't get globalObject.Object.prototype");
|
||||
|
||||
// Clear the no helper wrapper prototype object so that a new one
|
||||
// gets created if needed.
|
||||
|
@ -3954,30 +3954,6 @@ private:
|
||||
PRInt64 mTimeStamp;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class NS_STACK_CLASS AutoJSErrorAndExceptionEater
|
||||
{
|
||||
public:
|
||||
AutoJSErrorAndExceptionEater(JSContext* aCX
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCX(aCX),
|
||||
mOldErrorReporter(JS_SetErrorReporter(mCX, nsnull)),
|
||||
mOldExceptionState(JS_SaveExceptionState(mCX)) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
~AutoJSErrorAndExceptionEater()
|
||||
{
|
||||
JS_SetErrorReporter(mCX, mOldErrorReporter);
|
||||
JS_RestoreExceptionState(mCX, mOldExceptionState);
|
||||
}
|
||||
private:
|
||||
JSContext* mCX;
|
||||
JSErrorReporter mOldErrorReporter;
|
||||
JSExceptionState* mOldExceptionState;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Handles pre/post script processing and the setting/resetting the error
|
||||
* reporter
|
||||
|
Loading…
Reference in New Issue
Block a user