Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 */
5 #include "jsapi-tests/tests.h"
7 BEGIN_TEST(testJSEvaluateScript)
8 {
9 JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), global));
10 CHECK(obj);
12 CHECK(JS::ContextOptionsRef(cx).varObjFix());
14 static const char src[] = "var x = 5;";
16 JS::RootedValue retval(cx);
17 CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__, &retval));
19 bool hasProp = true;
20 CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp));
21 CHECK(!hasProp);
23 hasProp = false;
24 CHECK(JS_HasProperty(cx, global, "x", &hasProp));
25 CHECK(hasProp);
27 // Now do the same thing, but without JSOPTION_VAROBJFIX
28 JS::ContextOptionsRef(cx).setVarObjFix(false);
30 static const char src2[] = "var y = 5;";
32 CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__, &retval));
34 hasProp = false;
35 CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp));
36 CHECK(hasProp);
38 hasProp = true;
39 CHECK(JS_AlreadyHasOwnProperty(cx, global, "y", &hasProp));
40 CHECK(!hasProp);
42 return true;
43 }
44 END_TEST(testJSEvaluateScript)