Fix testContexts_bug570746 for the third time. The scope of the jsvalRoot fundamentally cannot be correct here, so explicit JS_{Add,Remove}ObjectRoot calls are needed. r=orange.
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 14 Jun 2010 18:50:07 -0500
changeset 47442 c254a83a877557cf9e820c2a1b5f1137c551e6ba
parent 47441 210562a030b7bf8aa47a0d87dfc45cbd910a1d7a
child 47443 fecc8ed9e813516cc6d820bd4981c0012732ede9
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersorange
bugs570746
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Fix testContexts_bug570746 for the third time. The scope of the jsvalRoot fundamentally cannot be correct here, so explicit JS_{Add,Remove}ObjectRoot calls are needed. r=orange.
js/src/jsapi-tests/testContexts.cpp
--- a/js/src/jsapi-tests/testContexts.cpp
+++ b/js/src/jsapi-tests/testContexts.cpp
@@ -90,32 +90,32 @@ BEGIN_TEST(testContexts_bug563735)
 
     EXEC("(function () { for (var i = 0; i < 9; i++) ; })();");
 
     JS_DestroyContext(cx2);
     return true;
 }
 END_TEST(testContexts_bug563735)
 
-BEGIN_TEST(testContexts_bug570764)
+BEGIN_TEST(testContexts_bug570746)
 {
     JSRuntime *rt2 = JS_NewRuntime(8L * 1024 * 1024);
     CHECK(rt2);
 
-    {
-        // Create and destroy first context.
-        JSContext *cx2 = JS_NewContext(rt2, 8192);
-        CHECK(cx2);
-        JS_BeginRequest(cx2);
-        JSObject *obj = JS_NewGlobalObject(cx2, getGlobalClass());
-        CHECK(obj);
-        jsvalRoot objr(cx2, OBJECT_TO_JSVAL(obj));
-        JS_DestroyContext(cx2);
+    // Create and destroy first context.
+    JSContext *cx2 = JS_NewContext(rt2, 8192);
+    CHECK(cx2);
+    JS_BeginRequest(cx2);
+    JSObject *obj = JS_NewGlobalObject(cx2, getGlobalClass());
+    CHECK(obj);
+    CHECK(JS_AddObjectRoot(cx2, &obj));
+    JS_DestroyContext(cx2);
 
-        // Create and destroy second context.
-        cx2 = JS_NewContext(rt2, 8192);
-        CHECK(cx2);
-        JS_DestroyContext(cx2);
-    }
+    // Create and destroy second context.
+    cx2 = JS_NewContext(rt2, 8192);
+    CHECK(cx2);
+    CHECK(JS_RemoveObjectRoot(cx2, &obj));
+    JS_DestroyContext(cx2);
+
     JS_DestroyRuntime(rt2);
     return true;
 }
-END_TEST(testContexts_bug570764)
+END_TEST(testContexts_bug570746)