tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_autofill_do_not_trim.js (4207B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 // We should not autofill when the search string contains spaces.
      6 
      7 testEngine_setup();
      8 
      9 add_setup(async () => {
     10  Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
     11  await PlacesTestUtils.addVisits({
     12    uri: Services.io.newURI("http://mozilla.org/link/"),
     13  });
     14 
     15  registerCleanupFunction(async () => {
     16    Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
     17    await cleanupPlaces();
     18  });
     19 });
     20 
     21 add_task(async function test_not_autofill_ws_1() {
     22  info("Do not autofill whitespaced entry 1");
     23  let context = createContext("mozilla.org ", { isPrivate: false });
     24  await check_results({
     25    context,
     26    matches: [
     27      makeVisitResult(context, {
     28        uri: "http://mozilla.org/",
     29        title: "mozilla.org/",
     30        source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
     31        heuristic: true,
     32      }),
     33      makeVisitResult(context, {
     34        uri: "http://mozilla.org/link/",
     35        title: "test visit for http://mozilla.org/link/",
     36      }),
     37    ],
     38  });
     39 });
     40 
     41 add_task(async function test_not_autofill_ws_2() {
     42  info("Do not autofill whitespaced entry 2");
     43  let context = createContext("mozilla.org/ ", { isPrivate: false });
     44  await check_results({
     45    context,
     46    matches: [
     47      makeVisitResult(context, {
     48        uri: "http://mozilla.org/",
     49        title: "mozilla.org/",
     50        iconUri: "page-icon:http://mozilla.org/",
     51        source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
     52        heuristic: true,
     53      }),
     54      makeVisitResult(context, {
     55        uri: "http://mozilla.org/link/",
     56        title: "test visit for http://mozilla.org/link/",
     57      }),
     58    ],
     59  });
     60 });
     61 
     62 add_task(async function test_not_autofill_ws_3() {
     63  info("Do not autofill whitespaced entry 3");
     64  let context = createContext("mozilla.org/link ", { isPrivate: false });
     65  await check_results({
     66    context,
     67    matches: [
     68      makeVisitResult(context, {
     69        uri: "http://mozilla.org/link",
     70        title: "mozilla.org/link",
     71        iconUri: "page-icon:http://mozilla.org/",
     72        source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
     73        heuristic: true,
     74      }),
     75      makeVisitResult(context, {
     76        uri: "http://mozilla.org/link/",
     77        title: "test visit for http://mozilla.org/link/",
     78      }),
     79    ],
     80  });
     81 });
     82 
     83 add_task(async function test_not_autofill_ws_4() {
     84  info(
     85    "Do not autofill whitespaced entry 4, but UrlbarProviderPlaces provides heuristic result"
     86  );
     87  let context = createContext("mozilla.org/link/ ", { isPrivate: false });
     88  await check_results({
     89    context,
     90    matches: [
     91      makeVisitResult(context, {
     92        uri: "http://mozilla.org/link/",
     93        title: "test visit for http://mozilla.org/link/",
     94        iconUri: "page-icon:http://mozilla.org/link/",
     95        source: UrlbarUtils.RESULT_SOURCE.HISTORY,
     96        heuristic: true,
     97      }),
     98    ],
     99  });
    100 });
    101 
    102 add_task(async function test_not_autofill_ws_5() {
    103  info("Do not autofill whitespaced entry 5");
    104  let context = createContext("moz illa ", { isPrivate: false });
    105  await check_results({
    106    context,
    107    matches: [
    108      makeSearchResult(context, {
    109        engineName: SUGGESTIONS_ENGINE_NAME,
    110        // query is made explict so makeSearchResult doesn't trim it.
    111        query: "moz illa ",
    112        heuristic: true,
    113      }),
    114      makeVisitResult(context, {
    115        uri: "http://mozilla.org/link/",
    116        title: "test visit for http://mozilla.org/link/",
    117      }),
    118    ],
    119  });
    120 });
    121 
    122 add_task(async function test_not_autofill_ws_6() {
    123  info("Do not autofill whitespaced entry 6");
    124  let context = createContext(" mozilla", { isPrivate: false });
    125  await check_results({
    126    context,
    127    matches: [
    128      makeSearchResult(context, {
    129        engineName: SUGGESTIONS_ENGINE_NAME,
    130        // query is made explict so makeSearchResult doesn't trim it.
    131        query: " mozilla",
    132        heuristic: true,
    133      }),
    134      makeVisitResult(context, {
    135        uri: "http://mozilla.org/link/",
    136        title: "test visit for http://mozilla.org/link/",
    137      }),
    138    ],
    139  });
    140 });