diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-12-07 11:20:07 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-12-07 15:53:21 +0100 |
commit | c8d98dc206714abd5c0dc76008ffa729973d3a8f (patch) | |
tree | f57120bd95ff0762fd7c5059c297f2c38da80a6f /tests/auto | |
parent | 33c87736db7ec79c89c0497192727697d126628d (diff) |
Allow the QML console methods to be called from outside JS
There may not be a stack frame and that is OK.
Change-Id: Iccac4db1530c9a4b316905a3a283d36674c146a8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 15 | ||||
-rw-r--r-- | tests/auto/qml/qjsvalue/tst_qjsvalue.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 6e91cec474..94068bfa12 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -2756,4 +2756,19 @@ void tst_QJSValue::stringAndUrl() QCOMPARE(engine.fromScriptValue<QUrl>(immediateStringValue), url); } +void tst_QJSValue::jsFunctionInVariant() +{ + QJSEngine engine; + engine.installExtensions(QJSEngine::ConsoleExtension); + QJSValue console = engine.globalObject().property("console"); + QVERIFY(console.isObject()); + QJSValue log = console.property("log"); + QVERIFY(log.isCallable()); + + { + QTest::ignoreMessage(QtDebugMsg, "direct call"); + log.callWithInstance(console, {"direct call"}); + } +} + QTEST_MAIN(tst_QJSValue) diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h index f6e3c2aacf..a291e156e0 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h @@ -145,6 +145,7 @@ private slots: void deleteFromDifferentThread(); void stringAndUrl(); + void jsFunctionInVariant(); private: void newEngine() |