tor-browser

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

test_download_embed_bookmarks.js (4245B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
      2 * vim:set ts=2 sw=2 sts=2 et:
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 /**
      8 * Tests bug 449406 to ensure that TRANSITION_DOWNLOAD, TRANSITION_EMBED and
      9 * TRANSITION_FRAMED_LINK bookmarked uri's show up in the location bar.
     10 */
     11 
     12 testEngine_setup();
     13 
     14 const TRANSITION_EMBED = PlacesUtils.history.TRANSITION_EMBED;
     15 const TRANSITION_FRAMED_LINK = PlacesUtils.history.TRANSITION_FRAMED_LINK;
     16 const TRANSITION_DOWNLOAD = PlacesUtils.history.TRANSITION_DOWNLOAD;
     17 
     18 add_task(async function test_download_embed_bookmarks() {
     19  Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
     20  registerCleanupFunction(() => {
     21    Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
     22  });
     23 
     24  let uri1 = Services.io.newURI("http://download/bookmarked");
     25  let uri2 = Services.io.newURI("http://embed/bookmarked");
     26  let uri3 = Services.io.newURI("http://framed/bookmarked");
     27  let uri4 = Services.io.newURI("http://download");
     28  let uri5 = Services.io.newURI("http://embed");
     29  let uri6 = Services.io.newURI("http://framed");
     30  await PlacesTestUtils.addVisits([
     31    { uri: uri1, title: "download-bookmark", transition: TRANSITION_DOWNLOAD },
     32    { uri: uri2, title: "embed-bookmark", transition: TRANSITION_EMBED },
     33    { uri: uri3, title: "framed-bookmark", transition: TRANSITION_FRAMED_LINK },
     34    { uri: uri4, title: "download2", transition: TRANSITION_DOWNLOAD },
     35    { uri: uri5, title: "embed2", transition: TRANSITION_EMBED },
     36    { uri: uri6, title: "framed2", transition: TRANSITION_FRAMED_LINK },
     37  ]);
     38  await PlacesTestUtils.addBookmarkWithDetails({
     39    uri: uri1,
     40    title: "download-bookmark",
     41  });
     42  await PlacesTestUtils.addBookmarkWithDetails({
     43    uri: uri2,
     44    title: "embed-bookmark",
     45  });
     46  await PlacesTestUtils.addBookmarkWithDetails({
     47    uri: uri3,
     48    title: "framed-bookmark",
     49  });
     50  await PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies();
     51 
     52  info("Searching for bookmarked download uri matches");
     53  let context = createContext("download-bookmark", { isPrivate: false });
     54  await check_results({
     55    context,
     56    matches: [
     57      makeSearchResult(context, {
     58        engineName: SUGGESTIONS_ENGINE_NAME,
     59        heuristic: true,
     60      }),
     61      makeBookmarkResult(context, {
     62        uri: uri1.spec,
     63        title: "download-bookmark",
     64      }),
     65    ],
     66  });
     67 
     68  info("Searching for bookmarked embed uri matches");
     69  context = createContext("embed-bookmark", { isPrivate: false });
     70  await check_results({
     71    context,
     72    matches: [
     73      makeSearchResult(context, {
     74        engineName: SUGGESTIONS_ENGINE_NAME,
     75        heuristic: true,
     76      }),
     77      makeBookmarkResult(context, {
     78        uri: uri2.spec,
     79        title: "embed-bookmark",
     80      }),
     81    ],
     82  });
     83 
     84  info("Searching for bookmarked framed uri matches");
     85  context = createContext("framed-bookmark", { isPrivate: false });
     86  await check_results({
     87    context,
     88    matches: [
     89      makeSearchResult(context, {
     90        engineName: SUGGESTIONS_ENGINE_NAME,
     91        heuristic: true,
     92      }),
     93      makeBookmarkResult(context, {
     94        uri: uri3.spec,
     95        title: "framed-bookmark",
     96      }),
     97    ],
     98  });
     99 
    100  info("Searching for download uri does not match");
    101  context = createContext("download2", { isPrivate: false });
    102  await check_results({
    103    context,
    104    matches: [
    105      makeSearchResult(context, {
    106        engineName: SUGGESTIONS_ENGINE_NAME,
    107        heuristic: true,
    108      }),
    109    ],
    110  });
    111 
    112  info("Searching for embed uri does not match");
    113  context = createContext("embed2", { isPrivate: false });
    114  await check_results({
    115    context,
    116    matches: [
    117      makeSearchResult(context, {
    118        engineName: SUGGESTIONS_ENGINE_NAME,
    119        heuristic: true,
    120      }),
    121    ],
    122  });
    123 
    124  info("Searching for framed uri does not match");
    125  context = createContext("framed2", { isPrivate: false });
    126  await check_results({
    127    context,
    128    matches: [
    129      makeSearchResult(context, {
    130        engineName: SUGGESTIONS_ENGINE_NAME,
    131        heuristic: true,
    132      }),
    133    ],
    134  });
    135 
    136  await cleanupPlaces();
    137 });