diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2018-05-17 13:16:27 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2018-05-18 14:11:04 +0000 |
commit | e11d897bd2a87d4d3870fdc4b3c120cd1f15231d (patch) | |
tree | e4a2ce94926537287dbd3171d509bff303bff126 /tests | |
parent | 0559bc08aae56a6a5846120d86d62ddbca5ca4b9 (diff) |
Test runJavaScript without JavascriptEnabled
Change-Id: I5fef99d3674fe4dee43df79d740988853d144abd
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 8d0d5c43c..8b88973e5 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -159,6 +159,7 @@ private Q_SLOTS: #endif void runJavaScript(); + void runJavaScriptDisabled(); void fullScreenRequested(); void quotaRequested(); @@ -2714,6 +2715,21 @@ void tst_QWebEnginePage::runJavaScript() QVERIFY(watcher.wait()); } +void tst_QWebEnginePage::runJavaScriptDisabled() +{ + QWebEnginePage page; + QSignalSpy spy(&page, &QWebEnginePage::loadFinished); + page.settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false); + // Settings changes take effect asynchronously. The load and wait ensure + // that the settings are applied by the time we start to execute JavaScript. + page.load(QStringLiteral("about:blank")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(evaluateJavaScriptSyncInWorld(&page, QStringLiteral("1+1"), QWebEngineScript::MainWorld), + QVariant()); + QCOMPARE(evaluateJavaScriptSyncInWorld(&page, QStringLiteral("1+1"), QWebEngineScript::ApplicationWorld), + QVariant(2)); +} + void tst_QWebEnginePage::fullScreenRequested() { JavaScriptCallbackWatcher watcher; |