diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-06-20 13:38:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-06-20 18:27:44 +0200 |
commit | 25ccef35eb19fd656eba2a7abe5419972ed28552 (patch) | |
tree | e0c92532c3c70135d0a547675414e95d21a66822 /tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp | |
parent | 3398abfc1b5b789d11592aada0b5860e36a50041 (diff) | |
parent | e91f09947b55dda8a13b2aeb0963836dee2ece8d (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
src/3rdparty
src/core/permission_manager_qt.cpp
src/core/renderer/web_channel_ipc_transport.cpp
src/core/renderer/web_channel_ipc_transport.h
Change-Id: I25fd8ed7c433dadce44d8ac1e39f86e211ec25f0
Diffstat (limited to 'tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp')
-rw-r--r-- | tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index ad10234f4..d5ecd8841 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -37,6 +37,7 @@ private Q_SLOTS: void scriptModifications(); void webChannel_data(); void webChannel(); + void noTransportWithoutWebChannel(); }; void tst_QWebEngineScript::domEditing() @@ -180,13 +181,17 @@ private: void tst_QWebEngineScript::webChannel_data() { QTest::addColumn<int>("worldId"); - QTest::newRow("MainWorld") << static_cast<int>(QWebEngineScript::MainWorld); - QTest::newRow("ApplicationWorld") << static_cast<int>(QWebEngineScript::ApplicationWorld); + QTest::addColumn<bool>("reloadFirst"); + QTest::newRow("MainWorld") << static_cast<int>(QWebEngineScript::MainWorld) << false; + QTest::newRow("ApplicationWorld") << static_cast<int>(QWebEngineScript::ApplicationWorld) << false; + QTest::newRow("MainWorldWithReload") << static_cast<int>(QWebEngineScript::MainWorld) << true; + QTest::newRow("ApplicationWorldWithReload") << static_cast<int>(QWebEngineScript::ApplicationWorld) << true; } void tst_QWebEngineScript::webChannel() { QFETCH(int, worldId); + QFETCH(bool, reloadFirst); QWebEnginePage page; TestObject testObject; QScopedPointer<QWebChannel> channel(new QWebChannel(this)); @@ -205,6 +210,11 @@ void tst_QWebEngineScript::webChannel() page.scripts().insert(script); page.setHtml(QStringLiteral("<html><body></body></html>")); waitForSignal(&page, SIGNAL(loadFinished(bool))); + if (reloadFirst) { + // Check that the transport is also reinstalled on navigation + page.triggerAction(QWebEnginePage::Reload); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + } page.runJavaScript(QLatin1String( "new QWebChannel(qt.webChannelTransport," " function(channel) {" @@ -218,6 +228,17 @@ void tst_QWebEngineScript::webChannel() QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid)); } +void tst_QWebEngineScript::noTransportWithoutWebChannel() +{ + QWebEnginePage page; + page.setHtml(QStringLiteral("<html><body></body></html>")); + + QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid)); + page.triggerAction(QWebEnginePage::Reload); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid)); +} + QTEST_MAIN(tst_QWebEngineScript) #include "tst_qwebenginescript.moc" |