aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcachegen
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-08-26 11:48:48 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-08-26 12:42:05 +0200
commit4b944cb61fb3ceee2f1b743823e4a83b686bafd6 (patch)
tree856154bc1e90be7cdd41fdadcfe1994315e03f9d /tests/auto/qml/qmlcachegen
parent4d080635872fbb77a2adfb736d3f108b62cc058a (diff)
Fix loading of ES modules when using CONFIG += qtquickcompiler
Added the missing lookup for cached .mjs files in ExecutionEngine::compileModule. This allows using .mjs files in WorkerScript {} elements in conjunction with the Qt Quick Compiler and also fixes the use when using QJSEngine::importModule. [ChangeLog][QtQml] Fix loading of EcmaScript modules when using the Qt Quick Compiler. Fixes: QTBUG-77761 Change-Id: I58130b0468f4920b2f6c49b98a2f51d5ae3a0491 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcachegen')
-rw-r--r--tests/auto/qml/qmlcachegen/data/module.mjs6
-rw-r--r--tests/auto/qml/qmlcachegen/data/utils.mjs4
-rw-r--r--tests/auto/qml/qmlcachegen/qmlcachegen.pro4
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp10
4 files changed, 23 insertions, 1 deletions
diff --git a/tests/auto/qml/qmlcachegen/data/module.mjs b/tests/auto/qml/qmlcachegen/data/module.mjs
new file mode 100644
index 0000000000..6838766329
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/data/module.mjs
@@ -0,0 +1,6 @@
+
+import { helper } from "utils.mjs"
+
+export function entry() {
+ return helper()
+}
diff --git a/tests/auto/qml/qmlcachegen/data/utils.mjs b/tests/auto/qml/qmlcachegen/data/utils.mjs
new file mode 100644
index 0000000000..25a1f38709
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/data/utils.mjs
@@ -0,0 +1,4 @@
+
+export function helper() {
+ return "ok"
+}
diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
index 7f8e93d101..ec1ec10ec1 100644
--- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro
+++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
@@ -15,7 +15,9 @@ RESOURCES += \
data/Enums.qml \
data/componentInItem.qml \
data/jsmoduleimport.qml \
- data/script.mjs
+ data/script.mjs \
+ data/module.mjs \
+ data/utils.mjs
workerscripts_test.files = \
data/worker.js \
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index e290f21986..27314d815b 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -63,6 +63,7 @@ private slots:
void qrcScriptImport();
void fsScriptImport();
void moduleScriptImport();
+ void esModulesViaQJSEngine();
void enums();
@@ -596,6 +597,15 @@ void tst_qmlcachegen::moduleScriptImport()
}
}
+void tst_qmlcachegen::esModulesViaQJSEngine()
+{
+ QCOMPARE(QFileInfo(":/data/module.mjs").size(), 0);
+ QJSEngine engine;
+ QJSValue module = engine.importModule(":/data/module.mjs");
+ QJSValue result = module.property("entry").call();
+ QCOMPARE(result.toString(), "ok");
+}
+
void tst_qmlcachegen::enums()
{
QQmlEngine engine;