tor-browser

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

test_dedupe_embedded_url_param.js (5005B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 testEngine_setup();
      7 
      8 add_task(async function test_embedded_url_show_up_as_places_result() {
      9  await PlacesTestUtils.addVisits([
     10    {
     11      uri: "http://example.com/?url=http://kitten.com/",
     12      title: "kitten",
     13    },
     14  ]);
     15 
     16  let context = createContext("kitten", {
     17    isPrivate: false,
     18  });
     19 
     20  await check_results({
     21    context,
     22    matches: [
     23      makeSearchResult(context, {
     24        heuristic: true,
     25        query: "kitten",
     26        engineName: Services.search.defaultEngine.name,
     27      }),
     28      makeVisitResult(context, {
     29        uri: "http://example.com/?url=http://kitten.com/",
     30        title: "kitten",
     31        source: UrlbarUtils.RESULT_SOURCE.HISTORY,
     32      }),
     33    ],
     34  });
     35 
     36  await cleanupPlaces();
     37 });
     38 
     39 add_task(async function test_deduplication_of_embedded_url_autofill_result() {
     40  await PlacesTestUtils.addVisits([
     41    {
     42      uri: "http://example.com/?url=http://kitten.com/",
     43      title: "kitten",
     44    },
     45    {
     46      uri: "http://kitten.com/",
     47      title: "kitten",
     48    },
     49  ]);
     50 
     51  let context = createContext("kitten", {
     52    isPrivate: false,
     53  });
     54 
     55  await check_results({
     56    context,
     57    matches: [
     58      makeVisitResult(context, {
     59        uri: "http://kitten.com/",
     60        title: "kitten",
     61        source: UrlbarUtils.RESULT_SOURCE.HISTORY,
     62        heuristic: true,
     63        providerName: "UrlbarProviderAutofill",
     64      }),
     65    ],
     66  });
     67 
     68  await cleanupPlaces();
     69 });
     70 
     71 add_task(async function test_deduplication_of_embedded_url_places_result() {
     72  await PlacesTestUtils.addVisits([
     73    {
     74      uri: "http://example.com/?url=http://kitten.com/",
     75      title: "kitten",
     76    },
     77    {
     78      uri: "http://kitten.com/",
     79      title: "kitten",
     80    },
     81  ]);
     82 
     83  let context = createContext("kitten", {
     84    isPrivate: false,
     85    allowAutofill: false,
     86  });
     87 
     88  await check_results({
     89    context,
     90    matches: [
     91      makeSearchResult(context, {
     92        heuristic: true,
     93        query: "kitten",
     94        engineName: Services.search.defaultEngine.name,
     95      }),
     96      makeVisitResult(context, {
     97        uri: "http://kitten.com/",
     98        title: "kitten",
     99        source: UrlbarUtils.RESULT_SOURCE.HISTORY,
    100      }),
    101    ],
    102  });
    103 
    104  await cleanupPlaces();
    105 });
    106 
    107 add_task(
    108  async function test_deduplication_of_higher_frecency_embedded_url_places_result() {
    109    await PlacesTestUtils.addVisits([
    110      {
    111        uri: "http://example.com/?url=http://kitten.com/",
    112        title: "kitten",
    113      },
    114      {
    115        uri: "http://example.com/?url=http://kitten.com/",
    116        title: "kitten",
    117      },
    118      {
    119        uri: "http://kitten.com/",
    120        title: "kitten",
    121      },
    122    ]);
    123 
    124    let context = createContext("kitten", {
    125      isPrivate: false,
    126      allowAutofill: false,
    127    });
    128 
    129    await check_results({
    130      context,
    131      matches: [
    132        makeSearchResult(context, {
    133          heuristic: true,
    134          query: "kitten",
    135          engineName: Services.search.defaultEngine.name,
    136        }),
    137        makeVisitResult(context, {
    138          uri: "http://kitten.com/",
    139          title: "kitten",
    140          source: UrlbarUtils.RESULT_SOURCE.HISTORY,
    141        }),
    142      ],
    143    });
    144 
    145    await cleanupPlaces();
    146  }
    147 );
    148 
    149 add_task(
    150  async function test_deduplication_of_embedded_encoded_url_places_result() {
    151    await PlacesTestUtils.addVisits([
    152      {
    153        uri: "http://example.com/?url=http%3A%2F%2Fkitten.com%2F",
    154        title: "kitten",
    155      },
    156      {
    157        uri: "http://kitten.com/",
    158        title: "kitten",
    159      },
    160    ]);
    161 
    162    let context = createContext("kitten", {
    163      isPrivate: false,
    164      allowAutofill: false,
    165    });
    166 
    167    await check_results({
    168      context,
    169      matches: [
    170        makeSearchResult(context, {
    171          heuristic: true,
    172          query: "kitten",
    173          engineName: Services.search.defaultEngine.name,
    174        }),
    175        makeVisitResult(context, {
    176          uri: "http://kitten.com/",
    177          title: "kitten",
    178          source: UrlbarUtils.RESULT_SOURCE.HISTORY,
    179        }),
    180      ],
    181    });
    182 
    183    await cleanupPlaces();
    184  }
    185 );
    186 
    187 add_task(async function test_deduplication_of_embedded_url_switchTab_result() {
    188  let uri = Services.io.newURI("http://kitten.com/");
    189 
    190  await PlacesTestUtils.addVisits([
    191    {
    192      uri: "http://example.com/?url=http://kitten.com/",
    193      title: "kitten",
    194    },
    195    {
    196      uri,
    197      title: "kitten",
    198    },
    199  ]);
    200 
    201  await addOpenPages(uri, 1);
    202 
    203  let context = createContext("kitten", {
    204    isPrivate: false,
    205    allowAutofill: false,
    206  });
    207 
    208  await check_results({
    209    context,
    210    matches: [
    211      makeSearchResult(context, {
    212        heuristic: true,
    213        query: "kitten",
    214        engineName: Services.search.defaultEngine.name,
    215      }),
    216      makeTabSwitchResult(context, {
    217        source: UrlbarUtils.RESULT_SOURCE.TAB,
    218        uri: "http://kitten.com/",
    219        title: "kitten",
    220      }),
    221    ],
    222  });
    223 
    224  await removeOpenPages(uri, 1);
    225  await cleanupPlaces();
    226 });