summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests2
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests2')
-rw-r--r--tests/auto/quick/qmltests2/data/accepttypes.html21
-rw-r--r--tests/auto/quick/qmltests2/data/alert.html5
-rw-r--r--tests/auto/quick/qmltests2/data/confirm.html10
-rw-r--r--tests/auto/quick/qmltests2/data/confirmclose.html6
-rw-r--r--tests/auto/quick/qmltests2/data/directoryupload.html17
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-candidates-gray.html29
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-misc.html11
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-multi-gray.html25
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-multi.html9
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-shortcut.html10
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-single.html9
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-touch.html10
-rw-r--r--tests/auto/quick/qmltests2/data/favicon-unavailable.html9
-rw-r--r--tests/auto/quick/qmltests2/data/favicon.html10
-rw-r--r--tests/auto/quick/qmltests2/data/favicon2.html10
-rw-r--r--tests/auto/quick/qmltests2/data/icons/favicon.pngbin0 -> 3961 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/gray128.pngbin0 -> 146 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/gray16.pngbin0 -> 72 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/gray255.pngbin0 -> 335 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/gray32.pngbin0 -> 79 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/gray64.pngbin0 -> 99 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/grayicons.icobin0 -> 22150 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/qt144.pngbin0 -> 8315 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/qt32.icobin0 -> 4286 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/qtmulti.icobin0 -> 22382 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/icons/small-favicon.pngbin0 -> 878 bytes
-rw-r--r--tests/auto/quick/qmltests2/data/multifileupload.html18
-rw-r--r--tests/auto/quick/qmltests2/data/prompt.html7
-rw-r--r--tests/auto/quick/qmltests2/data/singlefileupload.html18
-rw-r--r--tests/auto/quick/qmltests2/data/test1.html6
-rw-r--r--tests/auto/quick/qmltests2/data/test2.html6
-rw-r--r--tests/auto/quick/qmltests2/data/titleupdate.js42
-rw-r--r--tests/auto/quick/qmltests2/data/tst_favicon.qml413
-rw-r--r--tests/auto/quick/qmltests2/data/tst_faviconDownload.qml121
-rw-r--r--tests/auto/quick/qmltests2/data/tst_filePicker.qml326
-rw-r--r--tests/auto/quick/qmltests2/data/tst_inputMethod.qml78
-rw-r--r--tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml156
-rw-r--r--tests/auto/quick/qmltests2/data/tst_linkHovered.qml131
-rw-r--r--tests/auto/quick/qmltests2/data/tst_loadFail.qml147
-rw-r--r--tests/auto/quick/qmltests2/data/tst_mouseClick.qml131
-rw-r--r--tests/auto/quick/qmltests2/data/tst_viewSoure.qml137
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml32
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml49
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml49
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml57
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml44
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml52
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir5
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml37
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml37
-rw-r--r--tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir4
-rw-r--r--tests/auto/quick/qmltests2/qmltests2.pro79
-rw-r--r--tests/auto/quick/qmltests2/tst_qmltests2.cpp127
53 files changed, 2500 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests2/data/accepttypes.html b/tests/auto/quick/qmltests2/data/accepttypes.html
new file mode 100644
index 000000000..aff39f96e
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/accepttypes.html
@@ -0,0 +1,21 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title>Default title</title>
+</head>
+
+<body>
+<input type="file" name="file" id="upfile" accept="">
+
+<script>
+window.onload = function() {
+ document.getElementById("upfile").focus();
+}
+
+function setAcceptType(acceptType) {
+ document.getElementById("upfile").accept = acceptType;
+ document.title = acceptType;
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/alert.html b/tests/auto/quick/qmltests2/data/alert.html
new file mode 100644
index 000000000..89715a727
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/alert.html
@@ -0,0 +1,5 @@
+<html>
+<head>
+ <script> alert("Hello Qt"); </script>
+</head>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/confirm.html b/tests/auto/quick/qmltests2/data/confirm.html
new file mode 100644
index 000000000..a4fc5b532
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/confirm.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <script>
+ if (confirm("Confirm test"))
+ document.title += " ACCEPTED";
+ else
+ document.title += " REJECTED";
+ </script>
+</head>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/confirmclose.html b/tests/auto/quick/qmltests2/data/confirmclose.html
new file mode 100644
index 000000000..c2acbb67f
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/confirmclose.html
@@ -0,0 +1,6 @@
+<html>
+<body onbeforeunload="return 'You are about to miss out on some awesome content.';"
+ onmousedown="window.mousePressReceived = true;">
+ Be greeted, precious viewer!
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/directoryupload.html b/tests/auto/quick/qmltests2/data/directoryupload.html
new file mode 100644
index 000000000..adc408ebb
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/directoryupload.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title> Directory Upload </title>
+<script src = "./titleupdate.js">
+</script>
+</head>
+
+<body>
+<input type="file" id="upfile" webkitdirectory="" directory="" onchange="updateTitle()">
+<script>
+window.onload = function() {
+document.getElementById("upfile").focus()
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-candidates-gray.html b/tests/auto/quick/qmltests2/data/favicon-candidates-gray.html
new file mode 100644
index 000000000..ebea35b02
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-candidates-gray.html
@@ -0,0 +1,29 @@
+<html>
+ <head>
+ <title>Gray Candidate Favicons Test</title>
+ <link rel="shortcut icon" href="icons/gray16.png" />
+ <link rel="shortcut icon" href="icons/gray32.png" />
+ <link rel="shortcut icon" href="icons/gray64.png" />
+ <link rel="shortcut icon" href="icons/gray128.png" />
+ <link rel="shortcut icon" href="icons/gray255.png" />
+ </head>
+ <body>
+ <h1>Gray Candidate Favicons Test</h1>
+ <table style="width:100%">
+ <tr>
+ <td align="center"><img src="icons/gray16.png" height="16" width="16" border="1" /></td>
+ <td align="center"><img src="icons/gray32.png" height="32" width="32" border="1" /></td>
+ <td align="center"><img src="icons/gray64.png" height="64" width="64" border="1" /></td>
+ <td align="center"><img src="icons/gray128.png" height="128" width="128" border="1" /></td>
+ <td align="center"><img src="icons/gray255.png" height="255" width="255" border="1" /></td>
+ </tr>
+ <tr>
+ <td align="center">16x16</td>
+ <td align="center">32x32</td>
+ <td align="center">64x64</td>
+ <td align="center">128x128</td>
+ <td align="center">255x255</td>
+ </tr>
+ </table>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-misc.html b/tests/auto/quick/qmltests2/data/favicon-misc.html
new file mode 100644
index 000000000..9e788bdf4
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-misc.html
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title>Favicon Test</title>
+ <link rel="shortcut icon" href="icons/qt32.ico" />
+ <link rel="apple-touch-icon" href="icons/qt144.png" />
+ <link rel="shortcut icon" href="icons/unavailable.ico" />
+ </head>
+ <body>
+ <h1>Favicon Test</h1>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-multi-gray.html b/tests/auto/quick/qmltests2/data/favicon-multi-gray.html
new file mode 100644
index 000000000..24b71640f
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-multi-gray.html
@@ -0,0 +1,25 @@
+<html>
+ <head>
+ <title>Gray Multi-sized Favicon Test</title>
+ <link rel="shortcut icon" href="icons/grayicons.ico" />
+ </head>
+ <body>
+ <h1>Gray Multi-sized Favicon Test</h1>
+ <table style="width:100%">
+ <tr>
+ <td align="center"><img src="icons/gray16.png" height="16" width="16" border="1" /></td>
+ <td align="center"><img src="icons/gray32.png" height="32" width="32" border="1" /></td>
+ <td align="center"><img src="icons/gray64.png" height="64" width="64" border="1" /></td>
+ <td align="center"><img src="icons/gray128.png" height="128" width="128" border="1" /></td>
+ <td align="center"><img src="icons/gray255.png" height="255" width="255" border="1" /></td>
+ </tr>
+ <tr>
+ <td align="center">16x16</td>
+ <td align="center">32x32</td>
+ <td align="center">64x64</td>
+ <td align="center">128x128</td>
+ <td align="center">255x255</td>
+ </tr>
+ </table>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-multi.html b/tests/auto/quick/qmltests2/data/favicon-multi.html
new file mode 100644
index 000000000..cc5f3fd66
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-multi.html
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>Multi-sized Favicon Test</title>
+ <link rel="shortcut icon" sizes="16x16 32x23 64x64" href="icons/qtmulti.ico" />
+ </head>
+ <body>
+ <h1>Multi-sized Favicon Test</h1>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-shortcut.html b/tests/auto/quick/qmltests2/data/favicon-shortcut.html
new file mode 100644
index 000000000..786cdb816
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-shortcut.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>Favicon Test</title>
+ <link rel="shortcut icon" href="icons/qt32.ico" />
+ <link rel="shortcut icon" href="icons/qt144.png" />
+ </head>
+ <body>
+ <h1>Favicon Test</h1>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-single.html b/tests/auto/quick/qmltests2/data/favicon-single.html
new file mode 100644
index 000000000..eb4675c75
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-single.html
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>Favicon Test</title>
+ <link rel="shortcut icon" href="icons/qt32.ico" />
+ </head>
+ <body>
+ <h1>Favicon Test</h1>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-touch.html b/tests/auto/quick/qmltests2/data/favicon-touch.html
new file mode 100644
index 000000000..271783434
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-touch.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>Favicon Test</title>
+ <link rel="apple-touch-icon" href="icons/qt32.ico" />
+ <link rel="apple-touch-icon" href="icons/qt144.png" />
+ </head>
+ <body>
+ <h1>Favicon Test</h1>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon-unavailable.html b/tests/auto/quick/qmltests2/data/favicon-unavailable.html
new file mode 100644
index 000000000..c45664294
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon-unavailable.html
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>Favicon Test</title>
+ <link rel="shortcut icon" href="icons/unavailable.ico" />
+ </head>
+ <body>
+ <h1>Favicon Test</h1>
+ </body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon.html b/tests/auto/quick/qmltests2/data/favicon.html
new file mode 100644
index 000000000..e1b84a9cc
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<link type="image/png" href="icons/favicon.png" sizes="48x48" rel="icon" />
+</head>
+<body>
+<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p>
+<p>The favicon looks like this:</p>
+<img id='image' src="icons/favicon.png"/>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/favicon2.html b/tests/auto/quick/qmltests2/data/favicon2.html
new file mode 100644
index 000000000..81c2690fe
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/favicon2.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+</head>
+<link type="image/png" href="icons/small-favicon.png" sizes="16x16" rel="icon" />
+<body>
+<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p>
+<p>The favicon looks like this:</p>
+<img src="icons/small-favicon.png"/>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/icons/favicon.png b/tests/auto/quick/qmltests2/data/icons/favicon.png
new file mode 100644
index 000000000..35717cca5
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/favicon.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray128.png b/tests/auto/quick/qmltests2/data/icons/gray128.png
new file mode 100644
index 000000000..bf1cfaba0
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/gray128.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray16.png b/tests/auto/quick/qmltests2/data/icons/gray16.png
new file mode 100644
index 000000000..2a1a91a76
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/gray16.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray255.png b/tests/auto/quick/qmltests2/data/icons/gray255.png
new file mode 100644
index 000000000..549169551
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/gray255.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray32.png b/tests/auto/quick/qmltests2/data/icons/gray32.png
new file mode 100644
index 000000000..b269a528f
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/gray32.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/gray64.png b/tests/auto/quick/qmltests2/data/icons/gray64.png
new file mode 100644
index 000000000..e02559e5b
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/gray64.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/grayicons.ico b/tests/auto/quick/qmltests2/data/icons/grayicons.ico
new file mode 100644
index 000000000..8d8fee839
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/grayicons.ico
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/qt144.png b/tests/auto/quick/qmltests2/data/icons/qt144.png
new file mode 100644
index 000000000..050b1e066
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/qt144.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/qt32.ico b/tests/auto/quick/qmltests2/data/icons/qt32.ico
new file mode 100644
index 000000000..2f6fcb5bc
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/qt32.ico
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/qtmulti.ico b/tests/auto/quick/qmltests2/data/icons/qtmulti.ico
new file mode 100644
index 000000000..81e5a22e8
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/qtmulti.ico
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/icons/small-favicon.png b/tests/auto/quick/qmltests2/data/icons/small-favicon.png
new file mode 100644
index 000000000..8cf9a50a4
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/icons/small-favicon.png
Binary files differ
diff --git a/tests/auto/quick/qmltests2/data/multifileupload.html b/tests/auto/quick/qmltests2/data/multifileupload.html
new file mode 100644
index 000000000..d41ea15c0
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/multifileupload.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title> Failed to Upload </title>
+<script src = "./titleupdate.js">
+</script>
+</head>
+
+<body>
+<input type="file" name="file" id="upfile" onchange="updateTitle()" multiple/>
+
+<script>
+window.onload = function() {
+document.getElementById("upfile").focus()
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/prompt.html b/tests/auto/quick/qmltests2/data/prompt.html
new file mode 100644
index 000000000..3293c0dcf
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/prompt.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+ <script>
+ document.title = prompt("Please, reverse the default value", "Hello Qt");
+ </script>
+</head>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/singlefileupload.html b/tests/auto/quick/qmltests2/data/singlefileupload.html
new file mode 100644
index 000000000..ac91c2c0d
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/singlefileupload.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title> Failed to Upload </title>
+<script src = "./titleupdate.js">
+</script>
+</head>
+
+<body>
+<input type="file" name="file" id="upfile" onchange="updateTitle()"/>
+
+<script>
+window.onload = function() {
+document.getElementById("upfile").focus()
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/test1.html b/tests/auto/quick/qmltests2/data/test1.html
new file mode 100644
index 000000000..5c09f06ed
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/test1.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Test page 1</title></head>
+<body>
+Hello.
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/test2.html b/tests/auto/quick/qmltests2/data/test2.html
new file mode 100644
index 000000000..629c2a063
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/test2.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Test page with huge link area</title></head>
+<body>
+<a title="A title" href="test1.html"><img width=200 height=200></a>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests2/data/titleupdate.js b/tests/auto/quick/qmltests2/data/titleupdate.js
new file mode 100644
index 000000000..c86139c13
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/titleupdate.js
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+function updateTitle()
+{
+ var inp = document.getElementById("upfile");
+ var allfiles = new String("");
+ var name = new String("");
+ for (var i = 0; i < inp.files.length; ++i) {
+ name = inp.files.item(i).name;
+ if (allfiles.length == 0)
+ allfiles = name;
+ else
+ allfiles = allfiles + "," + name;
+ }
+ document.title = allfiles;
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_favicon.qml b/tests/auto/quick/qmltests2/data/tst_favicon.qml
new file mode 100644
index 000000000..ea5d20f17
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_favicon.qml
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** 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.3
+import QtWebEngine.testsupport 1.0
+import QtQuick.Window 2.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ testSupport: WebEngineTestSupport {
+ property var errorPageLoadStatus: null
+
+ function waitForErrorPageLoadSucceeded() {
+ var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus })
+ testSupport.errorPageLoadStatus = null
+ return success
+ }
+
+ errorPage.onLoadingChanged: {
+ errorPageLoadStatus = loadRequest.status
+ }
+ }
+
+ function removeFaviconProviderPrefix(url) {
+ return url.toString().substring(16)
+ }
+
+ function getFaviconPixel(faviconImage) {
+ var grabImage = Qt.createQmlObject("
+ import QtQuick 2.5\n
+ Image { }", testCase)
+ var faviconCanvas = Qt.createQmlObject("
+ import QtQuick 2.5\n
+ Canvas { }", testCase)
+
+ testCase.tryVerify(function() { return faviconImage.status == Image.Ready });
+ faviconImage.grabToImage(function(result) {
+ grabImage.source = result.url
+ });
+ testCase.tryVerify(function() { return grabImage.status == Image.Ready });
+
+ faviconCanvas.width = faviconImage.width;
+ faviconCanvas.height = faviconImage.height;
+ var ctx = faviconCanvas.getContext("2d");
+ ctx.drawImage(grabImage, 0, 0, grabImage.width, grabImage.height);
+ var imageData = ctx.getImageData(Math.round(faviconCanvas.width/2),
+ Math.round(faviconCanvas.height/2),
+ faviconCanvas.width,
+ faviconCanvas.height);
+
+ grabImage.destroy();
+ faviconCanvas.destroy();
+
+ return imageData.data;
+ }
+
+ SignalSpy {
+ id: iconChangedSpy
+ target: webEngineView
+ signalName: "iconChanged"
+ }
+
+ Image {
+ id: favicon
+ source: webEngineView.icon
+ }
+
+ TestCase {
+ id: testCase
+ name: "WebEngineFavicon"
+ when: windowShown
+
+
+ function init() {
+ // It is worth to restore the initial state with loading a blank page before all test functions.
+ webEngineView.url = 'about:blank'
+ verify(webEngineView.waitForLoadSucceeded())
+ iconChangedSpy.clear()
+ }
+
+ function test_faviconLoad() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("favicon.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+
+ compare(favicon.width, 48)
+ compare(favicon.height, 48)
+ }
+
+ function test_faviconLoadEncodedUrl() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("favicon2.html?favicon=load should work with#whitespace!")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+
+ compare(favicon.width, 16)
+ compare(favicon.height, 16)
+ }
+
+ function test_noFavicon() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("test1.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_aboutBlank() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("about:blank")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_unavailableFavicon() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("favicon-unavailable.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_errorPageEnabled() {
+ WebEngine.settings.errorPageEnabled = true
+
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("http://url.invalid")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadFailed(20000))
+ verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_errorPageDisabled() {
+ WebEngine.settings.errorPageEnabled = false
+
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("http://url.invalid")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadFailed(20000))
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_bestFavicon() {
+ compare(iconChangedSpy.count, 0)
+ var url, iconUrl
+
+ url = Qt.resolvedUrl("favicon-misc.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ // Touch icon is ignored
+ compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico"))
+ compare(favicon.width, 32)
+ compare(favicon.height, 32)
+
+ iconChangedSpy.clear()
+
+ url = Qt.resolvedUrl("favicon-shortcut.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ verify(iconChangedSpy.count >= 1)
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+
+ // If the icon URL is empty we have to wait for
+ // the second iconChanged signal that propagates the expected URL
+ if (iconUrl == Qt.resolvedUrl("")) {
+ tryCompare(iconChangedSpy, "count", 2)
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ }
+
+ compare(iconUrl, Qt.resolvedUrl("icons/qt144.png"))
+ compare(favicon.width, 144)
+ compare(favicon.height, 144)
+ }
+
+ function test_touchIcon() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("favicon-touch.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ compare(favicon.width, 0)
+ compare(favicon.height, 0)
+
+ WebEngine.settings.touchIconsEnabled = true
+
+ url = Qt.resolvedUrl("favicon-touch.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, Qt.resolvedUrl("icons/qt144.png"))
+ compare(iconChangedSpy.count, 1)
+ compare(favicon.width, 144)
+ compare(favicon.height, 144)
+ }
+
+ function test_multiIcon() {
+ compare(iconChangedSpy.count, 0)
+
+ var url = Qt.resolvedUrl("favicon-multi.html")
+ webEngineView.url = url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+ compare(favicon.width, 64)
+ compare(favicon.height, 64)
+ }
+
+ function test_faviconProvider_data() {
+ return [
+ { tag: "multi 8x8", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 8, value: 16 },
+ { tag: "multi 16x16", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 16, value: 16 },
+ { tag: "multi 17x17", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 17, value: 32 },
+ { tag: "multi 31x31", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 31, value: 32 },
+ { tag: "multi 32x32", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 32, value: 32 },
+ { tag: "multi 33x33", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 33, value: 64 },
+ { tag: "multi 64x64", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 64, value: 64 },
+ { tag: "multi 128x128", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 128, value: 128 },
+ { tag: "multi 255x255", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 255, value: 255 },
+ { tag: "multi 256x256", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 256, value: 255 },
+ { tag: "candidate 8x8", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 8, value: 16 },
+ { tag: "candidate 16x16", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 16, value: 16 },
+ { tag: "candidate 17x17", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 17, value: 32 },
+ { tag: "candidate 31x31", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 31, value: 32 },
+ { tag: "candidate 32x32", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 32, value: 32 },
+ { tag: "candidate 33x33", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 33, value: 64 },
+ { tag: "candidate 64x64", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 64, value: 64 },
+ { tag: "candidate 128x128", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 128, value: 128 },
+ { tag: "candidate 255x255", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 255, value: 255 },
+ { tag: "candidate 256x256", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 256, value: 255 },
+ ];
+ }
+
+ function test_faviconProvider(row) {
+ var faviconImage = Qt.createQmlObject("
+ import QtQuick 2.5\n
+ Image { sourceSize: Qt.size(width, height) }", testCase)
+
+ compare(iconChangedSpy.count, 0)
+
+ webEngineView.url = row.url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+
+ faviconImage.width = row.size / Screen.devicePixelRatio
+ faviconImage.height = row.size / Screen.devicePixelRatio
+ faviconImage.source = webEngineView.icon
+
+ var pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], row.value)
+
+ faviconImage.destroy()
+ }
+
+ function test_dynamicFavicon() {
+ var faviconImage = Qt.createQmlObject("
+ import QtQuick 2.5\n
+ Image { width: 16; height: 16; sourceSize: Qt.size(width, height); }", testCase)
+ faviconImage.source = Qt.binding(function() { return webEngineView.icon; });
+
+ var colors = [
+ {"url": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==", "r": 255, "g": 0, "b": 0},
+ {"url": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg==", "r": 0, "g": 255, "b": 0},
+ {"url": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==", "r": 0, "g": 0, "b": 255},
+ ];
+ var pixel;
+
+ compare(iconChangedSpy.count, 0);
+ webEngineView.loadHtml(
+ "<html>" +
+ "<link rel='icon' type='image/png' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII='/>" +
+ "</html>"
+ );
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(iconChangedSpy, "count", 1);
+
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], 0);
+ compare(pixel[1], 0);
+ compare(pixel[2], 0);
+
+ for (var i = 0; i < colors.length; ++i) {
+ iconChangedSpy.clear();
+ runJavaScript("document.getElementsByTagName('link')[0].href = 'data:image/png;base64," + colors[i]["url"] + "';");
+ tryCompare(faviconImage, "source", "image://favicon/data:image/png;base64," + colors[i]["url"]);
+ compare(iconChangedSpy.count, 1);
+
+ pixel = getFaviconPixel(faviconImage);
+ compare(pixel[0], colors[i]["r"]);
+ compare(pixel[1], colors[i]["g"]);
+ compare(pixel[2], colors[i]["b"]);
+ }
+
+ faviconImage.destroy()
+ }
+
+ function test_touchIconWithSameURL()
+ {
+ WebEngine.settings.touchIconsEnabled = false;
+
+ var icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
+
+ webEngineView.loadHtml(
+ "<html>" +
+ "<link rel='icon' type='image/png' href='" + icon + "'/>" +
+ "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" +
+ "</html>"
+ );
+ verify(webEngineView.waitForLoadSucceeded());
+
+ // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled.
+ tryCompare(iconChangedSpy, "count", 1);
+ compare(webEngineView.icon.toString().replace(/^image:\/\/favicon\//, ''), icon);
+
+ iconChangedSpy.clear();
+
+ webEngineView.loadHtml(
+ "<html>" +
+ "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" +
+ "</html>"
+ );
+ verify(webEngineView.waitForLoadSucceeded());
+
+ // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon
+ // was loaded previously.
+ tryCompare(iconChangedSpy, "count", 1);
+ verify(!webEngineView.icon.toString().replace(/^image:\/\/favicon\//, ''));
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_faviconDownload.qml b/tests/auto/quick/qmltests2/data/tst_faviconDownload.qml
new file mode 100644
index 000000000..7d9c39814
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_faviconDownload.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** 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.3
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ function removeFaviconProviderPrefix(url) {
+ return url.toString().substring(16)
+ }
+
+ SignalSpy {
+ id: iconChangedSpy
+ target: webEngineView
+ signalName: "iconChanged"
+ }
+
+ TestCase {
+ id: testCase
+ name: "WebEngineFaviconDownload"
+
+ function init() {
+ WebEngine.settings.autoLoadIconsForPage = true
+ WebEngine.settings.touchIconsEnabled = false
+
+ if (webEngineView.icon != '') {
+ // If this is not the first test, then load a blank page without favicon, restoring the initial state.
+ webEngineView.url = 'about:blank'
+ verify(webEngineView.waitForLoadSucceeded())
+ iconChangedSpy.wait()
+ }
+
+ iconChangedSpy.clear()
+ }
+
+ function cleanupTestCase() {
+ WebEngine.settings.autoLoadIconsForPage = true
+ WebEngine.settings.touchIconsEnabled = false
+ }
+
+ function test_downloadIconsDisabled_data() {
+ return [
+ { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html") },
+ { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html") },
+ { tag: "single", url: Qt.resolvedUrl("favicon-single.html") },
+ { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html") },
+ { tag: "unavailable", url: Qt.resolvedUrl("favicon-unavailable.html") },
+ ];
+ }
+
+ function test_downloadIconsDisabled(row) {
+ WebEngine.settings.autoLoadIconsForPage = false
+
+ compare(iconChangedSpy.count, 0)
+
+ webEngineView.url = row.url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ compare(iconChangedSpy.count, 0)
+
+ var iconUrl = webEngineView.icon
+ compare(iconUrl, Qt.resolvedUrl(""))
+ }
+
+ function test_downloadTouchIconsEnabled_data() {
+ return [
+ { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
+ { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
+ { tag: "single", url: Qt.resolvedUrl("favicon-single.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt32.ico") },
+ { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") },
+ ];
+ }
+
+ function test_downloadTouchIconsEnabled(row) {
+ WebEngine.settings.touchIconsEnabled = true
+
+ compare(iconChangedSpy.count, 0)
+
+ webEngineView.url = row.url
+ verify(webEngineView.waitForLoadSucceeded())
+
+ iconChangedSpy.wait()
+ compare(iconChangedSpy.count, 1)
+
+ var iconUrl = removeFaviconProviderPrefix(webEngineView.icon)
+ compare(iconUrl, row.expectedIconUrl)
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qmltests2/data/tst_filePicker.qml b/tests/auto/quick/qmltests2/data/tst_filePicker.qml
new file mode 100644
index 000000000..5b963c7bf
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_filePicker.qml
@@ -0,0 +1,326 @@
+/****************************************************************************
+**
+** 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.2
+import "../../qmltests/data" 1.0
+import "../mock-delegates/TestParams" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+ property var titleChanges: []
+
+ function driveLetter() {
+ if (Qt.platform.os !== "windows")
+ return "";
+ return "C:/";
+ }
+
+ SignalSpy {
+ id: titleSpy
+ target: webEngineView
+ signalName: "titleChanged"
+ }
+ SignalSpy {
+ id: terminationSpy
+ target: webEngineView
+ signalName: "renderProcessTerminated"
+ }
+
+ onTitleChanged: { titleChanges.push(webEngineView.title) }
+
+ TestCase {
+ id: testCase
+ name: "WebEngineViewSingleFileUpload"
+ when: windowShown
+
+ function init() {
+ FilePickerParams.filePickerOpened = false
+ FilePickerParams.selectFiles = false
+ FilePickerParams.selectedFilesUrl = []
+ FilePickerParams.nameFilters = []
+ titleSpy.clear()
+ terminationSpy.clear()
+ titleChanges = []
+ }
+
+ function cleanup() {
+ // Test that the render process doesn't crash, and make sure if it does it does so now.
+ wait(100)
+ verify(terminationSpy.count == 0, "Render process didn't self terminate")
+
+ // FIXME: Almost every second url loading progress does get stuck at about 90 percent, so the loadFinished signal won't arrive.
+ // This cleanup function is a workaround for this problem.
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ webEngineView.waitForLoadSucceeded()
+ }
+
+ function test_acceptSingleFileSelection_data() {
+ return [
+ { tag: "test.txt", input: "test.txt", expected: "Failed to Upload" },
+ { tag: driveLetter() + "/test.txt", input: driveLetter() + "/test.txt", expected: "test.txt" },
+ { 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: "t%65st.txt" },
+ { tag: "file://" + driveLetter() + "test.txt", input: "file://" + driveLetter() + "test.txt", expected: "Failed to Upload" },
+ { 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
+ 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);
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(webEngineView, "title", "about:blank");
+ compare(titleChanges[titleChanges.length-2], 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; });
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(webEngineView, "title", "about:blank");
+ compare(titleChanges[titleChanges.length-2], row.expected);
+ webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
+ }
+
+ function test_acceptMultipleFilesSelection() {
+ webEngineView.url = Qt.resolvedUrl("multifileupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ FilePickerParams.selectFiles = true
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html"))
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test2.html"))
+
+ keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true)
+ tryCompare(webEngineView, "title", "test1.html,test2.html")
+ }
+
+ function test_acceptDirectory() {
+ webEngineView.url = Qt.resolvedUrl("directoryupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ webEngineView.runJavaScript(
+ "let relativePathCount = 0;" +
+ "document.getElementById('upfile').addEventListener('change', function(event) {" +
+ " let files = event.target.files;" +
+ " for (let i = 0; i < files.length; i++) {" +
+ " if (files[i].webkitRelativePath != '')" +
+ " relativePathCount++;" +
+ " }" +
+ "}, false);")
+
+ FilePickerParams.selectFiles = true
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data"))
+
+ keyClick(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true)
+ // Check that the title is a file list (eg. "test1.html,test2.html")
+ tryVerify(function() { return webEngineView.title.match("^([^,]+,)+[^,]+$"); })
+
+ var relativePathCount = 0;
+ runJavaScript("relativePathCount", function(result) { relativePathCount = result; });
+ // The number of files in data directory may vary
+ tryVerify(function() { return relativePathCount > 0; });
+ }
+
+ function test_reject() {
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ titleSpy.clear()
+ keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ wait(100)
+ compare(titleSpy.count, 0)
+ }
+
+ function test_acceptMultipleFilesWithCustomDialog_data() {
+ return [
+ { 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
+ webEngineView.url = Qt.resolvedUrl("multifileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl = row.input;
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryCompare(webEngineView, "title", row.expectedValue);
+
+
+ // 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("multifileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryVerify(function() { return finished; });
+ 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: "\\\\applib\\products\\a%2Db\\ abc%5F9\\t.est\\test.txt", expected: "test.txt"},
+ { tag: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/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: "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: "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: "test.txt"},
+ ];
+ }
+
+ 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);
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(webEngineView, "title", "about:blank");
+ compare(titleChanges[titleChanges.length-2], 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; });
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(webEngineView, "title", "about:blank");
+ compare(titleChanges[titleChanges.length-2], row.expected);
+ webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
+ }
+
+ function test_acceptFileTypes_data() {
+ return [
+ { tag: "CustomSuffix", input: ".pug", expected: ".pug", exactMatch: false},
+ { tag: "CustomMime", input: "dog/pug", expected: "Accepted types ()", exactMatch: true},
+ { tag: "CustomGlob", input: "dog/*", expected: "Accepted types ()", exactMatch: true},
+ { tag: "Invalid", input: "---", expected: undefined, exactMatch: true},
+ { tag: "Jpeg", input: "image/jpeg", expected: ".jpeg", exactMatch: false}
+ ];
+ }
+
+ function test_acceptFileTypes(row) {
+ var expectedFileName;
+
+ webEngineView.url = Qt.resolvedUrl("accepttypes.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ webEngineView.runJavaScript("setAcceptType('" + row.input + "');");
+ tryCompare(webEngineView, "title", row.input);
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+
+ if (row.exactMatch)
+ compare(FilePickerParams.nameFilters[0], row.expected);
+ else
+ verify(FilePickerParams.nameFilters[0].includes(row.expected));
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_inputMethod.qml b/tests/auto/quick/qmltests2/data/tst_inputMethod.qml
new file mode 100644
index 000000000..00f85cb71
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_inputMethod.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ testSupport: WebEngineTestSupport { }
+
+ TestCase {
+ id: testCase
+ name: "WebEngineViewInputMethod"
+ when: windowShown
+
+ function init() {
+ testSupport.testInputContext.create();
+ }
+
+ function cleanup() {
+ testSupport.testInputContext.release();
+ }
+
+ function test_softwareInputPanel() {
+ verify(!Qt.inputMethod.visible);
+ webEngineView.loadHtml(
+ "<html><body>" +
+ " <form><input id='textInput' type='text' /></form>" +
+ "</body></html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ verify(!getActiveElementId());
+ verify(!Qt.inputMethod.visible);
+
+ // Show input panel
+ webEngineView.runJavaScript("document.getElementById('textInput').focus()");
+ webEngineView.verifyElementHasFocus("textInput");
+ tryVerify(function() { return Qt.inputMethod.visible; });
+
+ // Hide input panel
+ webEngineView.runJavaScript("document.getElementById('textInput').blur()");
+ verify(!getActiveElementId());
+ tryVerify(function() { return !Qt.inputMethod.visible; });
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml
new file mode 100644
index 000000000..a521ea0d6
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_javaScriptDialogs.qml
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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.2
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+import "../mock-delegates/TestParams" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ anchors.fill: parent
+
+ testSupport: WebEngineTestSupport {
+ property bool windowCloseRejectedSignalEmitted: false
+
+ function waitForWindowCloseRejected() {
+ return _waitFor(function () {
+ return testSupport.windowCloseRejectedSignalEmitted;
+ });
+ }
+
+ onWindowCloseRejected: {
+ windowCloseRejectedSignalEmitted = true;
+ }
+ }
+
+ TestCase {
+ id: test
+ name: "WebEngineViewJavaScriptDialogs"
+ when: windowShown
+
+ function init() {
+ JSDialogParams.dialogMessage = "";
+ JSDialogParams.dialogTitle = "";
+ JSDialogParams.dialogCount = 0;
+ JSDialogParams.shouldAcceptDialog = true;
+ }
+
+ function test_alert() {
+ webEngineView.url = Qt.resolvedUrl("alert.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(JSDialogParams.dialogCount, 1)
+ compare(JSDialogParams.dialogMessage, "Hello Qt")
+ verify(JSDialogParams.dialogTitle.indexOf("Javascript Alert -") === 0)
+ }
+
+ function test_confirm() {
+ webEngineView.url = Qt.resolvedUrl("confirm.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(JSDialogParams.dialogMessage, "Confirm test")
+ compare(JSDialogParams.dialogCount, 1)
+ compare(webEngineView.title, "ACCEPTED")
+ JSDialogParams.shouldAcceptDialog = false
+ webEngineView.reload()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(JSDialogParams.dialogCount, 2)
+ compare(webEngineView.title, "REJECTED")
+
+ }
+ function readMousePressRecieved() {
+ var mousePressReceived;
+ runJavaScript("window.mousePressReceived", function(result) {
+ mousePressReceived = result;
+ });
+
+ _waitFor(function() { return mousePressReceived != undefined; });
+ return mousePressReceived;
+ }
+
+ function simulateUserGesture() {
+ // A user gesture after page load is required since Chromium 60 to allow showing
+ // an onbeforeunload dialog.
+ // See https://www.chromestatus.com/feature/5082396709879808
+ mouseClick(webEngineView, 10, 10, Qt.LeftButton)
+
+ tryVerify(readMousePressRecieved)
+ }
+
+ function test_confirmClose() {
+ webEngineView.url = Qt.resolvedUrl("confirmclose.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ webEngineView.windowCloseRequestedSignalEmitted = false;
+ JSDialogParams.shouldAcceptDialog = true;
+
+ simulateUserGesture()
+ webEngineView.triggerWebAction(WebEngineView.RequestClose);
+ verify(webEngineView.waitForWindowCloseRequested());
+
+ // Navigate away from page with onbeforeunload handler,
+ // otherwise it would trigger an extra dialog request when
+ // navigating in the subsequent test.
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ compare(JSDialogParams.dialogCount, 2)
+ }
+
+ function test_rejectClose() {
+ webEngineView.url = Qt.resolvedUrl("confirmclose.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ webEngineView.testSupport.windowCloseRejectedSignalEmitted = false;
+ JSDialogParams.shouldAcceptDialog = false;
+
+ simulateUserGesture()
+ webEngineView.triggerWebAction(WebEngineView.RequestClose);
+ verify(webEngineView.testSupport.waitForWindowCloseRejected());
+
+ // Navigate away from page with onbeforeunload handler,
+ // otherwise it would trigger an extra dialog request when
+ // navigating in the subsequent test.
+ JSDialogParams.shouldAcceptDialog = true;
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ compare(JSDialogParams.dialogCount, 2)
+ }
+
+ function test_prompt() {
+ JSDialogParams.inputForPrompt = "tQ olleH"
+ webEngineView.url = Qt.resolvedUrl("prompt.html")
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(JSDialogParams.dialogCount, 1)
+ compare(webEngineView.title, "tQ olleH")
+ JSDialogParams.shouldAcceptDialog = false
+ webEngineView.reload()
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(JSDialogParams.dialogCount, 2)
+ compare(webEngineView.title, "null")
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_linkHovered.qml b/tests/auto/quick/qmltests2/data/tst_linkHovered.qml
new file mode 100644
index 000000000..faf943c55
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_linkHovered.qml
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** 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.2
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+ focus: true
+
+ property string lastUrl
+
+ testSupport: WebEngineTestSupport { }
+
+ SignalSpy {
+ id: loadVisuallyCommittedSpy
+ target: webEngineView.testSupport
+ signalName: "loadVisuallyCommitted"
+ }
+
+ SignalSpy {
+ id: linkHoveredSpy
+ target: webEngineView
+ signalName: "linkHovered"
+ }
+
+ onLinkHovered: {
+ webEngineView.lastUrl = hoveredUrl
+ }
+
+ TestCase {
+ name: "DesktopWebEngineViewLinkHovered"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ webEngineView.lastUrl = "";
+ loadVisuallyCommittedSpy.clear();
+ linkHoveredSpy.clear();
+ }
+
+ function test_linkHovered() {
+ compare(linkHoveredSpy.count, 0);
+ mouseMove(webEngineView, 100, 300)
+ webEngineView.url = Qt.resolvedUrl("test2.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ // We get a linkHovered signal with empty hoveredUrl after page load
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 1);
+ compare(webEngineView.lastUrl, "")
+
+ // Wait for the page to be rendered before trying to test based on input events
+ loadVisuallyCommittedSpy.wait();
+
+ mouseMove(webEngineView, 100, 100)
+ linkHoveredSpy.wait(12000);
+ compare(linkHoveredSpy.count, 2);
+ compare(webEngineView.lastUrl, Qt.resolvedUrl("test1.html"))
+ mouseMove(webEngineView, 100, 300)
+ linkHoveredSpy.wait(12000);
+ compare(linkHoveredSpy.count, 3);
+ compare(webEngineView.lastUrl, "")
+ }
+
+ function test_linkHoveredDoesntEmitRepeated() {
+ compare(linkHoveredSpy.count, 0);
+ webEngineView.url = Qt.resolvedUrl("test2.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ // We get a linkHovered signal with empty hoveredUrl after page load
+ linkHoveredSpy.wait();
+ compare(linkHoveredSpy.count, 1);
+ compare(webEngineView.lastUrl, "")
+
+ // Wait for the page to be rendered before trying to test based on input events
+ loadVisuallyCommittedSpy.wait();
+
+ for (var i = 0; i < 100; i += 10)
+ mouseMove(webEngineView, 100, 100 + i)
+
+ linkHoveredSpy.wait(12000);
+ compare(linkHoveredSpy.count, 2);
+ compare(webEngineView.lastUrl, Qt.resolvedUrl("test1.html"))
+
+ for (var i = 0; i < 100; i += 10)
+ mouseMove(webEngineView, 100, 300 + i)
+
+ linkHoveredSpy.wait(12000);
+ compare(linkHoveredSpy.count, 3);
+ compare(webEngineView.lastUrl, "")
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_loadFail.qml b/tests/auto/quick/qmltests2/data/tst_loadFail.qml
new file mode 100644
index 000000000..298f5b0fe
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_loadFail.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** 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.2
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+
+ property var unavailableUrl: Qt.resolvedUrl("file_that_does_not_exist.html")
+ property var loadRequestArray: []
+
+ testSupport: WebEngineTestSupport {
+ property var errorPageLoadStatus: null
+
+ function waitForErrorPageLoadSucceeded() {
+ var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus })
+ testSupport.errorPageLoadStatus = null
+ return success
+ }
+
+ errorPage.onLoadingChanged: {
+ errorPageLoadStatus = loadRequest.status
+
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ "url": loadRequest.url.toString(),
+ "errorDomain": loadRequest.errorDomain,
+ "isErrorPage": true
+ })
+ }
+ }
+
+ onLoadingChanged: {
+ if (loadRequest.status == WebEngineView.LoadFailedStatus) {
+ test.compare(loadRequest.url, unavailableUrl)
+ test.compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain)
+ }
+
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ "url": loadRequest.url.toString(),
+ "errorDomain": loadRequest.errorDomain,
+ "isErrorPage": false
+ })
+ }
+
+ TestCase {
+ id: test
+ name: "WebEngineViewLoadFail"
+
+ function test_fail() {
+ WebEngine.settings.errorPageEnabled = false
+ webEngineView.url = unavailableUrl
+ verify(webEngineView.waitForLoadFailed())
+ }
+
+ function test_fail_url() {
+ WebEngine.settings.errorPageEnabled = false
+ var url = Qt.resolvedUrl("test1.html")
+ webEngineView.url = url
+ compare(webEngineView.url, url)
+ verify(webEngineView.waitForLoadSucceeded())
+ compare(webEngineView.url, url)
+
+ webEngineView.url = unavailableUrl
+ compare(webEngineView.url, unavailableUrl)
+ verify(webEngineView.waitForLoadFailed())
+ // When error page is disabled in case of LoadFail the entry of the unavailable page is not stored.
+ // We expect the url of the previously loaded page here.
+ compare(webEngineView.url, url)
+ }
+
+ function test_error_page() {
+ WebEngine.settings.errorPageEnabled = true
+ webEngineView.url = unavailableUrl
+
+ // Loading of the error page must be successful
+ verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded())
+
+ var loadRequest = null
+ compare(loadRequestArray.length, 4)
+
+ // Start to load unavailableUrl
+ loadRequest = loadRequestArray[0]
+ compare(loadRequest.status, WebEngineView.LoadStartedStatus)
+ compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain)
+ compare(loadRequest.url, unavailableUrl)
+ verify(!loadRequest.isErrorPage)
+
+ // Loading of the unavailableUrl must fail
+ loadRequest = loadRequestArray[3]
+ compare(loadRequest.status, WebEngineView.LoadFailedStatus)
+ compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain)
+ compare(loadRequest.url, unavailableUrl)
+ verify(!loadRequest.isErrorPage)
+
+ // error page load is done inside main load through test support
+ // Start to load error page
+ loadRequest = loadRequestArray[1]
+ compare(loadRequest.status, WebEngineView.LoadStartedStatus)
+ compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain)
+ compare(loadRequest.url, "chrome-error://chromewebdata/")
+ verify(loadRequest.isErrorPage)
+
+ // Loading of the error page must be successful
+ loadRequest = loadRequestArray[2]
+ compare(loadRequest.status, WebEngineView.LoadSucceededStatus)
+ compare(loadRequest.errorDomain, WebEngineView.NoErrorDomain)
+ compare(loadRequest.url, "chrome-error://chromewebdata/")
+ verify(loadRequest.isErrorPage)
+
+ compare(webEngineView.url, unavailableUrl)
+ compare(webEngineView.title, unavailableUrl)
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_mouseClick.qml b/tests/auto/quick/qmltests2/data/tst_mouseClick.qml
new file mode 100644
index 000000000..6c314d44c
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_mouseClick.qml
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 200
+
+ testSupport: WebEngineTestSupport {
+ function mouseMultiClick(item, x, y, clickCount) {
+ if (!item)
+ qtest_fail("No item given to mouseMultiClick", 1);
+
+ if (x === undefined)
+ x = item.width / 2;
+ if (y === undefined)
+ y = item.height / 2;
+ if (!testEvent.mouseMultiClick(item, x, y, clickCount))
+ qtest_fail("window not shown", 2);
+ }
+
+ function mouseDoubleClick(item, x, y) {
+ mouseMultiClick(item, x, y, 2);
+ }
+
+ function mouseTripleClick(item, x, y) {
+ mouseMultiClick(item, x, y, 3);
+ }
+
+ function mouseQuadraClick(item, x, y) {
+ mouseMultiClick(item, x, y, 4);
+ }
+ }
+
+
+ TestCase {
+ id: testCase
+ name: "WebEngineViewMouseClick"
+ when: windowShown
+
+ function test_singleClick() {
+ webEngineView.settings.focusOnNavigationEnabled = false;
+ webEngineView.loadHtml("<html><body>" +
+ "<form><input id='input' width='150' type='text' value='The Qt Company' /></form>" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+ verify(!getActiveElementId());
+
+ var center = getElementCenter("input");
+ mouseClick(webEngineView, center.x, center.y);
+ verifyElementHasFocus("input");
+ compare(getTextSelection(), "");
+ }
+
+ function test_doubleClick() {
+ webEngineView.settings.focusOnNavigationEnabled = true;
+ webEngineView.loadHtml("<html><body onload='document.getElementById(\"input\").focus()'>" +
+ "<form><input id='input' width='150' type='text' value='The Qt Company' /></form>" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ var center = getElementCenter("input");
+ webEngineView.testSupport.mouseDoubleClick(webEngineView, center.x, center.y);
+ verifyElementHasFocus("input");
+ tryVerify(function() { return getTextSelection() == "Company" });
+
+ mouseClick(webEngineView, center.x, center.y);
+ tryVerify(function() { return getTextSelection() == "" });
+ }
+
+ function test_tripleClick() {
+ webEngineView.settings.focusOnNavigationEnabled = true;
+ webEngineView.loadHtml("<html><body onload='document.getElementById(\"input\").focus()'>" +
+ "<form><input id='input' width='150' type='text' value='The Qt Company' /></form>" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ var center = getElementCenter("input");
+ webEngineView.testSupport.mouseTripleClick(webEngineView, center.x, center.y);
+ verifyElementHasFocus("input");
+ tryVerify(function() { return getTextSelection() == "The Qt Company" });
+
+ mouseClick(webEngineView, center.x, center.y);
+ tryVerify(function() { return getTextSelection() == "" });
+ }
+
+ function test_quadraClick() {
+ webEngineView.settings.focusOnNavigationEnabled = true;
+ webEngineView.loadHtml("<html><body onload='document.getElementById(\"input\").focus()'>" +
+ "<form><input id='input' width='150' type='text' value='The Qt Company' /></form>" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ var center = getElementCenter("input");
+ webEngineView.testSupport.mouseQuadraClick(webEngineView, center.x, center.y);
+ verifyElementHasFocus("input");
+ tryVerify(function() { return getTextSelection() == "" });
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/data/tst_viewSoure.qml b/tests/auto/quick/qmltests2/data/tst_viewSoure.qml
new file mode 100644
index 000000000..28f7e8344
--- /dev/null
+++ b/tests/auto/quick/qmltests2/data/tst_viewSoure.qml
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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
+import QtWebEngine.testsupport 1.0
+import "../../qmltests/data" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+
+ property var viewRequest: null
+ property var loadRequestArray: []
+
+ testSupport: WebEngineTestSupport {
+ errorPage.onLoadingChanged: {
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ "url": loadRequest.url
+ })
+ }
+ }
+
+ onLoadingChanged: {
+ loadRequestArray.push({
+ "status": loadRequest.status,
+ "url": loadRequest.url
+ });
+ }
+
+ 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: testCase
+ name: "WebEngineViewSource"
+
+ function init() {
+ webEngineView.loadStatus = null;
+ webEngineView.url = Qt.resolvedUrl("test1.html");
+ tryCompare(webEngineView, "loadStatus", WebEngineView.LoadSucceededStatus);
+ webEngineView.loadStatus = null;
+
+ newViewRequestedSpy.clear();
+ titleChangedSpy.clear();
+ viewRequest = null;
+ }
+
+ 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: "http://non.existent/", title: "non.existent" },
+ { tag: "view-source:non.existent", userInputUrl: "view-source:non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" },
+ ];
+ }
+
+ function test_viewSourceURL(row) {
+ loadRequestArray = [];
+ WebEngine.settings.errorPageEnabled = true
+ webEngineView.url = row.userInputUrl;
+
+
+ if (row.loadSucceed) {
+ tryVerify(function() { return loadRequestArray.length == 2 });
+ compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus);
+ } else {
+ tryVerify(function() { return loadRequestArray.length == 4 }, 90000);
+ // error page load is done inside main load through test support
+ compare(loadRequestArray[2].status, WebEngineView.LoadSucceededStatus);
+ compare(loadRequestArray[2].url, "chrome-error://chromewebdata/")
+ compare(loadRequestArray[3].status, WebEngineView.LoadFailedStatus);
+ }
+ tryVerify(function() { return titleChangedSpy.count == 1; });
+
+ compare(webEngineView.url, row.url);
+ tryCompare(webEngineView, "title", row.title);
+ if (row.loadSucceed) {
+ verify(!webEngineView.action(WebEngineView.ViewSource).enabled);
+ } else {
+ verify(webEngineView.action(WebEngineView.ViewSource).enabled);
+ }
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
new file mode 100644
index 000000000..4ba3be4b9
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+// Both dialogs are basically expected to behave in the same way from an API point of view
+ConfirmDialog
+{
+}
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
new file mode 100644
index 000000000..9933fc2f7
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 QtQml 2.0
+import QtTest 1.0
+import "../../TestParams" 1.0
+
+QtObject {
+ property string text;
+ property string title;
+ signal accepted();
+ signal rejected();
+
+ function open() {
+ JSDialogParams.dialogTitle = title;
+ JSDialogParams.dialogMessage = text;
+ JSDialogParams.dialogCount++;
+ if (JSDialogParams.shouldAcceptDialog)
+ accepted()
+ else
+ rejected()
+ }
+}
+
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
new file mode 100644
index 000000000..745f533f5
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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.2
+import "../../TestParams" 1.0
+
+QtObject {
+ property bool selectMultiple: false;
+ property bool selectExisting: false;
+ property bool selectFolder: false;
+ property var nameFilters: [];
+
+ signal filesSelected(var fileList);
+ signal rejected();
+
+ function open() {
+ FilePickerParams.filePickerOpened = true;
+ FilePickerParams.nameFilters = nameFilters;
+ if (FilePickerParams.selectFiles)
+ filesSelected(FilePickerParams.selectedFilesUrl)
+ else
+ rejected()
+ }
+}
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
new file mode 100644
index 000000000..36efa7680
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtQuick.Controls 1.4 as Controls
+
+Controls.Menu {
+ id: menu
+ signal done()
+
+ // Use private API for now
+ onAboutToHide: doneTimer.start()
+
+ // WORKAROUND On Mac the Menu may be destroyed before the MenuItem
+ // is actually triggered (see qtbase commit 08cc9b9991ae9ab51)
+ Timer {
+ id: doneTimer
+ interval: 100
+ onTriggered: menu.done()
+ }
+}
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
new file mode 100644
index 000000000..e61f4c230
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtQuick.Controls 1.4 as Controls
+
+Controls.MenuItem { }
+
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
new file mode 100644
index 000000000..7c5b16eab
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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 QtQml 2.0
+import QtTest 1.0
+import "../../TestParams" 1.0
+
+QtObject {
+ property string text;
+ property string title;
+ signal accepted();
+ signal rejected();
+ signal input(string text);
+ signal closing();
+
+ function open() {
+ JSDialogParams.dialogTitle = title;
+ JSDialogParams.dialogMessage = text;
+ JSDialogParams.dialogCount++;
+ if (JSDialogParams.shouldAcceptDialog) {
+ input(JSDialogParams.inputForPrompt)
+ accepted()
+ } else {
+ rejected()
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
new file mode 100644
index 000000000..cf8ac0512
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/QtWebEngine/Controls1Delegates/qmldir
@@ -0,0 +1,5 @@
+module QtWebEngine.UIDelegates
+AlertDialog 1.0 AlertDialog.qml
+ConfirmDialog 1.0 ConfirmDialog.qml
+FilePicker 1.0 FilePicker.qml
+PromptDialog 1.0 PromptDialog.qml
diff --git a/tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml b/tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml
new file mode 100644
index 000000000..02b0da1d4
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/TestParams/FilePickerParams.qml
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+pragma Singleton
+import QtQuick 2.0
+
+QtObject {
+ property var selectedFilesUrl: [];
+ property bool selectFiles: false;
+ property bool filePickerOpened: false;
+ property var nameFilters: [];
+}
diff --git a/tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml b/tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml
new file mode 100644
index 000000000..70696803c
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/TestParams/JSDialogParams.qml
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+pragma Singleton
+import QtQml 2.0
+
+QtObject {
+ property string dialogMessage: "";
+ property string dialogTitle: "";
+ property bool shouldAcceptDialog: true;
+ property string inputForPrompt;
+ property int dialogCount: 0
+}
diff --git a/tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir b/tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir
new file mode 100644
index 000000000..5807f1e6e
--- /dev/null
+++ b/tests/auto/quick/qmltests2/mock-delegates/TestParams/qmldir
@@ -0,0 +1,4 @@
+# QML module so that the autotests can set testing parameters
+module TestParams
+singleton FilePickerParams 1.0 FilePickerParams.qml
+singleton JSDialogParams 1.0 JSDialogParams.qml
diff --git a/tests/auto/quick/qmltests2/qmltests2.pro b/tests/auto/quick/qmltests2/qmltests2.pro
new file mode 100644
index 000000000..98e33972b
--- /dev/null
+++ b/tests/auto/quick/qmltests2/qmltests2.pro
@@ -0,0 +1,79 @@
+include(../tests.pri)
+
+QT += qmltest
+
+IMPORTPATH += $$PWD/data
+
+OTHER_FILES += \
+ $$PWD/data/accepttypes.html \
+ $$PWD/data/alert.html \
+ $$PWD/data/confirm.html \
+ $$PWD/data/confirmclose.html \
+ $$PWD/data/directoryupload.html \
+ $$PWD/data/favicon.html \
+ $$PWD/data/favicon2.html \
+ $$PWD/data/favicon-candidates-gray.html \
+ $$PWD/data/favicon-misc.html \
+ $$PWD/data/favicon-multi.html \
+ $$PWD/data/favicon-multi-gray.html \
+ $$PWD/data/favicon-single.html \
+ $$PWD/data/favicon-shortcut.html \
+ $$PWD/data/favicon-touch.html \
+ $$PWD/data/favicon-unavailable.html \
+ $$PWD/data/multifileupload.html \
+ $$PWD/data/prompt.html \
+ $$PWD/data/singlefileupload.html \
+ $$PWD/data/test1.html \
+ $$PWD/data/test2.html \
+ $$PWD/data/titleupdate.js \
+ $$PWD/data/tst_favicon.qml \
+ $$PWD/data/tst_faviconDownload.qml \
+ $$PWD/data/tst_inputMethod.qml \
+ $$PWD/data/tst_javaScriptDialogs.qml \
+ $$PWD/data/tst_linkHovered.qml \
+ $$PWD/data/tst_loadFail.qml \
+ $$PWD/data/tst_mouseClick.qml \
+ $$PWD/data/tst_viewSource.qml \
+ $$PWD/data/icons/favicon.png \
+ $$PWD/data/icons/gray128.png \
+ $$PWD/data/icons/gray16.png \
+ $$PWD/data/icons/gray255.png \
+ $$PWD/data/icons/gray32.png \
+ $$PWD/data/icons/gray64.png \
+ $$PWD/data/icons/grayicons.ico \
+ $$PWD/data/icons/qt144.png \
+ $$PWD/data/icons/qt32.ico \
+ $$PWD/data/icons/qtmulti.ico \
+ $$PWD/data/icons/small-favicon.png \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/AlertDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/ConfirmDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/FilePicker.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/Menu.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/MenuItem.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/PromptDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/qmldir \
+ $$PWD/mock-delegates/TestParams/FilePickerParams.qml \
+ $$PWD/mock-delegates/TestParams/JSDialogParams.qml \
+ $$PWD/mock-delegates/TestParams/qmldir \
+
+load(qt_build_paths)
+DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$PWD$${QMAKE_DIR_SEP}data)\\\"
+
+!qtConfig(webengine-testsupport) {
+ PLUGIN_EXTENSION = .so
+ PLUGIN_PREFIX = lib
+ osx: PLUGIN_PREFIX = .dylib
+ win32 {
+ PLUGIN_EXTENSION = .dll
+ PLUGIN_PREFIX =
+ }
+
+ TESTSUPPORT_MODULE = $$shell_path($$[QT_INSTALL_QML]/QtWebEngine/testsupport/$${PLUGIN_PREFIX}qtwebenginetestsupportplugin$${PLUGIN_EXTENSION})
+ BUILD_DIR = $$shell_path($$clean_path($$OUT_PWD/../../../..))
+ SRC_DIR = $$shell_path($$clean_path($$PWD/../../../..))
+
+ warning("QML Test Support API is disabled. This means some QML tests that use Test Support API will fail.")
+ warning("Use the following command to build Test Support module and rebuild WebEngineView API:")
+ warning("cd $$BUILD_DIR && qmake -r $$shell_path($$SRC_DIR/qtwebengine.pro -- --feature-testsupport=yes) && make -C $$shell_path($$BUILD_DIR/src/webengine) clean && make")
+ warning("After performing the command above make sure QML module \"QtWebEngine.testsupport\" is deployed at $$TESTSUPPORT_MODULE")
+}
diff --git a/tests/auto/quick/qmltests2/tst_qmltests2.cpp b/tests/auto/quick/qmltests2/tst_qmltests2.cpp
new file mode 100644
index 000000000..8c81ed7f5
--- /dev/null
+++ b/tests/auto/quick/qmltests2/tst_qmltests2.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QtCore/QScopedPointer>
+#include <QtQuickTest/quicktest.h>
+#include <QtWebEngine/QQuickWebEngineProfile>
+#include "qt_webengine_quicktest.h"
+
+#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
+#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#endif
+
+#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
+static bool debuggerPresent()
+{
+ int fd = open("/proc/self/status", O_RDONLY);
+ if (fd == -1)
+ return false;
+ char buffer[2048];
+ ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
+ if (size == -1) {
+ close(fd);
+ return false;
+ }
+ buffer[size] = 0;
+ const char tracerPidToken[] = "\nTracerPid:";
+ char *tracerPid = strstr(buffer, tracerPidToken);
+ if (!tracerPid) {
+ close(fd);
+ return false;
+ }
+ tracerPid += sizeof(tracerPidToken);
+ long int pid = strtol(tracerPid, &tracerPid, 10);
+ close(fd);
+ return pid != 0;
+}
+
+static void stackTrace()
+{
+ bool ok = false;
+ const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
+ if (ok && disableStackDump == 1)
+ return;
+
+ if (debuggerPresent())
+ return;
+
+ fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
+ char cmd[512];
+ qsnprintf(cmd, 512, "gdb --pid %d 2>/dev/null <<EOF\n"
+ "set prompt\n"
+ "set height 0\n"
+ "thread apply all where full\n"
+ "detach\n"
+ "quit\n"
+ "EOF\n",
+ (int)getpid());
+
+ if (system(cmd) == -1)
+ fprintf(stderr, "calling gdb failed\n");
+ fprintf(stderr, "========= End of stack trace ==============\n");
+}
+
+static void sigSegvHandler(int signum)
+{
+ stackTrace();
+ qFatal("Received signal %d", signum);
+}
+#endif
+
+int main(int argc, char **argv)
+{
+#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
+ struct sigaction sigAction;
+
+ sigemptyset(&sigAction.sa_mask);
+ sigAction.sa_handler = &sigSegvHandler;
+ sigAction.sa_flags = 0;
+
+ sigaction(SIGSEGV, &sigAction, 0);
+#endif
+
+ // Inject the mock ui delegates module
+ qputenv("QML2_IMPORT_PATH", QByteArray(TESTS_SOURCE_DIR "qmltests2/mock-delegates"));
+ QScopedPointer<Application> app;
+
+ // Force to use English language for testing due to error message checks
+ QLocale::setDefault(QLocale("en"));
+
+ if (!QCoreApplication::instance()) {
+ app.reset(new Application(argc, argv));
+ }
+ QtWebEngine::initialize();
+ QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
+
+ QTEST_SET_MAIN_SOURCE_PATH
+
+ int i = quick_test_main(argc, argv, "qmltests2", QUICK_TEST_SOURCE_DIR);
+ return i;
+}