toolkit/components/places/tests/autocomplete/test_empty_search.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     5 /**
     6  * Test for bug 426864 that makes sure the empty search (drop down list) only
     7  * shows typed pages from history.
     8  */
    10 // Define some shared uris and titles (each page needs its own uri)
    11 let kURIs = [
    12   "http://foo/0",
    13   "http://foo/1",
    14   "http://foo/2",
    15   "http://foo/3",
    16   "http://foo/4",
    17   "http://foo/5",
    18 ];
    19 let kTitles = [
    20   "title",
    21 ];
    23 // Visited (in history)
    24 addPageBook(0, 0); // history
    25 addPageBook(1, 0, 0); // bookmark
    26 addPageBook(2, 0); // history typed
    27 addPageBook(3, 0, 0); // bookmark typed
    29 // Unvisited bookmark
    30 addPageBook(4, 0, 0); // bookmark
    31 addPageBook(5, 0, 0); // bookmark typed
    33 // Set some pages as typed
    34 markTyped([2,3,5], 0);
    35 // Remove pages from history to treat them as unvisited
    36 removePages([4,5]);
    38 // Provide for each test: description; search terms; array of gPages indices of
    39 // pages that should match; optional function to be run before the test
    40 let gTests = [
    41   ["0: Match everything",
    42    "foo", [0,1,2,3,4,5]],
    43   ["1: Match only typed history",
    44    "foo ^ ~", [2,3]],
    45   ["2: Drop-down empty search matches only typed history",
    46    "", [2,3]],
    47   ["3: Drop-down empty search matches everything",
    48    "", [0,1,2,3,4,5], function () setEmptyPref(0)],
    49   ["4: Drop-down empty search matches only typed",
    50    "", [2,3,5], function () setEmptyPref(32)],
    51   ["5: Drop-down empty search matches only typed history",
    52    "", [2,3], clearEmptyPref],
    53 ];
    55 function setEmptyPref(aValue)
    56   prefs.setIntPref("browser.urlbar.default.behavior.emptyRestriction", aValue);
    58 function clearEmptyPref()
    59 {
    60   if (prefs.prefHasUserValue("browser.urlbar.default.behavior.emptyRestriction"))
    61     prefs.clearUserPref("browser.urlbar.default.behavior.emptyRestriction");
    62 }

mercurial