1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sw=4 et tw=99:
3 : */
4 :
5 : #include "tests.h"
6 :
7 4 : BEGIN_TEST(testContexts_IsRunning)
8 : {
9 1 : CHECK(JS_DefineFunction(cx, global, "chk", chk, 0, 0));
10 1 : EXEC("for (var i = 0; i < 9; i++) chk();");
11 1 : return true;
12 : }
13 :
14 9 : static JSBool chk(JSContext *cx, unsigned argc, jsval *vp)
15 : {
16 9 : JSRuntime *rt = JS_GetRuntime(cx);
17 9 : JSContext *acx = JS_NewContext(rt, 8192);
18 9 : if (!acx) {
19 0 : JS_ReportOutOfMemory(cx);
20 0 : return JS_FALSE;
21 : }
22 :
23 : // acx should not be running
24 9 : bool ok = !JS_IsRunning(acx);
25 9 : if (!ok)
26 0 : JS_ReportError(cx, "Assertion failed: brand new context claims to be running");
27 9 : JS_DestroyContext(acx);
28 9 : return ok;
29 : }
30 1 : END_TEST(testContexts_IsRunning)
31 :
32 4 : BEGIN_TEST(testContexts_bug563735)
33 : {
34 1 : JSContext *cx2 = JS_NewContext(rt, 8192);
35 1 : CHECK(cx2);
36 :
37 : JSBool ok;
38 : {
39 2 : JSAutoRequest req(cx2);
40 2 : JSAutoEnterCompartment ac;
41 1 : CHECK(ac.enter(cx2, global));
42 1 : jsval v = JSVAL_NULL;
43 2 : ok = JS_SetProperty(cx2, global, "x", &v);
44 : }
45 1 : CHECK(ok);
46 :
47 1 : EXEC("(function () { for (var i = 0; i < 9; i++) ; })();");
48 :
49 1 : JS_DestroyContext(cx2);
50 1 : return true;
51 : }
52 3 : END_TEST(testContexts_bug563735)
|