Commit f91dba12 authored by Kent Hansen's avatar Kent Hansen Committed by Qt by Nokia

Use the same ReferenceError message wording as V8

Instead of "Can't find variable: foo", use "foo is not defined".

This is in preparation of letting V8 throw the exception when a
property lookup fails on the QML scope object (needed for
QTBUG-24448).

Change-Id: I3c747482a8ef138dad9a85530a4f6b5c4c818a03
Reviewed-by: default avatarAaron Kennedy <aaron.kennedy@nokia.com>
parent a06936e5
......@@ -245,7 +245,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::NullGetter(v8::Local<v8::String> proper
QV8Engine *engine = resource->engine;
QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
QString error = engine->toString(property) + QLatin1String(" is not defined");
v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
return v8::Undefined();
}
......@@ -365,7 +365,7 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
expressionContext->unresolvedNames = true;
QString error = QLatin1String("Can't find variable: ") + engine->toString(property);
QString error = engine->toString(property) + QLatin1String(" is not defined");
v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
return v8::Undefined();
}
......
......@@ -617,7 +617,7 @@ void tst_qqmlcontext::refreshExpressionsRootContext()
QQmlContext context(engine.rootContext());
QQmlContext context2(engine.rootContext());
QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName");
QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: unresolvedName is not defined");
QObject *o1 = component.create(&context);
......
......@@ -1416,10 +1416,10 @@ void tst_qqmlecmascript::scriptErrors()
QString url = component.url().toString();
QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
QString warning2 = url + ":5: ReferenceError: a is not defined";
QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
QString warning4 = url + ":13: ReferenceError: Can't find variable: a";
QString warning5 = url + ":11: ReferenceError: Can't find variable: a";
QString warning4 = url + ":13: ReferenceError: a is not defined";
QString warning5 = url + ":11: ReferenceError: a is not defined";
QString warning6 = url + ":10: Unable to assign [undefined] to int";
QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
......@@ -3216,7 +3216,7 @@ void tst_qqmlecmascript::importScripts_data()
QTest::newRow("javascript imports in an import should be private to the import scope")
<< testFileUrl("jsimportfail/failTwo.qml")
<< QString()
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: ImportOneJs is not defined")))
<< (QStringList() << QLatin1String("importScriptFunctionValue"))
<< (QVariantList() << QVariant(QString()));
......@@ -3230,14 +3230,14 @@ void tst_qqmlecmascript::importScripts_data()
QTest::newRow("typenames in an import should be private to the import scope")
<< testFileUrl("jsimportfail/failFour.qml")
<< QString()
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: JsQtTest is not defined")))
<< (QStringList() << QLatin1String("importedModuleEnumValue"))
<< (QVariantList() << QVariant(0));
QTest::newRow("import with imports has it's own activation scope")
<< testFileUrl("jsimportfail/failFive.qml")
<< QString()
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component")))
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Component is not defined")))
<< (QStringList() << QLatin1String("componentError"))
<< (QVariantList() << QVariant(0));
......@@ -3251,7 +3251,7 @@ void tst_qqmlecmascript::importScripts_data()
QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
<< testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
<< QString()
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
<< (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Component is not defined")))
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(0));
......@@ -5378,7 +5378,7 @@ void tst_qqmlecmascript::typeOf()
// These warnings should not happen once QTBUG-21864 is fixed
QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString");
QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a");
QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: a is not defined");
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
......@@ -5550,9 +5550,9 @@ void tst_qqmlecmascript::revisionErrors()
QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
QString url = component.url().toString();
QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2";
QString warning3 = url + ":13: ReferenceError: Can't find variable: method2";
QString warning1 = url + ":8: ReferenceError: prop2 is not defined";
QString warning2 = url + ":11: ReferenceError: prop2 is not defined";
QString warning3 = url + ":13: ReferenceError: method2 is not defined";
QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
......@@ -5568,11 +5568,11 @@ void tst_qqmlecmascript::revisionErrors()
// MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
// method2, prop2 from MyRevisionedClass not available
// method4, prop4 from MyRevisionedSubclass not available
QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2";
QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4";
QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4";
QString warning5 = url + ":20: ReferenceError: Can't find variable: method2";
QString warning1 = url + ":8: ReferenceError: prop2 is not defined";
QString warning2 = url + ":14: ReferenceError: prop2 is not defined";
QString warning3 = url + ":10: ReferenceError: prop4 is not defined";
QString warning4 = url + ":16: ReferenceError: prop4 is not defined";
QString warning5 = url + ":20: ReferenceError: method2 is not defined";
QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
......@@ -5589,9 +5589,9 @@ void tst_qqmlecmascript::revisionErrors()
// MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
// All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1
QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD";
QString warning2 = url + ":10: ReferenceError: Can't find variable: propD";
QString warning3 = url + ":20: ReferenceError: Can't find variable: propD";
QString warning1 = url + ":30: ReferenceError: methodD is not defined";
QString warning2 = url + ":10: ReferenceError: propD is not defined";
QString warning3 = url + ":20: ReferenceError: propD is not defined";
QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
......
......@@ -275,7 +275,7 @@ void tst_QQuickWorkerScript::scriptError_onCall()
QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
QTRY_COMPARE(qquickworkerscript_lastWarning,
testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: getData is not defined"));
qInstallMsgHandler(previousMsgHandler);
qApp->processEvents();
......
......@@ -612,12 +612,12 @@ void tst_qquickvisualdatamodel::modelProperties()
QUrl source(testFileUrl("modelproperties2.qml"));
//3 items, 3 i each
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: modelData is not defined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: modelData is not defined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: modelData is not defined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: modelData is not defined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: modelData is not defined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: modelData is not defined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment