summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/unifiedcomplete/test_trimming.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_trimming.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_trimming.js')
-rw-r--r--toolkit/components/places/tests/unifiedcomplete/test_trimming.js313
1 files changed, 313 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/unifiedcomplete/test_trimming.js b/toolkit/components/places/tests/unifiedcomplete/test_trimming.js
new file mode 100644
index 000000000..e55b009ff
--- /dev/null
+++ b/toolkit/components/places/tests/unifiedcomplete/test_trimming.js
@@ -0,0 +1,313 @@
+/* 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_untrimmed_secure_www() {
+ do_print("Searching for untrimmed https://www entry");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("https://www.mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "https://www.mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_secure_www_path() {
+ do_print("Searching for untrimmed https://www entry with path");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("https://www.mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mozilla.org/t",
+ autofilled: "mozilla.org/test/",
+ completed: "https://www.mozilla.org/test/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_secure() {
+ do_print("Searching for untrimmed https:// entry");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("https://mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "https://mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_secure_path() {
+ do_print("Searching for untrimmed https:// entry with path");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("https://mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mozilla.org/t",
+ autofilled: "mozilla.org/test/",
+ completed: "https://mozilla.org/test/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_www() {
+ do_print("Searching for untrimmed http://www entry");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "www.mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_www_path() {
+ do_print("Searching for untrimmed http://www entry with path");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mozilla.org/t",
+ autofilled: "mozilla.org/test/",
+ completed: "http://www.mozilla.org/test/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_ftp() {
+ do_print("Searching for untrimmed ftp:// entry");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "ftp://mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untrimmed_ftp_path() {
+ do_print("Searching for untrimmed ftp:// entry with path");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "mozilla.org/t",
+ autofilled: "mozilla.org/test/",
+ completed: "ftp://mozilla.org/test/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_priority_1() {
+ do_print("Ensuring correct priority 1");
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("https://www.mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("https://mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("ftp://mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://www.mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://mozilla.org/test/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_periority_2() {
+ do_print( "Ensuring correct priority 2");
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("https://mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("ftp://mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://www.mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://mozilla.org/test/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_periority_3() {
+ do_print("Ensuring correct priority 3");
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("ftp://mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://www.mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://mozilla.org/test/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_periority_4() {
+ do_print("Ensuring correct priority 4");
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("http://www.mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://mozilla.org/test/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_priority_5() {
+ do_print("Ensuring correct priority 5");
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("ftp://mozilla.org/test/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("ftp://www.mozilla.org/test/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "ftp://mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_priority_6() {
+ do_print("Ensuring correct priority 6");
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("http://www.mozilla.org/test1/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://www.mozilla.org/test2/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.org/",
+ completed: "www.mozilla.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_longer_domain() {
+ do_print("Ensuring longer domain can't match");
+ // The .co should be preferred, but should not get the https from the .com.
+ // The .co domain must be added later to activate the trigger bug.
+ yield PlacesTestUtils.addVisits([
+ { uri: NetUtil.newURI("https://mozilla.com/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://mozilla.co/"), transition: TRANSITION_TYPED },
+ { uri: NetUtil.newURI("http://mozilla.co/"), transition: TRANSITION_TYPED }
+ ]);
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "mozilla.co/",
+ completed: "mozilla.co/"
+ });
+
+ yield cleanup();
+});
+
+add_task(function* test_escaped_chars() {
+ do_print("Searching for URL with characters that are normally escaped");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("https://www.mozilla.org/啊-test"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "https://www.mozilla.org/啊-test",
+ autofilled: "https://www.mozilla.org/啊-test",
+ completed: "https://www.mozilla.org/啊-test"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_unsecure_secure() {
+ do_print("Don't return unsecure URL when searching for secure ones");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("http://test.moz.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "https://test.moz.org/t",
+ autofilled: "https://test.moz.org/test/",
+ completed: "https://test.moz.org/test/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_unsecure_secure_domain() {
+ do_print("Don't return unsecure domain when searching for secure ones");
+ yield PlacesTestUtils.addVisits({
+ uri: NetUtil.newURI("http://test.moz.org/test/"),
+ transition: TRANSITION_TYPED
+ });
+ yield check_autocomplete({
+ search: "https://test.moz",
+ autofilled: "https://test.moz.org/",
+ completed: "https://test.moz.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untyped_www() {
+ do_print("Untyped is not accounted for www");
+ Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
+ yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.moz.org/test/") });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "moz.org/",
+ completed: "moz.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untyped_ftp() {
+ do_print("Untyped is not accounted for ftp");
+ Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
+ yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("ftp://moz.org/test/") });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "moz.org/",
+ completed: "moz.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untyped_secure() {
+ do_print("Untyped is not accounted for https");
+ Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
+ yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("https://moz.org/test/") });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "moz.org/",
+ completed: "moz.org/"
+ });
+ yield cleanup();
+});
+
+add_task(function* test_untyped_secure_www() {
+ do_print("Untyped is not accounted for https://www");
+ Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
+ yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("https://www.moz.org/test/") });
+ yield check_autocomplete({
+ search: "mo",
+ autofilled: "moz.org/",
+ completed: "moz.org/"
+ });
+ yield cleanup();
+});