Bug 1135141 - Fix jsapi-test framework to not overwrite original global when createGlobal() fails r=terrence

This commit is contained in:
Jon Coppeard 2015-02-24 09:40:02 +00:00
parent 16c2153df4
commit cccd72bd00

View File

@ -76,20 +76,23 @@ bool JSAPITest::definePrint()
JSObject * JSAPITest::createGlobal(JSPrincipals *principals)
{
/* Create the global object. */
JS::RootedObject newGlobal(cx);
JS::CompartmentOptions options;
options.setVersion(JSVERSION_LATEST);
global = JS_NewGlobalObject(cx, getGlobalClass(), principals, JS::FireOnNewGlobalHook, options);
if (!global)
newGlobal = JS_NewGlobalObject(cx, getGlobalClass(), principals, JS::FireOnNewGlobalHook,
options);
if (!newGlobal)
return nullptr;
JSAutoCompartment ac(cx, global);
JSAutoCompartment ac(cx, newGlobal);
/* Populate the global object with the standard globals, like Object and
Array. */
if (!JS_InitStandardClasses(cx, global))
global = nullptr;
if (!JS_InitStandardClasses(cx, newGlobal))
return nullptr;
return global;
global = newGlobal;
return newGlobal;
}
int main(int argc, char *argv[])