summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js')
-rw-r--r--toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js175
1 files changed, 175 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js b/toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js
new file mode 100644
index 000000000..f79573ae6
--- /dev/null
+++ b/toolkit/components/places/tests/unifiedcomplete/test_word_boundary_search.js
@@ -0,0 +1,175 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * Test bug 393678 to make sure matches against the url, title, tags are only
+ * made on word boundaries instead of in the middle of words.
+ *
+ * Make sure we don't try matching one after a CamelCase because the upper-case
+ * isn't really a word boundary. (bug 429498)
+ *
+ * Bug 429531 provides switching between "must match on word boundary" and "can
+ * match," so leverage "must match" pref for checking word boundary logic and
+ * make sure "can match" matches anywhere.
+ */
+
+var katakana = ["\u30a8", "\u30c9"]; // E, Do
+var ideograph = ["\u4efb", "\u5929", "\u5802"]; // Nin Ten Do
+
+add_task(function* test_escape() {
+ Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", false);
+
+ let uri1 = NetUtil.newURI("http://matchme/");
+ let uri2 = NetUtil.newURI("http://dontmatchme/");
+ let uri3 = NetUtil.newURI("http://title/1");
+ let uri4 = NetUtil.newURI("http://title/2");
+ let uri5 = NetUtil.newURI("http://tag/1");
+ let uri6 = NetUtil.newURI("http://tag/2");
+ let uri7 = NetUtil.newURI("http://crazytitle/");
+ let uri8 = NetUtil.newURI("http://katakana/");
+ let uri9 = NetUtil.newURI("http://ideograph/");
+ let uri10 = NetUtil.newURI("http://camel/pleaseMatchMe/");
+
+ yield PlacesTestUtils.addVisits([
+ { uri: uri1, title: "title1" },
+ { uri: uri2, title: "title1" },
+ { uri: uri3, title: "matchme2" },
+ { uri: uri4, title: "dontmatchme3" },
+ { uri: uri5, title: "title1" },
+ { uri: uri6, title: "title1" },
+ { uri: uri7, title: "!@#$%^&*()_+{}|:<>?word" },
+ { uri: uri8, title: katakana.join("") },
+ { uri: uri9, title: ideograph.join("") },
+ { uri: uri10, title: "title1" }
+ ]);
+ yield addBookmark( { uri: uri5, title: "title1", tags: [ "matchme2" ] } );
+ yield addBookmark( { uri: uri6, title: "title1", tags: [ "dontmatchme3" ] } );
+
+ // match only on word boundaries
+ Services.prefs.setIntPref("browser.urlbar.matchBehavior", 2);
+
+ do_print("Match 'match' at the beginning or after / or on a CamelCase");
+ yield check_autocomplete({
+ search: "match",
+ matches: [ { uri: uri1, title: "title1" },
+ { uri: uri3, title: "matchme2" },
+ { uri: uri5, title: "title1", tags: [ "matchme2" ], style: [ "bookmark-tag" ] },
+ { uri: uri10, title: "title1" } ]
+ });
+
+ do_print("Match 'dont' at the beginning or after /");
+ yield check_autocomplete({
+ search: "dont",
+ matches: [ { uri: uri2, title: "title1" },
+ { uri: uri4, title: "dontmatchme3" },
+ { uri: uri6, title: "title1", tags: [ "dontmatchme3" ], style: [ "bookmark-tag" ] } ]
+ });
+
+ do_print("Match 'match' at the beginning or after / or on a CamelCase");
+ yield check_autocomplete({
+ search: "2",
+ matches: [ { uri: uri3, title: "matchme2" },
+ { uri: uri4, title: "dontmatchme3" },
+ { uri: uri5, title: "title1", tags: [ "matchme2" ], style: [ "bookmark-tag" ] },
+ { uri: uri6, title: "title1", tags: [ "dontmatchme3" ], style: [ "bookmark-tag" ] } ]
+ });
+
+ do_print("Match 't' at the beginning or after /");
+ yield check_autocomplete({
+ search: "t",
+ matches: [ { uri: uri1, title: "title1" },
+ { uri: uri2, title: "title1" },
+ { uri: uri3, title: "matchme2" },
+ { uri: uri4, title: "dontmatchme3" },
+ { uri: uri5, title: "title1", tags: [ "matchme2" ], style: [ "bookmark-tag" ] },
+ { uri: uri6, title: "title1", tags: [ "dontmatchme3" ], style: [ "bookmark-tag" ] },
+ { uri: uri10, title: "title1" } ]
+ });
+
+ do_print("Match 'word' after many consecutive word boundaries");
+ yield check_autocomplete({
+ search: "word",
+ matches: [ { uri: uri7, title: "!@#$%^&*()_+{}|:<>?word" } ]
+ });
+
+ do_print("Match a word boundary '/' for everything");
+ yield check_autocomplete({
+ search: "/",
+ matches: [ { uri: uri1, title: "title1" },
+ { uri: uri2, title: "title1" },
+ { uri: uri3, title: "matchme2" },
+ { uri: uri4, title: "dontmatchme3" },
+ { uri: uri5, title: "title1", tags: [ "matchme2" ], style: [ "bookmark-tag" ] },
+ { uri: uri6, title: "title1", tags: [ "dontmatchme3" ], style: [ "bookmark-tag" ] },
+ { uri: uri7, title: "!@#$%^&*()_+{}|:<>?word" },
+ { uri: uri8, title: katakana.join("") },
+ { uri: uri9, title: ideograph.join("") },
+ { uri: uri10, title: "title1" } ]
+ });
+
+ do_print("Match word boundaries '()_+' that are among word boundaries");
+ yield check_autocomplete({
+ search: "()_+",
+ matches: [ { uri: uri7, title: "!@#$%^&*()_+{}|:<>?word" } ]
+ });
+
+ do_print("Katakana characters form a string, so match the beginning");
+ yield check_autocomplete({
+ search: katakana[0],
+ matches: [ { uri: uri8, title: katakana.join("") } ]
+ });
+
+/*
+ do_print("Middle of a katakana word shouldn't be matched");
+ yield check_autocomplete({
+ search: katakana[1],
+ matches: [ ]
+ });
+*/
+ do_print("Ideographs are treated as words so 'nin' is one word");
+ yield check_autocomplete({
+ search: ideograph[0],
+ matches: [ { uri: uri9, title: ideograph.join("") } ]
+ });
+
+ do_print("Ideographs are treated as words so 'ten' is another word");
+ yield check_autocomplete({
+ search: ideograph[1],
+ matches: [ { uri: uri9, title: ideograph.join("") } ]
+ });
+
+ do_print("Ideographs are treated as words so 'do' is yet another word");
+ yield check_autocomplete({
+ search: ideograph[2],
+ matches: [ { uri: uri9, title: ideograph.join("") } ]
+ });
+
+ do_print("Extra negative assert that we don't match in the middle");
+ yield check_autocomplete({
+ search: "ch",
+ matches: [ ]
+ });
+
+ do_print("Don't match one character after a camel-case word boundary (bug 429498)");
+ yield check_autocomplete({
+ search: "atch",
+ matches: [ ]
+ });
+
+ // match against word boundaries and anywhere
+ Services.prefs.setIntPref("browser.urlbar.matchBehavior", 1);
+
+ yield check_autocomplete({
+ search: "tch",
+ matches: [ { uri: uri1, title: "title1" },
+ { uri: uri2, title: "title1" },
+ { uri: uri3, title: "matchme2" },
+ { uri: uri4, title: "dontmatchme3" },
+ { uri: uri5, title: "title1", tags: [ "matchme2" ], style: [ "bookmark-tag" ] },
+ { uri: uri6, title: "title1", tags: [ "dontmatchme3" ], style: [ "bookmark-tag" ] },
+ { uri: uri10, title: "title1" } ]
+ });
+
+ yield cleanup();
+});