diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-11 12:03:28 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-11 12:03:28 (GMT) |
commit | 73a86eaf8136959cbac60af540ee8faadf454015 (patch) | |
tree | 28d107e106c4b00033bba2eadd325a7fef1569b4 /tests/auto/qscriptcontext | |
parent | f2f338a922d20ad36c9849f5ea3208a8c4f1674a (diff) | |
download | Qt-73a86eaf8136959cbac60af540ee8faadf454015.zip Qt-73a86eaf8136959cbac60af540ee8faadf454015.tar.gz Qt-73a86eaf8136959cbac60af540ee8faadf454015.tar.bz2 |
make it possible to pop all items in a scope chain and then push to it
A lot of the JSC::ExecState functions rely on scopeChain() not
being 0. This means we shouldn't pop the scope chain if doing so
would make it empty; otherwise when you call e.g. pushScope() or
evaluate(), you will crash. So instead of popping the chain
completely, we now set the sole scope chain item's object pointer to
0 and add appropriate checks elsewhere.
A second issue, not solved in this commit, is that JSC expects
the Global Object to always be the last item in every scope
chain. If it's not, you will crash.
Diffstat (limited to 'tests/auto/qscriptcontext')
-rw-r--r-- | tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index be0b2b7..c8b21a5 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -674,19 +674,19 @@ void tst_QScriptContext::pushAndPopScope() ctx->pushScope(QScriptValue()); QCOMPARE(ctx->scopeChain().size(), 1); - qWarning("Popping the top-level scope causes crash"); -#if 0 QVERIFY(ctx->popScope().strictlyEquals(eng.globalObject())); QVERIFY(ctx->scopeChain().isEmpty()); -#endif ctx->pushScope(obj); - QCOMPARE(ctx->scopeChain().size(), 2); + 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()); QScriptEngine eng2; @@ -695,10 +695,8 @@ void tst_QScriptContext::pushAndPopScope() ctx->pushScope(obj2); QVERIFY(ctx->popScope().strictlyEquals(obj)); - QEXPECT_FAIL("", "This should work once the above crash issue has been fixed", Continue); QVERIFY(ctx->scopeChain().isEmpty()); - QSKIP("Crashes", SkipAll); QVERIFY(!ctx->popScope().isValid()); } |