diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-06-10 15:06:03 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-06-13 15:08:35 +0000 |
commit | ca6762abde85fe3104ec4f064b85319474ba2deb (patch) | |
tree | 00302c342376f345b454c9e6cbb52ff40e45d9c4 /tests | |
parent | c7aeb3b03ecce75c40d3f53352e8b7b3a4d6d050 (diff) |
Fix the IPC webChannelTransport not being available on reload
The gin JavaScript binging gets destroyed on page reload
after all references to it disappear from the previous document.
Do like other gin wrapper and reinstall the transport binding on
DidCreateDocumentElement, following how it's done by the
MojoBindingsController.
Task-number: QTBUG-53411
Change-Id: Ibcd9ef9dbedc5762d4f2210fd81f68e5b9127680
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'tests')
-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" |