summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests/data')
-rw-r--r--tests/auto/quick/qmltests/data/forms.html12
-rw-r--r--tests/auto/quick/qmltests/data/script-with-metadata.js10
-rw-r--r--tests/auto/quick/qmltests/data/tst_download.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml136
-rw-r--r--tests/auto/quick/qmltests/data/tst_formValidation.qml24
-rw-r--r--tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml1
-rw-r--r--tests/auto/quick/qmltests/data/tst_runJavaScript.qml1
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScripts.qml22
-rw-r--r--tests/auto/quick/qmltests/data/tst_viewSource.qml93
9 files changed, 281 insertions, 20 deletions
diff --git a/tests/auto/quick/qmltests/data/forms.html b/tests/auto/quick/qmltests/data/forms.html
index 8dc3472f2..18133eca6 100644
--- a/tests/auto/quick/qmltests/data/forms.html
+++ b/tests/auto/quick/qmltests/data/forms.html
@@ -19,10 +19,6 @@
<input type="url" value="invalid" required/>
<input type="submit" name="url_invalid"/>
</form>
- <form>
- <input type="url" value="invalid" title="url_title" required/>
- <input type="submit" name="url_title"/>
- </form>
<form>
<input type="email" required/>
@@ -33,8 +29,12 @@
<input type="submit" name="email_invalid"/>
</form>
<form>
- <input type="email" value="invalid" title="email_title" required/>
- <input type="submit" name="email_title"/>
+ <input type="text" title="empty input" required/>
+ <input type="submit" name="input_empty"/>
+ </form>
+ <form>
+ <input type="text" pattern="Lorem ipsum" value="Lorem Ipsum" title="Should type 'Lorem ipsum'"/>
+ <input type="submit" name="lorem_ipsum"/>
</form>
</body>
</html>
diff --git a/tests/auto/quick/qmltests/data/script-with-metadata.js b/tests/auto/quick/qmltests/data/script-with-metadata.js
new file mode 100644
index 000000000..4dcf50f55
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/script-with-metadata.js
@@ -0,0 +1,10 @@
+// ==UserScript==
+// @name Test script
+// @homepageURL http://www.qt.io/
+// @description Test script with metadata block
+// @include *test*.html
+// @exclude *test2.html
+// @run-at document-end
+// ==/UserScript==
+
+document.title = "New title";
diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml
index 7d1e24b4d..e4e93b993 100644
--- a/tests/auto/quick/qmltests/data/tst_download.qml
+++ b/tests/auto/quick/qmltests/data/tst_download.qml
@@ -114,7 +114,7 @@ TestWebEngineView {
compare(downloadState[1], WebEngineDownloadItem.DownloadInProgress)
downloadFinishedSpy.wait()
compare(totalBytes, receivedBytes)
- tryCompare(downloadState, 2, WebEngineDownloadItem.DownloadCompleted)
+ tryCompare(downloadState, "2", WebEngineDownloadItem.DownloadCompleted)
}
function test_downloadCancelled() {
diff --git a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
new file mode 100644
index 000000000..ce0fa2e31
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtTest 1.0
+import QtWebEngine 1.4
+
+Item {
+ id: container
+ width: 500
+ height: 300
+
+ Row {
+ id: row
+ spacing: 1
+
+ Rectangle {
+ anchors.top: row.top
+ anchors.topMargin: 7
+ width: input.width
+ height: input.height
+ border.color: "black"
+ border.width: 1
+
+ TextInput {
+ id: input
+ width: 80
+ height: 20
+ verticalAlignment: TextInput.AlignVCenter
+ horizontalAlignment: TextInput.AlignHCenter
+ text: "Text"
+ }
+ }
+
+ TestWebEngineView {
+ id: webView
+ width: 300
+ height: 300
+ }
+ }
+
+ TestCase {
+ name: "WebEngineViewFocusOnNavigation"
+ when: windowShown
+ function init() {
+ }
+
+ function test_focusOnNavigation_data() {
+ return [
+ {tag: "focusOnNavigation true", focusOnNavigation: true,
+ viewReceivedFocus: true },
+ {tag: "focusOnNavigation false", focusOnNavigation: false,
+ viewReceivedFocus: false },
+ ]
+ }
+
+ function triggerJavascriptFocus() {
+ var callbackCalled = false;
+ webView.runJavaScript("document.getElementById(\"input\").focus()", function(result) {
+ callbackCalled = true;
+ });
+ wait(100);
+ verify(callbackCalled);
+ }
+
+ function loadAndTriggerFocusAndCompare(data) {
+ verify(webView.waitForLoadSucceeded());
+ triggerJavascriptFocus();
+ compare(webView.activeFocus, data.viewReceivedFocus);
+ }
+
+ function test_focusOnNavigation(data) {
+ // TextInput awlays has initial focus.
+ input.forceActiveFocus();
+
+ // Set focusOnNavigation property to current testing value.
+ webView.settings.focusOnNavigationEnabled = data.focusOnNavigation;
+
+ // Load the content, invoke javascript focus on the view, and check which widget has
+ // focus.
+ webView.loadHtml("<html><head><title>Title</title></head><body>Hello" +
+ "<input id=\"input\" type=\"text\"></body></html>");
+ loadAndTriggerFocusAndCompare(data);
+
+ // Load a different page, and check focus.
+ webView.loadHtml("<html><head><title>Title</title></head><body>Hello 2" +
+ "<input id=\"input\" type=\"text\"></body></html>");
+ loadAndTriggerFocusAndCompare(data);
+
+ // Navigate to previous page in history, check focus.
+ webView.triggerWebAction(WebEngineView.Back)
+ loadAndTriggerFocusAndCompare(data);
+
+ // Navigate to next page in history, check focus.
+ webView.triggerWebAction(WebEngineView.Forward)
+ loadAndTriggerFocusAndCompare(data);
+
+ // Reload page, check focus.
+ webView.triggerWebAction(WebEngineView.Reload)
+ loadAndTriggerFocusAndCompare(data);
+
+ // Reload page bypassing cache, check focus.
+ webView.triggerWebAction(WebEngineView.ReloadAndBypassCache)
+ loadAndTriggerFocusAndCompare(data);
+
+ // Manually forcing focus on web view should work.
+ webView.forceActiveFocus()
+ compare(webView.activeFocus, true)
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_formValidation.qml b/tests/auto/quick/qmltests/data/tst_formValidation.qml
index 6da8af7ff..cae41821c 100644
--- a/tests/auto/quick/qmltests/data/tst_formValidation.qml
+++ b/tests/auto/quick/qmltests/data/tst_formValidation.qml
@@ -71,15 +71,6 @@ TestWebEngineView {
keyPress(Qt.Key_Enter)
showSpy.wait()
compare(showSpy.signalArguments[1][0], "Please enter a URL.")
-
- webEngineView.url = Qt.resolvedUrl("about:blank")
- verify(webEngineView.waitForLoadSucceeded())
-
- webEngineView.url = Qt.resolvedUrl("forms.html#url_title")
- verify(webEngineView.waitForLoadSucceeded())
- keyPress(Qt.Key_Enter)
- showSpy.wait()
- compare(showSpy.signalArguments[2][1], "url_title")
}
function test_emailForm() {
@@ -97,15 +88,26 @@ TestWebEngineView {
keyPress(Qt.Key_Enter)
showSpy.wait()
compare(showSpy.signalArguments[1][0], "Please include an '@' in the email address. 'invalid' is missing an '@'.")
+ }
+
+ function test_textForm() {
+ webEngineView.url = Qt.resolvedUrl("forms.html#input_empty")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[0][0], "Please fill out this field.")
+ // Title should be shown for pattern mismatch only
+ compare(showSpy.signalArguments[0][1], "")
webEngineView.url = Qt.resolvedUrl("about:blank")
verify(webEngineView.waitForLoadSucceeded())
- webEngineView.url = Qt.resolvedUrl("forms.html#email_title")
+ webEngineView.url = Qt.resolvedUrl("forms.html#lorem_ipsum")
verify(webEngineView.waitForLoadSucceeded())
keyPress(Qt.Key_Enter)
showSpy.wait()
- compare(showSpy.signalArguments[2][1], "email_title")
+ compare(showSpy.signalArguments[1][0], "Please match the requested format.")
+ compare(showSpy.signalArguments[1][1], "Should type 'Lorem ipsum'")
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml b/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
index 86fb9281c..ae60e5f5e 100644
--- a/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
+++ b/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
@@ -53,7 +53,6 @@ TestWebEngineView {
}
function test_keyboardModifierMapping() {
- skip("runJavaScript bug: QTBUG-51746")
webEngineView.url = Qt.resolvedUrl("keyboardModifierMapping.html")
waitForLoadSucceeded();
titleSpy.wait()
diff --git a/tests/auto/quick/qmltests/data/tst_runJavaScript.qml b/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
index 2011d2a5c..beeebc049 100644
--- a/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
+++ b/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
@@ -44,7 +44,6 @@ TestWebEngineView {
TestCase {
name: "WebEngineViewRunJavaScript"
function test_runJavaScript() {
- skip("runJavaScript bug: QTBUG-51746")
var testTitle = "Title to test runJavaScript";
runJavaScript("document.title = \"" + testTitle +"\"");
_waitFor(function() { spy.count > 0; });
diff --git a/tests/auto/quick/qmltests/data/tst_userScripts.qml b/tests/auto/quick/qmltests/data/tst_userScripts.qml
index 358e8f56d..92ae71f0b 100644
--- a/tests/auto/quick/qmltests/data/tst_userScripts.qml
+++ b/tests/auto/quick/qmltests/data/tst_userScripts.qml
@@ -49,6 +49,11 @@ Item {
injectionPoint: WebEngineScript.DocumentReady
}
+ WebEngineScript {
+ id: scriptWithMetadata
+ sourceUrl: Qt.resolvedUrl("script-with-metadata.js")
+ }
+
TestWebEngineView {
id: webEngineView
width: 400
@@ -151,5 +156,22 @@ Item {
webEngineView.waitForLoadSucceeded();
compare(webEngineView.title, "Big user script changed title");
}
+
+ function test_parseMetadataHeader() {
+ compare(scriptWithMetadata.name, "Test script");
+ compare(scriptWithMetadata.injectionPoint, WebEngineScript.DocumentReady);
+
+ webEngineView.userScripts = [ scriptWithMetadata ];
+
+ // @include *test*.html
+ webEngineView.url = Qt.resolvedUrl("test1.html");
+ webEngineView.waitForLoadSucceeded();
+ compare(webEngineView.title, "New title");
+
+ // @exclude *test2.html
+ webEngineView.url = Qt.resolvedUrl("test2.html");
+ webEngineView.waitForLoadSucceeded();
+ compare(webEngineView.title, "Test page with huge link area");
+ }
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_viewSource.qml b/tests/auto/quick/qmltests/data/tst_viewSource.qml
new file mode 100644
index 000000000..7c7dd34e0
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_viewSource.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.4
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ property var viewRequest: null
+
+ SignalSpy {
+ id: newViewRequestedSpy
+ target: webEngineView
+ signalName: "newViewRequested"
+ }
+
+ SignalSpy {
+ id: titleChangedSpy
+ target: webEngineView
+ signalName: "titleChanged"
+ }
+
+ onNewViewRequested: {
+ viewRequest = {
+ "destination": request.destination,
+ "userInitiated": request.userInitiated
+ };
+
+ request.openIn(webEngineView);
+ }
+
+ TestCase {
+ id: test
+ name: "WebEngineViewSource"
+
+ function init() {
+ newViewRequestedSpy.clear();
+ titleChangedSpy.clear();
+ viewRequest = null;
+ }
+
+ function test_viewSource() {
+ webEngineView.url = Qt.resolvedUrl("test1.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ compare(webEngineView.title, "Test page 1");
+ verify(webEngineView.canViewSource, true);
+
+ titleChangedSpy.clear();
+ webEngineView.viewSource();
+ tryCompare(newViewRequestedSpy, "count", 1);
+ verify(webEngineView.waitForLoadSucceeded());
+ // The first titleChanged signal is emitted by adoptWebContents()
+ tryCompare(titleChangedSpy, "count", 2);
+
+ compare(viewRequest.destination, WebEngineView.NewViewInTab);
+ verify(viewRequest.userInitiated);
+ verify(!webEngineView.canViewSource);
+
+ compare(webEngineView.title, "test1.html");
+ compare(webEngineView.url, "view-source:" + Qt.resolvedUrl("test1.html"));
+ }
+ }
+}
+