2010-06-09 12:34:18 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sw=4 et tw=99:
|
|
|
|
*/
|
|
|
|
|
2009-11-13 07:24:12 -08:00
|
|
|
#include "tests.h"
|
|
|
|
|
|
|
|
BEGIN_TEST(testContexts_IsRunning)
|
|
|
|
{
|
|
|
|
CHECK(JS_DefineFunction(cx, global, "chk", chk, 0, 0));
|
|
|
|
EXEC("for (var i = 0; i < 9; i++) chk();");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-16 12:35:04 -07:00
|
|
|
static JSBool chk(JSContext *cx, uintN argc, jsval *vp)
|
2009-11-13 07:24:12 -08:00
|
|
|
{
|
|
|
|
JSRuntime *rt = JS_GetRuntime(cx);
|
|
|
|
JSContext *acx = JS_NewContext(rt, 8192);
|
|
|
|
if (!acx) {
|
|
|
|
JS_ReportOutOfMemory(cx);
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// acx should not be running
|
|
|
|
bool ok = !JS_IsRunning(acx);
|
|
|
|
if (!ok)
|
|
|
|
JS_ReportError(cx, "Assertion failed: brand new context claims to be running");
|
|
|
|
JS_DestroyContext(acx);
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
END_TEST(testContexts_IsRunning)
|
2010-04-27 10:29:45 -07:00
|
|
|
|
2010-05-04 12:57:27 -07:00
|
|
|
BEGIN_TEST(testContexts_bug563735)
|
|
|
|
{
|
|
|
|
JSContext *cx2 = JS_NewContext(rt, 8192);
|
|
|
|
CHECK(cx2);
|
|
|
|
|
2010-06-26 13:31:54 -07:00
|
|
|
JSBool ok;
|
|
|
|
{
|
|
|
|
JSAutoRequest req(cx2);
|
2010-09-27 15:55:15 -07:00
|
|
|
JSAutoEnterCompartment ac;
|
|
|
|
CHECK(ac.enter(cx2, global));
|
2010-06-26 13:31:54 -07:00
|
|
|
jsval v = JSVAL_NULL;
|
|
|
|
ok = JS_SetProperty(cx2, global, "x", &v);
|
|
|
|
}
|
2010-05-04 12:57:27 -07:00
|
|
|
CHECK(ok);
|
|
|
|
|
|
|
|
EXEC("(function () { for (var i = 0; i < 9; i++) ; })();");
|
|
|
|
|
|
|
|
JS_DestroyContext(cx2);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
END_TEST(testContexts_bug563735)
|