aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-02-04 15:44:14 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2022-05-07 22:36:11 +0100
commit0e88794676660166aaf327089eaaa1aff902a317 (patch)
treee4f580447ee4c37a7d0080c48546e11a3185c4f8 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
parente12c9455a04aecc6334bdbad755b232c1dccdce6 (diff)
QML/JS: Reject yield expression not directly in generator functions
If an inner function contains a yield expression, we need to reject the program even if that function is inside of a generator function. Fixes: QTBUG-98356 Change-Id: I2e820a1ca5f0da4080e313fd9809aa8bfdc1b681 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit dde1d86baabac1eddd84a11b7d2ed49e26c511bd)
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 696566d987..2291c31895 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -241,6 +241,7 @@ private slots:
void topLevelGeneratorFunction();
void generatorCrashNewProperty();
void generatorCallsGC();
+ void noYieldInInnerFunction();
void qtbug_10696();
void qtbug_11606();
void qtbug_11600();
@@ -6516,6 +6517,19 @@ void tst_qqmlecmascript::generatorCallsGC()
QVERIFY2(o != nullptr, qPrintable(component.errorString()));
}
+void tst_qqmlecmascript::noYieldInInnerFunction()
+{
+ QJSEngine engine;
+ const QString program = R"(
+ function *a() {
+ (function() { yield 1; })();
+ };
+ )";
+ auto result = engine.evaluate(program);
+ QVERIFY(result.isError());
+ QCOMPARE(result.errorType(), QJSValue::SyntaxError);
+}
+
// Test the "Qt.include" method
void tst_qqmlecmascript::include()
{