From 822763ddda98f04339df44641f9b0d0f72ff6466 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 27 Jul 2016 09:14:52 +0200 Subject: Autocomplete view-source URL User may miss the URL scheme (eg. http://) when type a view-source url into the browser's location bar (eg. view-source:qt.io). This is not handled by the Chromium thus will produce an empty view-source page. The new autocompletion extends the incomplete view-source URL thus it will provide valid URL if it is possible (eg. view-source:http://qt.io/) Change-Id: I3edcd271cd0a971c9754e875db8f2a55a9a545de Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/qmltests/data/tst_viewSource.qml | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/auto/quick/qmltests') diff --git a/tests/auto/quick/qmltests/data/tst_viewSource.qml b/tests/auto/quick/qmltests/data/tst_viewSource.qml index 7c7dd34e0..746bfcfb3 100644 --- a/tests/auto/quick/qmltests/data/tst_viewSource.qml +++ b/tests/auto/quick/qmltests/data/tst_viewSource.qml @@ -63,6 +63,9 @@ TestWebEngineView { name: "WebEngineViewSource" function init() { + webEngineView.url = Qt.resolvedUrl("about:blank"); + verify(webEngineView.waitForLoadSucceeded()); + newViewRequestedSpy.clear(); titleChangedSpy.clear(); viewRequest = null; @@ -88,6 +91,37 @@ TestWebEngineView { compare(webEngineView.title, "test1.html"); compare(webEngineView.url, "view-source:" + Qt.resolvedUrl("test1.html")); } + + function test_viewSourceURL_data() { + var testLocalUrl = "view-source:" + Qt.resolvedUrl("test1.html"); + var testLocalUrlWithoutScheme = "view-source:" + Qt.resolvedUrl("test1.html").substring(7); + + return [ + { tag: "view-source:", userInputUrl: "view-source:", loadSucceed: true, url: "view-source:", title: "view-source:" }, + { tag: "view-source:about:blank", userInputUrl: "view-source:about:blank", loadSucceed: true, url: "view-source:about:blank", title: "view-source:about:blank" }, + { tag: testLocalUrl, userInputUrl: testLocalUrl, loadSucceed: true, url: testLocalUrl, title: "test1.html" }, + { tag: testLocalUrlWithoutScheme, userInputUrl: testLocalUrlWithoutScheme, loadSucceed: true, url: testLocalUrl, title: "test1.html" }, + { tag: "view-source:http://non.existent", userInputUrl: "view-source:http://non.existent", loadSucceed: false, url: "view-source:http://non.existent/", title: "http://non.existent/ is not available" }, + { tag: "view-source:non.existent", userInputUrl: "view-source:non.existent", loadSucceed: false, url: "view-source:http://non.existent/", title: "http://non.existent/ is not available" }, + ]; + } + + function test_viewSourceURL(row) { + WebEngine.settings.errorPageEnabled = true + webEngineView.url = row.userInputUrl; + + if (row.loadSucceed) { + verify(webEngineView.waitForLoadSucceeded()); + tryCompare(titleChangedSpy, "count", 1); + } else { + verify(webEngineView.waitForLoadFailed()); + tryCompare(titleChangedSpy, "count", 2); + } + + compare(webEngineView.url, row.url); + compare(webEngineView.title, row.title); + verify(!webEngineView.canViewSource); + } } } -- cgit v1.2.3