diff --git a/dom/public/nsIScriptContext.h b/dom/public/nsIScriptContext.h index 1675e711685..296287c28df 100644 --- a/dom/public/nsIScriptContext.h +++ b/dom/public/nsIScriptContext.h @@ -330,6 +330,16 @@ public: NS_IMETHOD SetTerminationFunction(nsScriptTerminationFunc aFunc, nsISupports* aRef) = 0; + /** + * Store a single script object to be unrooted from the script garbage + * collector in the implementation's destructor. This obvious hack + * is used to delay the unrooting of an object until that point. + * (At time of writing, it's used only on the window script object). + * This should never be called twice (the stored object will never + * be replaced.) + */ + NS_IMETHOD SetRootedScriptObject(void *aObject) = 0; + /** * Called to disable/enable script execution in this context. */ diff --git a/dom/src/base/nsJSEnvironment.h b/dom/src/base/nsJSEnvironment.h index f867d3480eb..ad6f415f195 100644 --- a/dom/src/base/nsJSEnvironment.h +++ b/dom/src/base/nsJSEnvironment.h @@ -49,6 +49,7 @@ private: nsCOMPtr mRef; PRBool mScriptsEnabled; PRUint32 mBranchCallbackCount; + void *mRootedScriptObject; // special case for the window script object static JSBool PR_CALLBACK DOMBranchCallback(JSContext *cx, JSScript *script); @@ -127,6 +128,7 @@ public: NS_IMETHOD GetOwner(nsIScriptContextOwner** owner); NS_IMETHOD SetTerminationFunction(nsScriptTerminationFunc aFunc, nsISupports* aRef); + NS_IMETHOD SetRootedScriptObject(void *aObject); NS_IMETHOD GetScriptsEnabled(PRBool *aEnabled); NS_IMETHOD SetScriptsEnabled(PRBool aEnabled);