diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_download.qml | 35 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_filePicker.qml | 116 | ||||
-rw-r--r-- | tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp | 14 | ||||
-rw-r--r-- | tests/auto/widgets/proxypac/tst_proxypac.cpp | 4 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/BLACKLIST | 4 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 10 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp | 28 | ||||
-rw-r--r-- | tests/auto/widgets/qwebengineview/BLACKLIST | 3 | ||||
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 34 | ||||
-rw-r--r-- | tests/auto/widgets/widgets.pro | 5 |
10 files changed, 210 insertions, 43 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml index c38018ffd..e049f3621 100644 --- a/tests/auto/quick/qmltests/data/tst_download.qml +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -47,6 +47,7 @@ TestWebEngineView { property string downloadDirectory: "" property string downloadFileName: "" property string downloadedPath: "" + property string downloadedSetPath: "" property int downloadDirectoryChanged: 0 property int downloadFileNameChanged: 0 property int downloadPathChanged: 0 @@ -94,14 +95,19 @@ TestWebEngineView { } else { totalBytes = download.totalBytes - download.downloadDirectory = downloadDirectory.length != 0 ? testDownloadProfile.downloadPath + downloadDirectory : testDownloadProfile.downloadPath - download.downloadFileName = downloadFileName.length != 0 ? downloadFileName : "testfile.zip" + if (downloadedSetPath.length != 0) { + download.path = testDownloadProfile.downloadPath + downloadedSetPath + downloadedPath = download.path + } else { + download.downloadDirectory = downloadDirectory.length != 0 ? testDownloadProfile.downloadPath + downloadDirectory : testDownloadProfile.downloadPath + download.downloadFileName = downloadFileName.length != 0 ? downloadFileName : "testfile.zip" + downloadedPath = download.downloadDirectory + download.downloadFileName + } download.accept() } downloadUrl = download.url suggestedFileName = download.suggestedFileName - downloadedPath = download.downloadDirectory + download.downloadFileName } onDownloadFinished: { receivedBytes = download.receivedBytes; @@ -126,6 +132,7 @@ TestWebEngineView { downloadDirectory = "" downloadFileName = "" downloadedPath = "" + downloadedSetPath = "" } function test_downloadRequest() { @@ -211,5 +218,27 @@ TestWebEngineView { tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted); verify(!downloadInterruptReason); } + + function test_downloadWithSetPath() { + compare(downLoadRequestedSpy.count, 0); + compare(downloadDirectoryChanged, 0); + compare(downloadFileNameChanged, 0); + downloadedSetPath = "/test/test.zip"; + webEngineView.url = Qt.resolvedUrl("download.zip"); + downLoadRequestedSpy.wait(); + compare(downLoadRequestedSpy.count, 1); + compare(downloadUrl, webEngineView.url); + compare(suggestedFileName, "download.zip"); + compare(downloadState[0], WebEngineDownloadItem.DownloadRequested); + tryCompare(downloadState, "1", WebEngineDownloadItem.DownloadInProgress); + compare(downloadedPath, testDownloadProfile.downloadPath + downloadedSetPath); + compare(downloadDirectoryChanged, 1); + compare(downloadFileNameChanged, 1); + compare(downloadPathChanged, 2); + downloadFinishedSpy.wait(); + compare(totalBytes, receivedBytes); + tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted); + verify(!downloadInterruptReason); + } } } diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml index 2f813b966..fad81273c 100644 --- a/tests/auto/quick/qmltests/data/tst_filePicker.qml +++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml @@ -36,6 +36,12 @@ TestWebEngineView { width: 400 height: 300 + function driveLetter() { + if (Qt.platform.os !== "windows") + return ""; + return "C:/"; + } + SignalSpy { id: titleSpy target: webEngineView @@ -72,27 +78,25 @@ TestWebEngineView { function test_acceptSingleFileSelection_data() { return [ - { tag: "/test.txt)", input: "/test.txt", passDefaultDialog: false, passCustomDialog: true }, - { tag: "/tést.txt", input: "/tést.txt", passDefaultDialog: false, passCustomDialog: true }, - { tag: "file:///test.txt", input: "file:///test.txt", passDefaultDialog: true, passCustomDialog: false }, - { tag: "file:///tést.txt", input: "file:///tést.txt", passDefaultDialog: true, passCustomDialog: false }, - { tag: "file:///t%C3%A9st.txt", input: "file:///t%C3%A9st.txt", passDefaultDialog: true, passCustomDialog: false }, - { tag: "file://test.txt", input: "file://test.txt", passDefaultDialog: false, passCustomDialog: false }, - { tag: "file:/test.txt", input: "file:/test.txt", passDefaultDialog: true, passCustomDialog: false }, - { tag: "file:test//test.txt", input: "file:test//test.txt", passDefaultDialog: false, passCustomDialog: false }, - { tag: "http://test.txt", input: "http://test.txt", passDefaultDialog: false, passCustomDialog: false }, - { tag: "qrc:/test.txt", input: "qrc:/test.txt", passDefaultDialog: false, passCustomDialog: false }, + { tag: driveLetter() + "/test.txt", input: driveLetter() + "/test.txt", expected: "test.txt" }, + { tag: driveLetter() + "test.txt", input: driveLetter() + "test.txt", expected: "Failed to Upload" }, + { tag: driveLetter() + "/tést.txt", input: driveLetter() + "/tést.txt", expected: "tést.txt" }, + { tag: driveLetter() + "/t%65st.txt", input: driveLetter() + "/t%65st.txt", expected: "t%65st.txt" }, + { tag: "file:///" + driveLetter() + "test.txt", input: "file:///" + driveLetter() + "test.txt", expected: "test.txt" }, + { tag: "file:///" + driveLetter() + "tést.txt", input: "file:///" + driveLetter() + "tést.txt", expected: "tést.txt" }, + { tag: "file:///" + driveLetter() + "t%65st.txt", input: "file:///" + driveLetter() + "t%65st.txt", expected: "test.txt" }, + { tag: "file://" + driveLetter() + "test.txt", input: "file://" + driveLetter() + "test.txt", expected: "test.txt" }, + { tag: "file:/" + driveLetter() + "test.txt", input: "file:/" + driveLetter() + "test.txt", expected: "test.txt"}, + { tag: "file:test//test.txt", input: "file:test//test.txt", expected: "Failed to Upload" }, + { tag: "http://test.txt", input: "http://test.txt", expected: "Failed to Upload" }, + { tag: "qrc:/test.txt", input: "qrc:/test.txt", expected: "Failed to Upload" }, ]; } function test_acceptSingleFileSelection(row) { var expectedFileName; - // Default dialog (expects URL). - expectedFileName = "Failed to Upload"; - if (row.passDefaultDialog) - expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1); - + // Default dialog webEngineView.url = Qt.resolvedUrl("singlefileupload.html"); verify(webEngineView.waitForLoadSucceeded()); @@ -101,16 +105,12 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryCompare(FilePickerParams, "filePickerOpened", true); - tryCompare(webEngineView, "title", decodeURIComponent(expectedFileName)); + tryCompare(webEngineView, "title", row.expected); - // Custom dialog (expects absolute path). + // Custom dialog var finished = false; - expectedFileName = "Failed to Upload"; - if (row.passCustomDialog) - expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1); - function acceptedFileHandler(request) { request.accepted = true; request.dialogAccept(row.input); @@ -123,7 +123,7 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryVerify(function() { return finished; }); - tryCompare(webEngineView, "title", expectedFileName); + tryCompare(webEngineView, "title", row.expected); webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); } @@ -165,14 +165,14 @@ TestWebEngineView { function test_acceptMultipleFilesWithCustomDialog_data() { return [ - { tag: "path", input: ["/test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "Failed to Upload", expectedValueForCustomDialog: "test1.txt,test2.txt" }, - { tag: "file", input: ["file:///test1.txt", "file:///test2.txt"], expectedValueForDefaultDialog: "test1.txt,test2.txt", expectedValueForCustomDialog: "Failed to Upload" }, - { tag: "mixed", input: ["file:///test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "test1.txt", expectedValueForCustomDialog: "test2.txt" }, + { tag: "path", input: [driveLetter() + "/test1.txt", driveLetter() + "/test2.txt"], expectedValue: "test1.txt,test2.txt" }, + { tag: "file", input: ["file:///" + driveLetter() + "test1.txt", "file:/" + driveLetter() + "test2.txt"], expectedValue: "test1.txt,test2.txt" }, + { tag: "mixed", input: ["file:///" + driveLetter() + "test1.txt", driveLetter() + "/test2.txt"], expectedValue: "test1.txt,test2.txt" }, ]; } function test_acceptMultipleFilesWithCustomDialog(row) { - // Default dialog (expects URL). + // Default dialog webEngineView.url = Qt.resolvedUrl("multifileupload.html"); verify(webEngineView.waitForLoadSucceeded()); @@ -181,10 +181,10 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryCompare(FilePickerParams, "filePickerOpened", true); - tryCompare(webEngineView, "title", row.expectedValueForDefaultDialog); + tryCompare(webEngineView, "title", row.expectedValue); - // Custom dialog (expects absolute path). + // Custom dialog var finished = false; function acceptedFileHandler(request) { @@ -199,7 +199,65 @@ TestWebEngineView { keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. tryVerify(function() { return finished; }); - tryCompare(webEngineView, "title", row.expectedValueForCustomDialog); + tryCompare(webEngineView, "title", row.expectedValue); + webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); + } + + function test_acceptFileOnWindows_data() { + return [ + { tag: "C:test.txt", input: "C:test.txt", expected: "Failed to Upload"}, + { tag: "C:test:txt", input: "C:test:txt", expected: "Failed to Upload"}, + { tag: "C:/test.txt", input: "C:/test.txt", expected: "test.txt"}, + { tag: "C:\\test.txt", input: "C:\\test.txt", expected: "test.txt"}, + { tag: "C:\\Documents and Settings\\test\\test.txt", input: "C:\\Documents and Settings\\test\\test.txt", expected: "test.txt"}, + { tag: "\\\\applib\\products\\a%2Db\\ abc%5F9\\t.est\\test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"}, + { tag: "file://applib/products/a%2Db/ abc%5F9/t.est/test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"}, + { tag: "file://applib/products/a-b/abc_1/t.est/test.txt", input: "file://applib/products/a-b/abc_1/t.est/test.txt", expected: "test.txt"}, + { tag: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", input: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", expected: "test.txt"}, + { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "Failed to Upload"}, + { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "Failed to Upload"}, + { tag: "file://C:/test.txt", input: "file://C:/test.txt", expected: "Failed to Upload"}, + { tag: "file:///C:test.txt", input: "file:///C:test.txt", expected: "Failed to Upload"}, + { tag: "file:///C:/test.txt", input: "file:///C:/test.txt", expected: "test.txt"}, + { tag: "file:///C:\\test.txt", input: "file:///C:\\test.txt", expected: "test.txt"}, + { tag: "file:\\//C:/test.txt", input: "file:\\//C:/test.txt", expected: "test.txt"}, + { tag: "file:\\\\/C:\\test.txt", input: "file:\\\\/C:\\test.txt", expected: "test.txt"}, + { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "Failed to Upload"}, + ]; + } + + function test_acceptFileOnWindows(row) { + if (Qt.platform.os !== "windows") + skip("Windows-only test"); + + // Default dialog + webEngineView.url = Qt.resolvedUrl("singlefileupload.html"); + verify(webEngineView.waitForLoadSucceeded()); + + FilePickerParams.selectFiles = true; + FilePickerParams.selectedFilesUrl.push(row.input); + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryCompare(FilePickerParams, "filePickerOpened", true); + tryCompare(webEngineView, "title", row.expected); + + + // Custom dialog + var finished = false; + + function acceptedFileHandler(request) { + request.accepted = true; + request.dialogAccept(row.input); + finished = true; + } + + webEngineView.fileDialogRequested.connect(acceptedFileHandler); + webEngineView.url = Qt.resolvedUrl("singlefileupload.html"); + verify(webEngineView.waitForLoadSucceeded()); + + keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog. + tryVerify(function() { return finished; }); + tryCompare(webEngineView, "title", row.expected); webEngineView.fileDialogRequested.disconnect(acceptedFileHandler); } } diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 74c04635f..5572515a1 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -91,6 +91,7 @@ private Q_SLOTS: void userScripts(); void javascriptClipboard_data(); void javascriptClipboard(); + void setProfile(); private: inline QQuickWebEngineView *newWebEngineView(); @@ -1148,5 +1149,18 @@ void tst_QQuickWebEngineView::javascriptClipboard() QTRY_COMPARE(evaluateJavaScriptSync(view, "accessPrompt").toBool(), false); } +void tst_QQuickWebEngineView::setProfile() { + QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*))); + webEngineView()->setUrl(urlFromTestPath("html/basic_page.html")); + QVERIFY(waitForLoadSucceeded(webEngineView())); + QCOMPARE(loadSpy.size(), 2); + webEngineView()->setUrl(urlFromTestPath("html/basic_page2.html")); + QVERIFY(waitForLoadSucceeded(webEngineView())); + QCOMPARE(loadSpy.size(), 4); + QQuickWebEngineProfile *profile = new QQuickWebEngineProfile(); + webEngineView()->setProfile(profile); + QTRY_COMPARE(webEngineView()->url() ,urlFromTestPath("html/basic_page2.html")); +} + QTEST_MAIN(tst_QQuickWebEngineView) #include "tst_qquickwebengineview.moc" diff --git a/tests/auto/widgets/proxypac/tst_proxypac.cpp b/tests/auto/widgets/proxypac/tst_proxypac.cpp index f9340341b..934e23fde 100644 --- a/tests/auto/widgets/proxypac/tst_proxypac.cpp +++ b/tests/auto/widgets/proxypac/tst_proxypac.cpp @@ -46,6 +46,10 @@ private slots: void tst_ProxyPac::proxypac() { + const QString fromEnv = QString::fromLocal8Bit(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS")); + if (!fromEnv.contains("--proxy-pac-url")) + qFatal("--proxy-pac-url argument is not passed."); + ProxyServer proxyServer1; proxyServer1.setPort(5551); proxyServer1.run(); diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index e6fad8b20..7857ee818 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -4,9 +4,5 @@ osx [mouseMovementProperties] windows -[runJavaScriptFromSlot] -osx -linux - [fullScreenRequested] windows diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index dbb15ba10..5edd778e2 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -1824,24 +1824,22 @@ void tst_QWebEnginePage::runJavaScriptFromSlot() { QWebEngineProfile profile; QWebEnginePage page(&profile); - page.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true); QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished); page.setHtml("<html><body>" " <input type='text' id='input1' value='QtWebEngine' size='50' />" "</body></html>"); QTRY_COMPARE(loadFinishedSpy.count(), 1); - // Workaround for QTBUG-74718 - QTRY_VERIFY(page.action(QWebEnginePage::SelectAll)->isEnabled()); - QVariant result(-1); + bool done = false; connect(&page, &QWebEnginePage::selectionChanged, [&]() { - result = evaluateJavaScriptSync(&page, QStringLiteral("2+2")); + QTRY_COMPARE(evaluateJavaScriptSync(&page, QStringLiteral("2+2")), QVariant(4)); + done = true; }); evaluateJavaScriptSync(&page, QStringLiteral("const input = document.getElementById('input1');" "input.focus();" "input.select();")); - QTRY_COMPARE(result, QVariant(4)); + QTRY_VERIFY(done); } void tst_QWebEnginePage::fullScreenRequested() diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index 90361f2c9..2e8687d9b 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -71,6 +71,7 @@ private Q_SLOTS: #endif void noTransportWithoutWebChannel(); void scriptsInNestedIframes(); + void matchQrcUrl(); }; void tst_QWebEngineScript::domEditing() @@ -589,6 +590,33 @@ void tst_QWebEngineScript::webChannelWithBadString() QCOMPARE(host.text(), data); } #endif + +void tst_QWebEngineScript::matchQrcUrl() +{ + QWebEnginePage page; + QWebEngineView view; + view.setPage(&page); + QWebEngineScript s; + s.setInjectionPoint(QWebEngineScript::DocumentReady); + s.setWorldId(QWebEngineScript::MainWorld); + + + s.setSourceCode(QStringLiteral(R"( +// ==UserScript== +// @match qrc:/*main.html +// ==/UserScript== + +document.title = 'New title'; + )")); + + page.scripts().insert(s); + page.load(QUrl("qrc:/resources/test_iframe_main.html")); + view.show(); + QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished); + QVERIFY(spyFinished.wait()); + QCOMPARE(page.title(), "New title"); +} + QTEST_MAIN(tst_QWebEngineScript) #include "tst_qwebenginescript.moc" diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST index 9087067f5..266f08886 100644 --- a/tests/auto/widgets/qwebengineview/BLACKLIST +++ b/tests/auto/widgets/qwebengineview/BLACKLIST @@ -3,3 +3,6 @@ osx [textSelectionOutOfInputField] * + +[visibilityState3] +windows diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 827ac2757..71c4aa9b5 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -192,6 +192,8 @@ private Q_SLOTS: void webUIURLs_data(); void webUIURLs(); void visibilityState(); + void visibilityState2(); + void visibilityState3(); void jsKeyboardEvent(); void deletePage(); void closeOpenerTab(); @@ -3140,6 +3142,38 @@ void tst_QWebEngineView::visibilityState() QCOMPARE(evaluateJavaScriptSync(view.page(), "document.visibilityState").toString(), QStringLiteral("visible")); } +void tst_QWebEngineView::visibilityState2() +{ + QWebEngineView view; + QSignalSpy spy(&view, &QWebEngineView::loadFinished); + view.show(); + view.load(QStringLiteral("about:blank")); + view.hide(); + QVERIFY(spy.count() || spy.wait()); + QVERIFY(spy.takeFirst().takeFirst().toBool()); + QCOMPARE(evaluateJavaScriptSync(view.page(), "document.visibilityState").toString(), QStringLiteral("hidden")); +} + +void tst_QWebEngineView::visibilityState3() +{ + QWebEnginePage page1; + QWebEnginePage page2; + QSignalSpy spy1(&page1, &QWebEnginePage::loadFinished); + QSignalSpy spy2(&page2, &QWebEnginePage::loadFinished); + page1.load(QStringLiteral("about:blank")); + page2.load(QStringLiteral("about:blank")); + QVERIFY(spy1.count() || spy1.wait()); + QVERIFY(spy2.count() || spy2.wait()); + QWebEngineView view; + view.setPage(&page1); + view.show(); + QCOMPARE(evaluateJavaScriptSync(&page1, "document.visibilityState").toString(), QStringLiteral("visible")); + QCOMPARE(evaluateJavaScriptSync(&page2, "document.visibilityState").toString(), QStringLiteral("hidden")); + view.setPage(&page2); + QCOMPARE(evaluateJavaScriptSync(&page1, "document.visibilityState").toString(), QStringLiteral("hidden")); + QCOMPARE(evaluateJavaScriptSync(&page2, "document.visibilityState").toString(), QStringLiteral("visible")); +} + void tst_QWebEngineView::jsKeyboardEvent() { QWebEngineView view; diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index df553df55..6d65eecb5 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -4,7 +4,6 @@ QT_FOR_CONFIG += webenginecore webenginecore-private TEMPLATE = subdirs SUBDIRS += \ - certificateerror \ defaultsurfaceformat \ devtools \ faviconmanager \ @@ -31,6 +30,10 @@ qtConfig(webengine-printing-and-pdf) { SUBDIRS += printing } +qtConfig(ssl) { + SUBDIRS += certificateerror +} + qtConfig(webengine-spellchecker):!cross_compile { !qtConfig(webengine-native-spellchecker) { SUBDIRS += spellchecking |