tor-browser

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

test_query_url.js (3488B)


      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 const PLACES_PROVIDERNAME = "UrlbarProviderPlaces";
      6 
      7 testEngine_setup();
      8 
      9 add_task(async function test_no_slash() {
     10  info("Searching for host match without slash should match host");
     11  await PlacesTestUtils.addVisits([
     12    { uri: "http://file.org/test/" },
     13    { uri: "file:///c:/test.html" },
     14  ]);
     15  let context = createContext("file", { isPrivate: false });
     16  await check_results({
     17    context,
     18    autofilled: "file.org/",
     19    completed: "http://file.org/",
     20    matches: [
     21      makeVisitResult(context, {
     22        uri: "http://file.org/",
     23        title: UrlbarTestUtils.trimURL("http://file.org/"),
     24        heuristic: true,
     25      }),
     26      makeVisitResult(context, {
     27        uri: "file:///c:/test.html",
     28        title: "test visit for file:///c:/test.html",
     29        providerName: PLACES_PROVIDERNAME,
     30      }),
     31      makeVisitResult(context, {
     32        uri: "http://file.org/test/",
     33        title: "test visit for http://file.org/test/",
     34        providerName: PLACES_PROVIDERNAME,
     35      }),
     36    ],
     37  });
     38  await cleanupPlaces();
     39 });
     40 
     41 add_task(async function test_w_slash() {
     42  info("Searching match with slash at the end should match url");
     43  await PlacesTestUtils.addVisits(
     44    {
     45      uri: Services.io.newURI("http://file.org/test/"),
     46    },
     47    {
     48      uri: Services.io.newURI("file:///c:/test.html"),
     49    }
     50  );
     51  let context = createContext("file.org/", { isPrivate: false });
     52  await check_results({
     53    context,
     54    autofilled: "file.org/",
     55    completed: "http://file.org/",
     56    matches: [
     57      makeVisitResult(context, {
     58        uri: "http://file.org/",
     59        title: UrlbarTestUtils.trimURL("http://file.org/", {
     60          removeSingleTrailingSlash: false,
     61        }),
     62        heuristic: true,
     63      }),
     64      makeVisitResult(context, {
     65        uri: "http://file.org/test/",
     66        title: "test visit for http://file.org/test/",
     67        providerName: PLACES_PROVIDERNAME,
     68      }),
     69    ],
     70  });
     71  await cleanupPlaces();
     72 });
     73 
     74 add_task(async function test_middle() {
     75  info("Searching match with slash in the middle should match url");
     76  await PlacesTestUtils.addVisits(
     77    {
     78      uri: Services.io.newURI("http://file.org/test/"),
     79    },
     80    {
     81      uri: Services.io.newURI("file:///c:/test.html"),
     82    }
     83  );
     84  let context = createContext("file.org/t", { isPrivate: false });
     85  await check_results({
     86    context,
     87    autofilled: "file.org/test/",
     88    completed: "http://file.org/test/",
     89    matches: [
     90      makeVisitResult(context, {
     91        uri: "http://file.org/test/",
     92        title: "test visit for http://file.org/test/",
     93        heuristic: true,
     94      }),
     95    ],
     96  });
     97  await cleanupPlaces();
     98 });
     99 
    100 add_task(async function test_nonhost() {
    101  info("Searching for non-host match without slash should not match url");
    102  await PlacesTestUtils.addVisits({
    103    uri: Services.io.newURI("file:///c:/test.html"),
    104  });
    105  let context = createContext("file", { isPrivate: false });
    106  await check_results({
    107    context,
    108    matches: [
    109      makeSearchResult(context, {
    110        engineName: SUGGESTIONS_ENGINE_NAME,
    111        heuristic: true,
    112      }),
    113      makeVisitResult(context, {
    114        uri: "file:///c:/test.html",
    115        title: "test visit for file:///c:/test.html",
    116        providerName: PLACES_PROVIDERNAME,
    117      }),
    118    ],
    119  });
    120  await cleanupPlaces();
    121 });