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.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 /**
michael@0 6 * Test for bug 426864 that makes sure the empty search (drop down list) only
michael@0 7 * shows typed pages from history.
michael@0 8 */
michael@0 9
michael@0 10 // Define some shared uris and titles (each page needs its own uri)
michael@0 11 let kURIs = [
michael@0 12 "http://foo/0",
michael@0 13 "http://foo/1",
michael@0 14 "http://foo/2",
michael@0 15 "http://foo/3",
michael@0 16 "http://foo/4",
michael@0 17 "http://foo/5",
michael@0 18 ];
michael@0 19 let kTitles = [
michael@0 20 "title",
michael@0 21 ];
michael@0 22
michael@0 23 // Visited (in history)
michael@0 24 addPageBook(0, 0); // history
michael@0 25 addPageBook(1, 0, 0); // bookmark
michael@0 26 addPageBook(2, 0); // history typed
michael@0 27 addPageBook(3, 0, 0); // bookmark typed
michael@0 28
michael@0 29 // Unvisited bookmark
michael@0 30 addPageBook(4, 0, 0); // bookmark
michael@0 31 addPageBook(5, 0, 0); // bookmark typed
michael@0 32
michael@0 33 // Set some pages as typed
michael@0 34 markTyped([2,3,5], 0);
michael@0 35 // Remove pages from history to treat them as unvisited
michael@0 36 removePages([4,5]);
michael@0 37
michael@0 38 // Provide for each test: description; search terms; array of gPages indices of
michael@0 39 // pages that should match; optional function to be run before the test
michael@0 40 let gTests = [
michael@0 41 ["0: Match everything",
michael@0 42 "foo", [0,1,2,3,4,5]],
michael@0 43 ["1: Match only typed history",
michael@0 44 "foo ^ ~", [2,3]],
michael@0 45 ["2: Drop-down empty search matches only typed history",
michael@0 46 "", [2,3]],
michael@0 47 ["3: Drop-down empty search matches everything",
michael@0 48 "", [0,1,2,3,4,5], function () setEmptyPref(0)],
michael@0 49 ["4: Drop-down empty search matches only typed",
michael@0 50 "", [2,3,5], function () setEmptyPref(32)],
michael@0 51 ["5: Drop-down empty search matches only typed history",
michael@0 52 "", [2,3], clearEmptyPref],
michael@0 53 ];
michael@0 54
michael@0 55 function setEmptyPref(aValue)
michael@0 56 prefs.setIntPref("browser.urlbar.default.behavior.emptyRestriction", aValue);
michael@0 57
michael@0 58 function clearEmptyPref()
michael@0 59 {
michael@0 60 if (prefs.prefHasUserValue("browser.urlbar.default.behavior.emptyRestriction"))
michael@0 61 prefs.clearUserPref("browser.urlbar.default.behavior.emptyRestriction");
michael@0 62 }
michael@0 63

mercurial