michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "jsapi-tests/tests.h" michael@0: michael@0: BEGIN_TEST(testContexts_IsRunning) michael@0: { michael@0: CHECK(JS_DefineFunction(cx, global, "chk", chk, 0, 0)); michael@0: EXEC("for (var i = 0; i < 9; i++) chk();"); michael@0: return true; michael@0: } michael@0: michael@0: static bool chk(JSContext *cx, unsigned argc, jsval *vp) michael@0: { michael@0: JSRuntime *rt = JS_GetRuntime(cx); michael@0: JSContext *acx = JS_NewContext(rt, 8192); michael@0: if (!acx) { michael@0: JS_ReportOutOfMemory(cx); michael@0: return false; michael@0: } michael@0: michael@0: // acx should not be running michael@0: bool ok = !JS_IsRunning(acx); michael@0: if (!ok) michael@0: JS_ReportError(cx, "Assertion failed: brand new context claims to be running"); michael@0: JS_DestroyContext(acx); michael@0: return ok; michael@0: } michael@0: END_TEST(testContexts_IsRunning) michael@0: michael@0: BEGIN_TEST(testContexts_bug563735) michael@0: { michael@0: JSContext *cx2 = JS_NewContext(rt, 8192); michael@0: CHECK(cx2); michael@0: michael@0: bool ok; michael@0: { michael@0: JSAutoRequest req(cx2); michael@0: JSAutoCompartment ac(cx2, global); michael@0: JS::RootedValue v(cx2); michael@0: ok = JS_SetProperty(cx2, global, "x", v); michael@0: } michael@0: CHECK(ok); michael@0: michael@0: EXEC("(function () { for (var i = 0; i < 9; i++) ; })();"); michael@0: michael@0: JS_DestroyContext(cx2); michael@0: return true; michael@0: } michael@0: END_TEST(testContexts_bug563735)