summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorPaul Clark <paul.clark@spalge.com>2018-01-13 20:17:58 +1300
committerFlorian Bruhin <qt-project.org@the-compiler.org>2018-01-26 13:14:35 +0000
commitc8bb939e7e45214f17daf8f576582e5bff2527ea (patch)
treea075297c5e5fb123952dc83eaca692ab19a1dda4 /tests/auto
parenta7f37f48d5691c9be4a419edc34396229a1b9bb5 (diff)
Support regex format include rules in user scripts
For user scripts with `@include` and `@exclude` directives in their headers, if the value starts and ends with `/` then assume it is a regular expression to be matched against a URL. This feature has been in the original greasemonkey module since 2011 and currently in webengine regex include rules are being blindly passed to the glob matcher. An alternative to this approach of leaving the bracketing slashes on the values as a kind of in-band signalling (and making the glob escaping conditional) would be to add new members to the UserScriptData struct for holding regex patterns. This commit also applies cleanly to v5.8 and every release after it. [ChangeLog][][UserScript] User script metadata parsing now supports regular expressions in @include and @exclude rules. Task-number: QTBUG-65484 Change-Id: Ie2e483419f6784f995131ffb7d2d5e91c2c55b1d Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Szabolcs David <davidsz@inf.u-szeged.hu> Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/qmltests/data/script-with-metadata.js4
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScripts.qml12
2 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/quick/qmltests/data/script-with-metadata.js b/tests/auto/quick/qmltests/data/script-with-metadata.js
index 4dcf50f55..de2e3974c 100644
--- a/tests/auto/quick/qmltests/data/script-with-metadata.js
+++ b/tests/auto/quick/qmltests/data/script-with-metadata.js
@@ -2,8 +2,10 @@
// @name Test script
// @homepageURL http://www.qt.io/
// @description Test script with metadata block
-// @include *test*.html
+// @include *data/test*.html
+// @include /favicon.html?$/
// @exclude *test2.html
+// @exclude /test[-]iframe/
// @run-at document-end
// ==/UserScript==
diff --git a/tests/auto/quick/qmltests/data/tst_userScripts.qml b/tests/auto/quick/qmltests/data/tst_userScripts.qml
index e9a4eba99..d7c7d5983 100644
--- a/tests/auto/quick/qmltests/data/tst_userScripts.qml
+++ b/tests/auto/quick/qmltests/data/tst_userScripts.qml
@@ -170,7 +170,7 @@ Item {
webEngineView.userScripts = [ scriptWithMetadata ];
- // @include *test*.html
+ // @include *data/test*.html
webEngineView.url = Qt.resolvedUrl("test1.html");
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "New title");
@@ -179,6 +179,16 @@ Item {
webEngineView.url = Qt.resolvedUrl("test2.html");
webEngineView.waitForLoadSucceeded();
tryCompare(webEngineView, "title", "Test page with huge link area");
+
+ // @include /favicon.html?$/
+ webEngineView.url = Qt.resolvedUrl("favicon.html");
+ webEngineView.waitForLoadSucceeded();
+ tryCompare(webEngineView, "title", "New title");
+
+ // @exclude /test[-]iframe/
+ webEngineView.url = Qt.resolvedUrl("test-iframe.html");
+ webEngineView.waitForLoadSucceeded();
+ tryCompare(webEngineView, "title", "Test page with huge link area and iframe");
}
function test_profileWideScript() {