@@ -1327,20 +1327,39 @@ void tst_QWebEnginePage::textEditing()
1327
1327
void tst_QWebEnginePage::backActionUpdate ()
1328
1328
{
1329
1329
QWebEngineView view;
1330
+ view.resize (640 , 480 );
1331
+ view.show ();
1332
+
1330
1333
QWebEnginePage *page = view.page ();
1334
+ QSignalSpy loadSpy (page, &QWebEnginePage::loadFinished);
1331
1335
QAction *action = page->action (QWebEnginePage::Back);
1332
1336
QVERIFY (!action->isEnabled ());
1333
- QSignalSpy loadSpy (page, SIGNAL (loadFinished (bool )));
1334
- QUrl url = QUrl (" qrc:///resources/framedindex.html" );
1335
- page->load (url);
1336
- QTRY_COMPARE (loadSpy.count (), 1 );
1337
+
1338
+ page->load (QUrl (" qrc:///resources/framedindex.html" ));
1339
+ QTRY_COMPARE_WITH_TIMEOUT (loadSpy.count (), 1 , 20000 );
1337
1340
QVERIFY (!action->isEnabled ());
1338
- QTest::mouseClick (&view, Qt::LeftButton, 0 , QPoint (10 , 10 ));
1339
- QEXPECT_FAIL (" " , " Behavior change: Load signals are emitted only for the main frame in QtWebEngine." , Continue);
1340
- QTRY_COMPARE_WITH_TIMEOUT (loadSpy.count (), 2 , 100 );
1341
1341
1342
- QEXPECT_FAIL (" " , " FIXME: Mouse events aren't passed from the QWebEngineView down to the RWHVQtDelegateWidget" , Continue);
1343
- QVERIFY (action->isEnabled ());
1342
+ auto firstAnchorCenterInFrame = [](QWebEnginePage *page, const QString &frameName) {
1343
+ QVariantList rectList = evaluateJavaScriptSync (page,
1344
+ " (function(){"
1345
+ " var frame = document.getElementsByName('" + frameName + " ')[0];"
1346
+ " var anchor = frame.contentDocument.getElementsByTagName('a')[0];"
1347
+ " var rect = anchor.getBoundingClientRect();"
1348
+ " return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];"
1349
+ " })()" ).toList ();
1350
+
1351
+ if (rectList.count () != 2 ) {
1352
+ qWarning (" firstAnchorCenterInFrame failed." );
1353
+ return QPoint ();
1354
+ }
1355
+
1356
+ return QPoint (rectList.at (0 ).toInt (), rectList.at (1 ).toInt ());
1357
+ };
1358
+
1359
+ QVERIFY (evaluateJavaScriptSync (page, " document.getElementsByName('frame_b')[0].contentDocument == undefined" ).toBool ());
1360
+ QTest::mouseClick (view.focusProxy (), Qt::LeftButton, 0 , firstAnchorCenterInFrame (page, " frame_c" ));
1361
+ QTRY_VERIFY (evaluateJavaScriptSync (page, " document.getElementsByName('frame_b')[0].contentDocument != undefined" ).toBool ());
1362
+ QTRY_VERIFY (action->isEnabled ());
1344
1363
}
1345
1364
1346
1365
#if defined(QWEBENGINEPAGE_SETTINGS)
0 commit comments