summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 7c58d93a4..07fb2eab9 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -758,19 +758,38 @@ void tst_QWebEnginePage::textSelection()
void tst_QWebEnginePage::backActionUpdate()
{
QWebEngineView view;
+ view.resize(640, 480);
+ view.show();
+
QWebEnginePage *page = view.page();
+ QSignalSpy loadSpy(page, &QWebEnginePage::loadFinished);
QAction *action = page->action(QWebEnginePage::Back);
QVERIFY(!action->isEnabled());
- QSignalSpy loadSpy(page, SIGNAL(loadFinished(bool)));
- QUrl url = QUrl("qrc:///resources/framedindex.html");
- page->load(url);
+
+ page->load(QUrl("qrc:///resources/framedindex.html"));
QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000);
QVERIFY(!action->isEnabled());
- QTest::mouseClick(&view, Qt::LeftButton, 0, QPoint(10, 10));
- QEXPECT_FAIL("", "Behavior change: Load signals are emitted only for the main frame in QtWebEngine.", Continue);
- QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 2, 100);
- QEXPECT_FAIL("", "FIXME: Mouse events aren't passed from the QWebEngineView down to the RWHVQtDelegateWidget", Continue);
+ auto firstAnchorCenterInFrame = [](QWebEnginePage *page, const QString &frameName) {
+ QVariantList rectList = evaluateJavaScriptSync(page,
+ "(function(){"
+ "var frame = document.getElementsByName('" + frameName + "')[0];"
+ "var anchor = frame.contentDocument.getElementsByTagName('a')[0];"
+ "var rect = anchor.getBoundingClientRect();"
+ "return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];"
+ "})()").toList();
+
+ if (rectList.count() != 2) {
+ qWarning("firstAnchorCenterInFrame failed.");
+ return QPoint();
+ }
+
+ return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt());
+ };
+
+ QVERIFY(evaluateJavaScriptSync(page, "document.getElementsByName('frame_b')[0].contentDocument == undefined").toBool());
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, firstAnchorCenterInFrame(page, "frame_c"));
+ QTRY_VERIFY(evaluateJavaScriptSync(page, "document.getElementsByName('frame_b')[0].contentDocument != undefined").toBool());
QVERIFY(action->isEnabled());
}