michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * Test for bug 426864 that makes sure the empty search (drop down list) only michael@0: * shows typed pages from history. michael@0: */ michael@0: michael@0: // Define some shared uris and titles (each page needs its own uri) michael@0: let kURIs = [ michael@0: "http://foo/0", michael@0: "http://foo/1", michael@0: "http://foo/2", michael@0: "http://foo/3", michael@0: "http://foo/4", michael@0: "http://foo/5", michael@0: ]; michael@0: let kTitles = [ michael@0: "title", michael@0: ]; michael@0: michael@0: // Visited (in history) michael@0: addPageBook(0, 0); // history michael@0: addPageBook(1, 0, 0); // bookmark michael@0: addPageBook(2, 0); // history typed michael@0: addPageBook(3, 0, 0); // bookmark typed michael@0: michael@0: // Unvisited bookmark michael@0: addPageBook(4, 0, 0); // bookmark michael@0: addPageBook(5, 0, 0); // bookmark typed michael@0: michael@0: // Set some pages as typed michael@0: markTyped([2,3,5], 0); michael@0: // Remove pages from history to treat them as unvisited michael@0: removePages([4,5]); michael@0: michael@0: // Provide for each test: description; search terms; array of gPages indices of michael@0: // pages that should match; optional function to be run before the test michael@0: let gTests = [ michael@0: ["0: Match everything", michael@0: "foo", [0,1,2,3,4,5]], michael@0: ["1: Match only typed history", michael@0: "foo ^ ~", [2,3]], michael@0: ["2: Drop-down empty search matches only typed history", michael@0: "", [2,3]], michael@0: ["3: Drop-down empty search matches everything", michael@0: "", [0,1,2,3,4,5], function () setEmptyPref(0)], michael@0: ["4: Drop-down empty search matches only typed", michael@0: "", [2,3,5], function () setEmptyPref(32)], michael@0: ["5: Drop-down empty search matches only typed history", michael@0: "", [2,3], clearEmptyPref], michael@0: ]; michael@0: michael@0: function setEmptyPref(aValue) michael@0: prefs.setIntPref("browser.urlbar.default.behavior.emptyRestriction", aValue); michael@0: michael@0: function clearEmptyPref() michael@0: { michael@0: if (prefs.prefHasUserValue("browser.urlbar.default.behavior.emptyRestriction")) michael@0: prefs.clearUserPref("browser.urlbar.default.behavior.emptyRestriction"); michael@0: } michael@0: