diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/unifiedcomplete/test_avoid_middle_complete.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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_avoid_middle_complete.js')
-rw-r--r-- | toolkit/components/places/tests/unifiedcomplete/test_avoid_middle_complete.js | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/unifiedcomplete/test_avoid_middle_complete.js b/toolkit/components/places/tests/unifiedcomplete/test_avoid_middle_complete.js new file mode 100644 index 000000000..54fc343ca --- /dev/null +++ b/toolkit/components/places/tests/unifiedcomplete/test_avoid_middle_complete.js @@ -0,0 +1,179 @@ +/* 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/. */ + +add_task(function* test_prefix_space_noautofill() { + yield PlacesTestUtils.addVisits({ + uri: NetUtil.newURI("http://moz.org/test/"), + transition: TRANSITION_TYPED + }); + + do_print("Should not try to autoFill if search string contains a space"); + yield check_autocomplete({ + search: " mo", + autofilled: " mo", + completed: " mo" + }); + + yield cleanup(); +}); + +add_task(function* test_trailing_space_noautofill() { + yield PlacesTestUtils.addVisits({ + uri: NetUtil.newURI("http://moz.org/test/"), + transition: TRANSITION_TYPED + }); + + do_print("Should not try to autoFill if search string contains a space"); + yield check_autocomplete({ + search: "mo ", + autofilled: "mo ", + completed: "mo " + }); + + yield cleanup(); +}); + +add_task(function* test_searchEngine_autofill() { + Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", true); + Services.search.addEngineWithDetails("CakeSearch", "", "", "", + "GET", "http://cake.search/"); + let engine = Services.search.getEngineByName("CakeSearch"); + engine.addParam("q", "{searchTerms}", null); + do_register_cleanup(() => Services.search.removeEngine(engine)); + + do_print("Should autoFill search engine if search string does not contains a space"); + yield check_autocomplete({ + search: "ca", + autofilled: "cake.search", + completed: "http://cake.search" + }); + + yield cleanup(); +}); + +add_task(function* test_searchEngine_prefix_space_noautofill() { + Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", true); + Services.search.addEngineWithDetails("CupcakeSearch", "", "", "", + "GET", "http://cupcake.search/"); + let engine = Services.search.getEngineByName("CupcakeSearch"); + engine.addParam("q", "{searchTerms}", null); + do_register_cleanup(() => Services.search.removeEngine(engine)); + + do_print("Should not try to autoFill search engine if search string contains a space"); + yield check_autocomplete({ + search: " cu", + autofilled: " cu", + completed: " cu" + }); + + yield cleanup(); +}); + +add_task(function* test_searchEngine_trailing_space_noautofill() { + Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", true); + Services.search.addEngineWithDetails("BaconSearch", "", "", "", + "GET", "http://bacon.search/"); + let engine = Services.search.getEngineByName("BaconSearch"); + engine.addParam("q", "{searchTerms}", null); + do_register_cleanup(() => Services.search.removeEngine(engine)); + + do_print("Should not try to autoFill search engine if search string contains a space"); + yield check_autocomplete({ + search: "ba ", + autofilled: "ba ", + completed: "ba " + }); + + yield cleanup(); +}); + +add_task(function* test_searchEngine_www_noautofill() { + Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", true); + Services.search.addEngineWithDetails("HamSearch", "", "", "", + "GET", "http://ham.search/"); + let engine = Services.search.getEngineByName("HamSearch"); + engine.addParam("q", "{searchTerms}", null); + do_register_cleanup(() => Services.search.removeEngine(engine)); + + do_print("Should not autoFill search engine if search string contains www. but engine doesn't"); + yield check_autocomplete({ + search: "www.ham", + autofilled: "www.ham", + completed: "www.ham" + }); + + yield cleanup(); +}); + +add_task(function* test_searchEngine_different_scheme_noautofill() { + Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", true); + Services.search.addEngineWithDetails("PieSearch", "", "", "", + "GET", "https://pie.search/"); + let engine = Services.search.getEngineByName("PieSearch"); + engine.addParam("q", "{searchTerms}", null); + do_register_cleanup(() => Services.search.removeEngine(engine)); + + do_print("Should not autoFill search engine if search string has a different scheme."); + yield check_autocomplete({ + search: "http://pie", + autofilled: "http://pie", + completed: "http://pie" + }); + + yield cleanup(); +}); + +add_task(function* test_searchEngine_matching_prefix_autofill() { + Services.prefs.setBoolPref("browser.urlbar.autoFill.searchEngines", true); + Services.search.addEngineWithDetails("BeanSearch", "", "", "", + "GET", "http://www.bean.search/"); + let engine = Services.search.getEngineByName("BeanSearch"); + engine.addParam("q", "{searchTerms}", null); + do_register_cleanup(() => Services.search.removeEngine(engine)); + + + do_print("Should autoFill search engine if search string has matching prefix."); + yield check_autocomplete({ + search: "http://www.be", + autofilled: "http://www.bean.search", + completed: "http://www.bean.search" + }) + + do_print("Should autoFill search engine if search string has www prefix."); + yield check_autocomplete({ + search: "www.be", + autofilled: "www.bean.search", + completed: "http://www.bean.search" + }); + + do_print("Should autoFill search engine if search string has matching scheme."); + yield check_autocomplete({ + search: "http://be", + autofilled: "http://bean.search", + completed: "http://www.bean.search" + }); + + yield cleanup(); +}); + +add_task(function* test_prefix_autofill() { + yield PlacesTestUtils.addVisits({ + uri: NetUtil.newURI("http://mozilla.org/test/"), + transition: TRANSITION_TYPED + }); + yield PlacesTestUtils.addVisits({ + uri: NetUtil.newURI("http://moz.org/test/"), + transition: TRANSITION_TYPED + }); + + do_print("Should not try to autoFill in-the-middle if a search is canceled immediately"); + yield check_autocomplete({ + incompleteSearch: "moz", + search: "mozi", + autofilled: "mozilla.org/", + completed: "mozilla.org/" + }); + + yield cleanup(); +}); |