summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-14 15:01:42 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-14 15:08:03 (GMT)
commit034d7d1c0893fe2b25379b109a82325fac96f0d1 (patch)
treec9afb9818474964c43e0c76205f3f821546f6706 /tests
parent7c1e089fd3d2560322e643c6c1c3b1e73bf04c98 (diff)
downloadQt-034d7d1c0893fe2b25379b109a82325fac96f0d1.zip
Qt-034d7d1c0893fe2b25379b109a82325fac96f0d1.tar.gz
Qt-034d7d1c0893fe2b25379b109a82325fac96f0d1.tar.bz2
push the right object when the argument is the Global Object
Since the internal Global Object is never exposed to the public, we need to do like we do in setActivationObject(): if the object passed is the Global Object proxy, use the internal Global Object as the "real" argument. (JSC requires that the initial object pushed onto the scope chain is an instance of JSC::JSGlobalObject, and the Global Object proxy is not; hence, we can't push the proxy.)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 2f96ea0..17d57a3 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -709,6 +709,11 @@ void tst_QScriptContext::pushAndPopScope()
QCOMPARE(ctx->scopeChain().size(), 1);
QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject()));
+ QVERIFY(ctx->popScope().strictlyEquals(eng.globalObject()));
+ ctx->pushScope(eng.globalObject());
+ QCOMPARE(ctx->scopeChain().size(), 1);
+ QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject()));
+
QScriptValue obj = eng.newObject();
ctx->pushScope(obj);
QCOMPARE(ctx->scopeChain().size(), 2);
@@ -758,24 +763,16 @@ void tst_QScriptContext::pushAndPopScope()
QVERIFY(ctx->popScope().strictlyEquals(eng.globalObject()));
QVERIFY(ctx->scopeChain().isEmpty());
+ // Used to work with old back-end, doesn't with new one because JSC requires that the last object in
+ // a scope chain is the Global Object.
+ QTest::ignoreMessage(QtWarningMsg, "QScriptContext::pushScope() failed: initial object in scope chain has to be the Global Object");
ctx->pushScope(obj);
- QCOMPARE(ctx->scopeChain().size(), 1);
- QVERIFY(ctx->scopeChain().at(0).strictlyEquals(obj));
- QVERIFY(!obj.property("foo").isValid());
-#if 0 // ### CRASHES, JSC expects last scope object to always be the Global Object
- eng.evaluate("function foo() {}");
- // function declarations should always end up in the activation object (ECMA-262, chapter 13)
- QVERIFY(!obj.property("foo").isValid());
-#endif
- QEXPECT_FAIL("", "JSC requires last object in scope chain to be the Global Object", Continue);
- QVERIFY(ctx->activationObject().property("foo").isFunction());
+ QCOMPARE(ctx->scopeChain().size(), 0);
QScriptEngine eng2;
QScriptValue obj2 = eng2.newObject();
QTest::ignoreMessage(QtWarningMsg, "QScriptContext::pushScope() failed: cannot push an object created in a different engine");
ctx->pushScope(obj2);
-
- QVERIFY(ctx->popScope().strictlyEquals(obj));
QVERIFY(ctx->scopeChain().isEmpty());
QVERIFY(!ctx->popScope().isValid());