summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2018-04-17 16:23:51 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2018-04-27 07:30:24 +0000
commitff0a83a6c3e64772276cb71cba0392d1e89b037f (patch)
treef2170055d12cef72dd620be1a4418aed6e36d96f /tests/auto/quick/qmltests
parent216240a31baae6e54e38de8157332f272ddf57a7 (diff)
Fix handling of bad @match directives
User scripts with parse errors in their @match patterns were included on all pages. Don't allow to fallback to "@include *" in this case. Task-number: QTBUG-67726 Change-Id: I8172184e79fe3e515f391bc6cc8274a624e67a19 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/quick/qmltests')
-rw-r--r--tests/auto/quick/qmltests/data/script-with-bad-match-metadata.js9
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScripts.qml17
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/data/script-with-bad-match-metadata.js b/tests/auto/quick/qmltests/data/script-with-bad-match-metadata.js
new file mode 100644
index 000000000..c9a811e5c
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/script-with-bad-match-metadata.js
@@ -0,0 +1,9 @@
+// ==UserScript==
+// @name Test bad match script
+// @homepageURL http://www.qt.io/
+// @description Test script with metadata block with an invalid match directive
+// @match some:junk
+// @run-at document-end
+// ==/UserScript==
+
+document.title = "New title for some:junk";
diff --git a/tests/auto/quick/qmltests/data/tst_userScripts.qml b/tests/auto/quick/qmltests/data/tst_userScripts.qml
index d7c7d5983..f4fcc30ab 100644
--- a/tests/auto/quick/qmltests/data/tst_userScripts.qml
+++ b/tests/auto/quick/qmltests/data/tst_userScripts.qml
@@ -54,6 +54,11 @@ Item {
sourceUrl: Qt.resolvedUrl("script-with-metadata.js")
}
+ WebEngineScript {
+ id: scriptWithBadMatchMetadata
+ sourceUrl: Qt.resolvedUrl("script-with-bad-match-metadata.js")
+ }
+
TestWebEngineView {
id: webEngineView
width: 400
@@ -191,6 +196,18 @@ Item {
tryCompare(webEngineView, "title", "Test page with huge link area and iframe");
}
+ function test_dontInjectBadUrlPatternsEverywhere() {
+ compare(scriptWithBadMatchMetadata.name, "Test bad match script");
+ compare(scriptWithBadMatchMetadata.injectionPoint, WebEngineScript.DocumentReady);
+
+ webEngineView.userScripts = [ scriptWithBadMatchMetadata ];
+
+ // @match some:junk
+ webEngineView.url = Qt.resolvedUrl("test2.html");
+ webEngineView.waitForLoadSucceeded();
+ tryCompare(webEngineView, "title", "Test page with huge link area");
+ }
+
function test_profileWideScript() {
webEngineView.profile.userScripts = [ changeDocumentTitleScript ];