summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-09-07 10:51:39 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-07 04:50:45 +0200
commitbc2eac1ef3e6902f8fed65f72b70b582f93bcb19 (patch)
tree6af22cb1316b194268981bee884d17ba40dbce3a /tests
parent846c5c9459331cde33ef92b665fab1457eaf1252 (diff)
Update V8
This fixes a few bugs in QML mode name resolution and simplifies our V8 patchset a little by folding some patches together. Change-Id: Ia528a43ac8ccad95ac81bcdff5d05aaeab4b48b2 Reviewed-on: http://codereview.qt.nokia.com/4294 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/v8/tst_v8.cpp6
-rw-r--r--tests/auto/v8/v8main.cpp1
-rw-r--r--tests/auto/v8/v8test.cpp43
-rw-r--r--tests/auto/v8/v8test.h1
4 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/v8/tst_v8.cpp b/tests/auto/v8/tst_v8.cpp
index 4ff80067c5..c753806518 100644
--- a/tests/auto/v8/tst_v8.cpp
+++ b/tests/auto/v8/tst_v8.cpp
@@ -55,6 +55,7 @@ private slots:
void cleanupTestCase() {}
void eval();
+ void evalwithinwith();
void userobjectcompare();
};
@@ -63,6 +64,11 @@ void tst_v8::eval()
QVERIFY(v8test_eval());
}
+void tst_v8::evalwithinwith()
+{
+ QVERIFY(v8test_evalwithinwith());
+}
+
void tst_v8::userobjectcompare()
{
QVERIFY(v8test_userobjectcompare());
diff --git a/tests/auto/v8/v8main.cpp b/tests/auto/v8/v8main.cpp
index fa0137938e..76d326aa3f 100644
--- a/tests/auto/v8/v8main.cpp
+++ b/tests/auto/v8/v8main.cpp
@@ -11,6 +11,7 @@ int main(int argc, char *argv[])
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
RUN_TEST(eval);
+ RUN_TEST(evalwithinwith);
RUN_TEST(userobjectcompare);
return -1;
diff --git a/tests/auto/v8/v8test.cpp b/tests/auto/v8/v8test.cpp
index a712bf12b4..0b299ed23c 100644
--- a/tests/auto/v8/v8test.cpp
+++ b/tests/auto/v8/v8test.cpp
@@ -81,6 +81,49 @@ cleanup:
ENDTEST();
}
+bool v8test_evalwithinwith()
+{
+ BEGINTEST();
+
+ HandleScope handle_scope;
+ Persistent<Context> context = Context::New();
+ Context::Scope context_scope(context);
+
+ Local<Object> qmlglobal = Object::New();
+ qmlglobal->Set(String::New("a"), Integer::New(1922));
+ // There was a bug that the "eval" lookup would incorrectly resolve
+ // to the QML global object
+ qmlglobal->Set(String::New("eval"), Integer::New(1922));
+
+#define SOURCE \
+ "(function() { " \
+ " var b = { c: 10 }; " \
+ " with (b) { " \
+ " return eval(\"a\"); " \
+ " } " \
+ "})"
+ Local<Script> script = Script::Compile(String::New(SOURCE), NULL, NULL,
+ Handle<String>(), Script::QmlMode);
+#undef SOURCE
+
+ TryCatch tc;
+ Local<Value> result = script->Run(qmlglobal);
+
+ VERIFY(!tc.HasCaught());
+ VERIFY(result->IsFunction());
+
+ {
+ Local<Value> fresult = Handle<Function>::Cast(result)->Call(context->Global(), 0, 0);
+ VERIFY(!tc.HasCaught());
+ VERIFY(fresult->Int32Value() == 1922);
+ }
+
+cleanup:
+ context.Dispose();
+
+ ENDTEST();
+}
+
static int userObjectComparisonCalled = 0;
static bool userObjectComparisonReturn = false;
static Local<Object> expectedLhs;
diff --git a/tests/auto/v8/v8test.h b/tests/auto/v8/v8test.h
index 812036dd66..fa9bbe9f02 100644
--- a/tests/auto/v8/v8test.h
+++ b/tests/auto/v8/v8test.h
@@ -49,6 +49,7 @@
#endif
bool v8test_eval();
+bool v8test_evalwithinwith();
bool v8test_userobjectcompare();
#endif // V8TEST_H