summaryrefslogtreecommitdiffstats
path: root/tests/auto/v8
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/v8')
-rw-r--r--tests/auto/v8/tst_v8.cpp6
-rw-r--r--tests/auto/v8/v8main.cpp42
-rw-r--r--tests/auto/v8/v8test.cpp43
-rw-r--r--tests/auto/v8/v8test.h1
4 files changed, 92 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..b38bbabbd5 100644
--- a/tests/auto/v8/v8main.cpp
+++ b/tests/auto/v8/v8main.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "v8test.h"
#include <stdio.h>
@@ -11,6 +52,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