diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 5623cbcaa93..0b2a4ce3520 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1194,6 +1194,18 @@ JS_SetContextPrivate(JSContext *cx, void *data) cx->data = data; } +JS_PUBLIC_API(void *) +JS_GetSecondContextPrivate(JSContext *cx) +{ + return cx->data2; +} + +JS_PUBLIC_API(void) +JS_SetSecondContextPrivate(JSContext *cx, void *data) +{ + cx->data2 = data; +} + JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 68d9cac0a18..a982ae6f8ef 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2085,6 +2085,12 @@ JS_GetContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetContextPrivate(JSContext *cx, void *data); +extern JS_PUBLIC_API(void *) +JS_GetSecondContextPrivate(JSContext *cx); + +extern JS_PUBLIC_API(void) +JS_SetSecondContextPrivate(JSContext *cx, void *data); + extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); diff --git a/js/xpconnect/src/XPCContext.cpp b/js/xpconnect/src/XPCContext.cpp index ea48216abe8..15c35521191 100644 --- a/js/xpconnect/src/XPCContext.cpp +++ b/js/xpconnect/src/XPCContext.cpp @@ -42,6 +42,8 @@ #include "xpcprivate.h" +#include "jsapi.h" + /***************************************************************************/ XPCContext::XPCContext(XPCJSRuntime* aRuntime, @@ -59,15 +61,15 @@ XPCContext::XPCContext(XPCJSRuntime* aRuntime, PR_INIT_CLIST(&mScopes); - NS_ASSERTION(!mJSContext->data2, "Must be null"); - mJSContext->data2 = this; + NS_ASSERTION(!JS_GetSecondContextPrivate(mJSContext), "Must be null"); + JS_SetSecondContextPrivate(mJSContext, this); } XPCContext::~XPCContext() { MOZ_COUNT_DTOR(XPCContext); - NS_ASSERTION(mJSContext->data2 == this, "Must match this"); - mJSContext->data2 = nsnull; + NS_ASSERTION(JS_GetSecondContextPrivate(mJSContext) == this, "Must match this"); + JS_SetSecondContextPrivate(mJSContext, nsnull); NS_IF_RELEASE(mException); NS_IF_RELEASE(mSecurityManager); diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index ff7769f3a2c..2542fec62fc 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -859,8 +859,8 @@ class XPCContext public: static XPCContext* GetXPCContext(JSContext* aJSContext) { - NS_ASSERTION(aJSContext->data2, "should already have XPCContext"); - return static_cast(aJSContext->data2); + NS_ASSERTION(JS_GetSecondContextPrivate(aJSContext), "should already have XPCContext"); + return static_cast(JS_GetSecondContextPrivate(aJSContext)); } XPCJSRuntime* GetRuntime() const {return mRuntime;}