diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-12 07:49:03 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-12 07:49:03 +0200 |
commit | a9ac6da893ac10ce160c9eb80141508881cd71e2 (patch) | |
tree | 0e74067407612d44ad07ff74cb7be6d444ee28c5 /tests/auto/v8/v8test.cpp | |
parent | 8eb5ba3b9cb1e8e07f28a3153672a946b2d82fd9 (diff) | |
parent | 687461627310e8b781da15d1a907c35bd8ffea6e (diff) |
Merge branch 'master' into refactor
Conflicts:
src/3rdparty/v8
src/gui/text/qfont_qpa.cpp
src/gui/widgets/qlinecontrol.cpp
src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
tests/auto/gui.pro
tests/auto/network.pro
tests/auto/qstring/tst_qstring.cpp
Change-Id: Id118c172645303ccf06a207050d5bf1462ff57fe
Diffstat (limited to 'tests/auto/v8/v8test.cpp')
-rw-r--r-- | tests/auto/v8/v8test.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
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; |