This article covers features introduced in SpiderMonkey 18
Note: the preferred way of changing a context's current compartment is using
Enter a different compartment on the given context, so that objects in that compartment can be accessed.
JSCompartment *JS_EnterCompartment(JSContext *cx, JSRawObject target);
||The context on which a cross-compartment call is needed.|
The object in a different compartment to be accessed. This implicitly identifies the compartment to be entered.
JS_EnterCompartmentreturns a pointer to the entered compartment. To leave that compartment, pass it to
JS_EnterCompartmentis infallible, so a
NULLreturn value doesn't indicate failure.