diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-10 11:07:24 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-04-11 08:59:37 +0000 |
commit | 8780764b274217b256aadd00114a76bdffbdb1ef (patch) | |
tree | 9629fd8c29fd32fb9397452a2132f368a9d2df89 /tests | |
parent | e185d303839f2a8bb0e5769ba465b971ae354bd5 (diff) |
Warn about non spec compliant extension being used
eval("function(){}") would return a function object in our engine.
This is not compliant with the ES spec, so warn about it, as it'll
start throwing a syntax error in 5.12.
Also fix the two places where we were using that syntax in our auto
tests.
Change-Id: I573c2ad0ec4955570b857c69edef2f75998d55a9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 0455895c14..e62e4a0980 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -2996,7 +2996,7 @@ void tst_QJSEngine::arraySort() void tst_QJSEngine::lookupOnDisappearingProperty() { QJSEngine eng; - QJSValue func = eng.evaluate("(function(){\"use strict\"; return eval(\"function(obj) { return obj.someProperty; }\")})()"); + QJSValue func = eng.evaluate("(function(){\"use strict\"; return eval(\"(function(obj) { return obj.someProperty; })\")})()"); QVERIFY(func.isCallable()); QJSValue o = eng.newObject(); @@ -3341,7 +3341,7 @@ void tst_QJSEngine::prototypeChainGc() QJSValue getProto = engine.evaluate("Object.getPrototypeOf"); - QJSValue factory = engine.evaluate("function() { return Object.create(Object.create({})); }"); + QJSValue factory = engine.evaluate("(function() { return Object.create(Object.create({})); })"); QVERIFY(factory.isCallable()); QJSValue obj = factory.call(); engine.collectGarbage(); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 18b1718ddf..8913528d79 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -2131,7 +2131,7 @@ void tst_qqmllanguage::scriptStringJs() QVERIFY(!object->scriptProperty().booleanLiteral(&ok) && !ok); QJSValue inst = engine.newQObject(object.data()); - QJSValue func = engine.evaluate("function(value) { this.scriptProperty = value }"); + QJSValue func = engine.evaluate("(function(value) { this.scriptProperty = value })"); func.callWithInstance(inst, QJSValueList() << "test a \"string "); QCOMPARE(QQmlScriptStringPrivate::get(object->scriptProperty())->script, QString("\"test a \\\"string \"")); @@ -2263,7 +2263,7 @@ void tst_qqmllanguage::scriptStringComparison() //QJSValue inst1 = engine.newQObject(object1); QJSValue inst2 = engine.newQObject(object2.data()); QJSValue inst3 = engine.newQObject(object3.data()); - QJSValue func = engine.evaluate("function(value) { this.scriptProperty = value }"); + QJSValue func = engine.evaluate("(function(value) { this.scriptProperty = value })"); const QString s = "hello\\n\\\"world\\\""; const qreal n = 12.345; |