Bug 813278 - Overload JSAutoCompartment for TimeZoneSettingObserver - r=luke

This commit is contained in:
Jeff Gilbert 2012-11-20 01:39:26 -08:00
parent 060f9c47ea
commit a6216d9879
3 changed files with 10 additions and 1 deletions

View File

@ -82,7 +82,7 @@ public:
// Set the system timezone based on the current settings.
if (aResult.isString()) {
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(aResult));
JSAutoCompartment ac(cx, aResult.toString());
return TimeZoneSettingObserver::SetTimeZone(aResult, cx);
}

View File

@ -1488,6 +1488,14 @@ JSAutoCompartment::JSAutoCompartment(JSContext *cx, JSStackFrame *target)
cx_->enterCompartment(Valueify(target)->global().compartment());
}
JSAutoCompartment::JSAutoCompartment(JSContext *cx, JSString *target)
: cx_(cx),
oldCompartment_(cx->compartment)
{
AssertHeapIsIdleOrIterating(cx_);
cx_->enterCompartment(target->compartment());
}
JSAutoCompartment::~JSAutoCompartment()
{
cx_->leaveCompartment(oldCompartment_);

View File

@ -3156,6 +3156,7 @@ class JS_PUBLIC_API(JSAutoCompartment)
JSAutoCompartment(JSContext *cx, JSRawObject target);
JSAutoCompartment(JSContext *cx, JSScript *target);
JSAutoCompartment(JSContext *cx, JSStackFrame *target);
JSAutoCompartment(JSContext *cx, JSString *target);
~JSAutoCompartment();
};