toolkit/components/places/tests/inline/test_trimming.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/inline/test_trimming.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,249 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +add_autocomplete_test([
     1.9 +  "Searching for untrimmed https://www entry",
    1.10 +  "mo",
    1.11 +  { autoFilled: "mozilla.org/", completed: "https://www.mozilla.org/" },
    1.12 +  function () {
    1.13 +    promiseAddVisits({ uri: NetUtil.newURI("https://www.mozilla.org/test/"),
    1.14 +                       transition: TRANSITION_TYPED });
    1.15 +  },
    1.16 +]);
    1.17 +
    1.18 +add_autocomplete_test([
    1.19 +  "Searching for untrimmed https://www entry with path",
    1.20 +  "mozilla.org/t",
    1.21 +  { autoFilled: "mozilla.org/test/", completed: "https://www.mozilla.org/test/" },
    1.22 +  function () {
    1.23 +    promiseAddVisits({ uri: NetUtil.newURI("https://www.mozilla.org/test/"),
    1.24 +                       transition: TRANSITION_TYPED });
    1.25 +  },
    1.26 +]);
    1.27 +
    1.28 +add_autocomplete_test([
    1.29 +  "Searching for untrimmed https:// entry",
    1.30 +  "mo",
    1.31 +  { autoFilled: "mozilla.org/", completed: "https://mozilla.org/" },
    1.32 +  function () {
    1.33 +    promiseAddVisits({ uri: NetUtil.newURI("https://mozilla.org/test/"),
    1.34 +                       transition: TRANSITION_TYPED });
    1.35 +  },
    1.36 +]);
    1.37 +
    1.38 +add_autocomplete_test([
    1.39 +  "Searching for untrimmed https:// entry with path",
    1.40 +  "mozilla.org/t",
    1.41 +  { autoFilled: "mozilla.org/test/", completed: "https://mozilla.org/test/" },
    1.42 +  function () {
    1.43 +    promiseAddVisits({ uri: NetUtil.newURI("https://mozilla.org/test/"),
    1.44 +                       transition: TRANSITION_TYPED });
    1.45 +  },
    1.46 +]);
    1.47 +
    1.48 +add_autocomplete_test([
    1.49 +  "Searching for untrimmed http://www entry",
    1.50 +  "mo",
    1.51 +  { autoFilled: "mozilla.org/", completed: "www.mozilla.org/" },
    1.52 +  function () {
    1.53 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
    1.54 +                       transition: TRANSITION_TYPED });
    1.55 +  },
    1.56 +]);
    1.57 +
    1.58 +add_autocomplete_test([
    1.59 +  "Searching for untrimmed http://www entry with path",
    1.60 +  "mozilla.org/t",
    1.61 +  { autoFilled: "mozilla.org/test/", completed: "http://www.mozilla.org/test/" },
    1.62 +  function () {
    1.63 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
    1.64 +                       transition: TRANSITION_TYPED });
    1.65 +  },
    1.66 +]);
    1.67 +
    1.68 +add_autocomplete_test([
    1.69 +  "Searching for untrimmed ftp:// entry",
    1.70 +  "mo",
    1.71 +  { autoFilled: "mozilla.org/", completed: "ftp://mozilla.org/" },
    1.72 +  function () {
    1.73 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
    1.74 +                       transition: TRANSITION_TYPED });
    1.75 +  },
    1.76 +]);
    1.77 +
    1.78 +add_autocomplete_test([
    1.79 +  "Searching for untrimmed ftp:// entry with path",
    1.80 +  "mozilla.org/t",
    1.81 +  { autoFilled: "mozilla.org/test/", completed: "ftp://mozilla.org/test/" },
    1.82 +  function () {
    1.83 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
    1.84 +                       transition: TRANSITION_TYPED });
    1.85 +  },
    1.86 +]);
    1.87 +
    1.88 +add_autocomplete_test([
    1.89 +  "Ensuring correct priority 1",
    1.90 +  "mo",
    1.91 +  { autoFilled: "mozilla.org/", completed: "mozilla.org/" },
    1.92 +  function () {
    1.93 +    promiseAddVisits({ uri: NetUtil.newURI("https://www.mozilla.org/test/"),
    1.94 +                       transition: TRANSITION_TYPED });
    1.95 +    promiseAddVisits({ uri: NetUtil.newURI("https://mozilla.org/test/"),
    1.96 +                       transition: TRANSITION_TYPED });
    1.97 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
    1.98 +                       transition: TRANSITION_TYPED });
    1.99 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
   1.100 +                       transition: TRANSITION_TYPED });
   1.101 +    promiseAddVisits({ uri: NetUtil.newURI("http://mozilla.org/test/"),
   1.102 +                       transition: TRANSITION_TYPED });
   1.103 +  },
   1.104 +]);
   1.105 +
   1.106 +add_autocomplete_test([
   1.107 +  "Ensuring correct priority 2",
   1.108 +  "mo",
   1.109 +  { autoFilled: "mozilla.org/", completed: "mozilla.org/" },
   1.110 +  function () {
   1.111 +    promiseAddVisits({ uri: NetUtil.newURI("https://mozilla.org/test/"),
   1.112 +                       transition: TRANSITION_TYPED });
   1.113 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
   1.114 +                       transition: TRANSITION_TYPED });
   1.115 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
   1.116 +                       transition: TRANSITION_TYPED });
   1.117 +    promiseAddVisits({ uri: NetUtil.newURI("http://mozilla.org/test/"),
   1.118 +                       transition: TRANSITION_TYPED });
   1.119 +  },
   1.120 +]);
   1.121 +
   1.122 +add_autocomplete_test([
   1.123 +  "Ensuring correct priority 3",
   1.124 +  "mo",
   1.125 +  { autoFilled: "mozilla.org/", completed: "mozilla.org/" },
   1.126 +  function () {
   1.127 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
   1.128 +                       transition: TRANSITION_TYPED });
   1.129 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
   1.130 +                       transition: TRANSITION_TYPED });
   1.131 +    promiseAddVisits({ uri: NetUtil.newURI("http://mozilla.org/test/"),
   1.132 +                       transition: TRANSITION_TYPED });
   1.133 +  },
   1.134 +]);
   1.135 +
   1.136 +add_autocomplete_test([
   1.137 +  "Ensuring correct priority 4",
   1.138 +  "mo",
   1.139 +  { autoFilled: "mozilla.org/", completed: "mozilla.org/" },
   1.140 +  function () {
   1.141 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
   1.142 +                       transition: TRANSITION_TYPED });
   1.143 +    promiseAddVisits({ uri: NetUtil.newURI("http://mozilla.org/test/"),
   1.144 +                       transition: TRANSITION_TYPED });
   1.145 +  },
   1.146 +]);
   1.147 +
   1.148 +add_autocomplete_test([
   1.149 +  "Ensuring correct priority 5",
   1.150 +  "mo",
   1.151 +  { autoFilled: "mozilla.org/", completed: "ftp://mozilla.org/" },
   1.152 +  function () {
   1.153 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
   1.154 +                       transition: TRANSITION_TYPED });
   1.155 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://www.mozilla.org/test/"),
   1.156 +                       transition: TRANSITION_TYPED });
   1.157 +  },
   1.158 +]);
   1.159 +
   1.160 +add_autocomplete_test([
   1.161 +  "Ensuring correct priority 6",
   1.162 +  "mo",
   1.163 +  { autoFilled: "mozilla.org/", completed: "www.mozilla.org/" },
   1.164 +  function () {
   1.165 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test1/"),
   1.166 +                       transition: TRANSITION_TYPED });
   1.167 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.mozilla.org/test2/"),
   1.168 +                       transition: TRANSITION_TYPED });
   1.169 +  },
   1.170 +]);
   1.171 +
   1.172 +add_autocomplete_test([
   1.173 +  "Ensuring longer domain can't match",
   1.174 +  "mo",
   1.175 +  { autoFilled: "mozilla.co/", completed: "mozilla.co/" },
   1.176 +  function () {
   1.177 +    // The .co should be preferred, but should not get the https from the .com.
   1.178 +    // The .co domain must be added later to activate the trigger bug.
   1.179 +    promiseAddVisits({ uri: NetUtil.newURI("https://mozilla.com/"),
   1.180 +                       transition: TRANSITION_TYPED });
   1.181 +    promiseAddVisits({ uri: NetUtil.newURI("http://mozilla.co/"),
   1.182 +                       transition: TRANSITION_TYPED });
   1.183 +    promiseAddVisits({ uri: NetUtil.newURI("http://mozilla.co/"),
   1.184 +                       transition: TRANSITION_TYPED });
   1.185 +  },
   1.186 +]);
   1.187 +
   1.188 +add_autocomplete_test([
   1.189 +  "Searching for URL with characters that are normally escaped",
   1.190 +  "https://www.mozilla.org/啊-test",
   1.191 +  { autoFilled: "https://www.mozilla.org/啊-test", completed: "https://www.mozilla.org/啊-test" },
   1.192 +  function () {
   1.193 +    promiseAddVisits({ uri: NetUtil.newURI("https://www.mozilla.org/啊-test"),
   1.194 +                       transition: TRANSITION_TYPED });
   1.195 +  },
   1.196 +]);
   1.197 +
   1.198 +add_autocomplete_test([
   1.199 +  "Don't return unsecure URL when searching for secure ones",
   1.200 +  "https://test.moz.org/t",
   1.201 +  { autoFilled: "https://test.moz.org/test/", completed: "https://test.moz.org/test/" },
   1.202 +  function () {
   1.203 +    promiseAddVisits({ uri: NetUtil.newURI("http://test.moz.org/test/"),
   1.204 +                       transition: TRANSITION_TYPED });
   1.205 +  },
   1.206 +]);
   1.207 +
   1.208 +add_autocomplete_test([
   1.209 +  "Don't return unsecure domain when searching for secure ones",
   1.210 +  "https://test.moz",
   1.211 +  { autoFilled: "https://test.moz.org/", completed: "https://test.moz.org/" },
   1.212 +  function () {
   1.213 +    promiseAddVisits({ uri: NetUtil.newURI("http://test.moz.org/test/"),
   1.214 +                       transition: TRANSITION_TYPED });
   1.215 +  },
   1.216 +]);
   1.217 +
   1.218 +add_autocomplete_test([
   1.219 +  "Untyped is not accounted for www",
   1.220 +  "mo",
   1.221 +  { autoFilled: "moz.org/", completed: "moz.org/" },
   1.222 +  function () {
   1.223 +    promiseAddVisits({ uri: NetUtil.newURI("http://www.moz.org/test/") });
   1.224 +  },
   1.225 +]);
   1.226 +
   1.227 +add_autocomplete_test([
   1.228 +  "Untyped is not accounted for ftp",
   1.229 +  "mo",
   1.230 +  { autoFilled: "moz.org/", completed: "moz.org/" },
   1.231 +  function () {
   1.232 +    promiseAddVisits({ uri: NetUtil.newURI("ftp://moz.org/test/") });
   1.233 +  },
   1.234 +]);
   1.235 +
   1.236 +add_autocomplete_test([
   1.237 +  "Untyped is not accounted for https",
   1.238 +  "mo",
   1.239 +  { autoFilled: "moz.org/", completed: "moz.org/" },
   1.240 +  function () {
   1.241 +    promiseAddVisits({ uri: NetUtil.newURI("https://moz.org/test/") });
   1.242 +  },
   1.243 +]);
   1.244 +
   1.245 +add_autocomplete_test([
   1.246 +  "Untyped is not accounted for https://www",
   1.247 +  "mo",
   1.248 +  { autoFilled: "moz.org/", completed: "moz.org/" },
   1.249 +  function () {
   1.250 +    promiseAddVisits({ uri: NetUtil.newURI("https://www.moz.org/test/") });
   1.251 +  },
   1.252 +]);

mercurial