From 3c661e39a47b794ddc44dde72feb72f48ef8f936 Mon Sep 17 00:00:00 2001 From: "mconnor%steelgryphon.com" Date: Thu, 21 Apr 2005 21:05:10 +0000 Subject: [PATCH] land jst's fix for bug 289675, r=bz/dveditz, sr=brendan, a=chase --- dom/src/base/nsDOMClassInfo.cpp | 37 ++++++++++++------- .../xpconnect/src/xpcwrappednativescope.cpp | 5 +-- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index a47f24b9316..45dcb59eb05 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -5044,27 +5044,28 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, nsIScriptContext *my_context = sgo->GetContext(); - if (!my_context || !my_context->IsContextInitialized()) { - // The context is not yet initialized so there's nothing we can do - // here yet. - - return NS_OK; - } - nsresult rv = NS_OK; // It is not worth calling JS_ResolveStandardClass() if we are // resolving for assignment, since only read-write properties // get dealt with there. if (!(flags & JSRESOLVE_ASSIGNING)) { - JSContext *my_cx = (JSContext *) my_context->GetNativeContext(); - JSBool did_resolve = JS_FALSE; + // Resolve standard classes on my_context's JSContext (or on cx, + // if we don't have a my_context yet), in case the two contexts + // have different origins. We want lazy standard class + // initialization to behave as if it were done eagerly, on each + // window's own context (not on some other window-caller's + // context). + + JSContext *my_cx; - // Resolve standard classes on my_context's JSContext, not on - // cx, in case the two contexts have different origins. We want - // lazy standard class initialization to behave as if it were - // done eagerly, on each window's own context (not on some other - // window-caller's context). + if (!my_context) { + my_cx = cx; + } else { + my_cx = (JSContext *)my_context->GetNativeContext(); + } + + JSBool did_resolve = JS_FALSE; if (!::JS_ResolveStandardClass(my_cx, obj, id, &did_resolve)) { *_retval = JS_FALSE; @@ -5086,6 +5087,14 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, } } + if (!my_context || !my_context->IsContextInitialized()) { + // The context is not yet initialized so there's nothing we can do + // here yet. + + return NS_OK; + } + + // Hmm, we do an awful lot of QIs here; maybe we should add a // method on an interface that would let us just call into the // window code directly... diff --git a/js/src/xpconnect/src/xpcwrappednativescope.cpp b/js/src/xpconnect/src/xpcwrappednativescope.cpp index b1b17ed452d..1cf51a6c46a 100644 --- a/js/src/xpconnect/src/xpcwrappednativescope.cpp +++ b/js/src/xpconnect/src/xpcwrappednativescope.cpp @@ -193,10 +193,7 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal) } else { -#if defined(DEBUG_jband) || defined(DEBUG_jst) -// NS_ERROR("Can't get globalObject.Object.prototype"); - NS_WARNING("Can't get globalObject.Object.prototype"); -#endif + NS_ERROR("Can't get globalObject.Object.prototype"); } } }