mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 775317. Add a test for the JSOPTION_VAROBJFIX behavior of JS_EvaluateScript. r=jorendorff
This commit is contained in:
parent
ace95218b3
commit
9bb7bd33eb
@ -64,6 +64,7 @@ CPPSRCS = \
|
||||
testVersion.cpp \
|
||||
testXDR.cpp \
|
||||
testProfileStrings.cpp \
|
||||
testJSEvaluateScript.cpp \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = \
|
||||
|
50
js/src/jsapi-tests/testJSEvaluateScript.cpp
Normal file
50
js/src/jsapi-tests/testJSEvaluateScript.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sw=4 et tw=99:
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
BEGIN_TEST(testJSEvaluateScript)
|
||||
{
|
||||
jsvalRoot proto(cx);
|
||||
JSObject *obj = JS_NewObject(cx, NULL, NULL, global);
|
||||
CHECK(obj);
|
||||
|
||||
uint32_t options = JS_GetOptions(cx);
|
||||
CHECK(options & JSOPTION_VAROBJFIX);
|
||||
|
||||
static const char src[] = "var x = 5;";
|
||||
|
||||
JS::Value retval;
|
||||
CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__,
|
||||
&retval));
|
||||
|
||||
JSBool hasProp = JS_TRUE;
|
||||
CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp));
|
||||
CHECK(!hasProp);
|
||||
|
||||
hasProp = JS_FALSE;
|
||||
CHECK(JS_HasProperty(cx, global, "x", &hasProp));
|
||||
CHECK(hasProp);
|
||||
|
||||
// Now do the same thing, but without JSOPTION_VAROBJFIX
|
||||
JS_SetOptions(cx, options & ~JSOPTION_VAROBJFIX);
|
||||
|
||||
static const char src2[] = "var y = 5;";
|
||||
|
||||
CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__,
|
||||
&retval));
|
||||
|
||||
hasProp = JS_FALSE;
|
||||
CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp));
|
||||
CHECK(hasProp);
|
||||
|
||||
hasProp = JS_TRUE;
|
||||
CHECK(JS_AlreadyHasOwnProperty(cx, global, "y", &hasProp));
|
||||
CHECK(!hasProp);
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(testJSEvaluateScript)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user