|
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 for bug 426864 that makes sure the empty search (drop down list) only |
|
7 * shows typed pages from history. |
|
8 */ |
|
9 |
|
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 ]; |
|
22 |
|
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 |
|
28 |
|
29 // Unvisited bookmark |
|
30 addPageBook(4, 0, 0); // bookmark |
|
31 addPageBook(5, 0, 0); // bookmark typed |
|
32 |
|
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]); |
|
37 |
|
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 ]; |
|
54 |
|
55 function setEmptyPref(aValue) |
|
56 prefs.setIntPref("browser.urlbar.default.behavior.emptyRestriction", aValue); |
|
57 |
|
58 function clearEmptyPref() |
|
59 { |
|
60 if (prefs.prefHasUserValue("browser.urlbar.default.behavior.emptyRestriction")) |
|
61 prefs.clearUserPref("browser.urlbar.default.behavior.emptyRestriction"); |
|
62 } |
|
63 |