diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp')
-rw-r--r-- | JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp index 90730c3..27d6df2 100644 --- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp @@ -431,6 +431,46 @@ void tst_QScriptValue::call() QVERIFY(incr.call().isValid()); // Exception. } +void tst_QScriptValue::getSetPrototype() +{ + QScriptEngine engine; + QScriptValue object = engine.evaluate("new Object()"); + QScriptValue object2 = engine.evaluate("new Object()"); + object2.setPrototype(object); + QCOMPARE(object2.prototype().strictlyEquals(object), true); + + QScriptValue inv; + inv.setPrototype(object); + QCOMPARE(inv.prototype().isValid(), false); + + QScriptEngine otherEngine; + QScriptValue object3 = otherEngine.evaluate("new Object()"); + QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setPrototype() failed: cannot set a prototype created in a different engine"); + object2.setPrototype(object3); + QCOMPARE(object2.prototype().strictlyEquals(object), true); + + // cyclic prototypes + { + QScriptValue ret = engine.evaluate("o = { }; p = { }; o.__proto__ = p; p.__proto__ = o"); + QCOMPARE(ret.isError(), true); + QCOMPARE(ret.toString(), QLatin1String("Error: cyclic __proto__ value")); + } + { + QScriptValue ret = engine.evaluate("p.__proto__ = { }"); + QCOMPARE(ret.isError(), false); + } + + QScriptValue old = object.prototype(); + QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setPrototype() failed: cyclic prototype value"); + object.setPrototype(object); + QCOMPARE(object.prototype().strictlyEquals(old), true); + + object2.setPrototype(object); + QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setPrototype() failed: cyclic prototype value"); + object.setPrototype(object2); + QCOMPARE(object.prototype().strictlyEquals(old), true); +} + void tst_QScriptValue::toObjectSimple() { QScriptEngine eng; |