tor-browser

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

test_escaping_escapeSelf.js (1888B)


      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
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /**
      6 * Test bug 422698 to make sure searches with urls from the location bar
      7 * correctly match itself when it contains escaped characters.
      8 */
      9 
     10 testEngine_setup();
     11 
     12 add_task(async function test_escape() {
     13  Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
     14  Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
     15  registerCleanupFunction(() => {
     16    Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
     17  });
     18 
     19  let uri1 = Services.io.newURI("http://unescapeduri/");
     20  let uri2 = Services.io.newURI("http://escapeduri/%40/");
     21  await PlacesTestUtils.addVisits([
     22    { uri: uri1, title: "title" },
     23    { uri: uri2, title: "title" },
     24  ]);
     25 
     26  info("Unescaped location matches itself");
     27  let context = createContext("http://unescapeduri/", { isPrivate: false });
     28  await check_results({
     29    context,
     30    matches: [
     31      makeVisitResult(context, {
     32        uri: uri1.spec,
     33        title: "title",
     34        iconUri: `page-icon:${uri1.spec}`,
     35        source: UrlbarUtils.RESULT_SOURCE.HISTORY,
     36        heuristic: true,
     37      }),
     38      // Note that uri2 does not appear in results.
     39    ],
     40  });
     41 
     42  info("Escaped location matches itself");
     43  context = createContext("http://escapeduri/%40", { isPrivate: false });
     44  await check_results({
     45    context,
     46    matches: [
     47      makeVisitResult(context, {
     48        uri: "http://escapeduri/%40",
     49        title: "http://escapeduri/@",
     50        iconUri: "page-icon:http://escapeduri/",
     51        source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
     52        heuristic: true,
     53      }),
     54      makeVisitResult(context, {
     55        uri: uri2.spec,
     56        title: "title",
     57      }),
     58    ],
     59  });
     60 
     61  await cleanupPlaces();
     62 });