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 392143 that puts keyword results into the autocomplete. Makes michael@0: * sure that multiple parameter queries get spaces converted to +, + converted michael@0: * to %2B, non-ascii become escaped, and pages in history that match the michael@0: * keyword uses the page's title. michael@0: * michael@0: * Also test for bug 249468 by making sure multiple keyword bookmarks with the michael@0: * same keyword appear in the list. michael@0: */ michael@0: michael@0: // Details for the keyword bookmark michael@0: let keyBase = "http://abc/?search="; michael@0: let keyKey = "key"; michael@0: michael@0: // A second keyword bookmark with the same keyword michael@0: let otherBase = "http://xyz/?foo="; michael@0: michael@0: let unescaped = "ユニコード"; michael@0: let pageInHistory = "ThisPageIsInHistory"; michael@0: michael@0: // Define some shared uris and titles (each page needs its own uri) michael@0: let kURIs = [ michael@0: keyBase + "%s", michael@0: keyBase + "term", michael@0: keyBase + "multi+word", michael@0: keyBase + "blocking%2B", michael@0: keyBase + unescaped, michael@0: keyBase + pageInHistory, michael@0: keyBase, michael@0: otherBase + "%s", michael@0: keyBase + "twoKey", michael@0: otherBase + "twoKey" michael@0: ]; michael@0: let kTitles = [ michael@0: "Generic page title", michael@0: "Keyword title", michael@0: ]; michael@0: michael@0: // Add the keyword bookmark michael@0: addPageBook(0, 0, 1, [], keyKey); michael@0: // Add in the "fake pages" for keyword searches michael@0: gPages[1] = [1,1]; michael@0: gPages[2] = [2,1]; michael@0: gPages[3] = [3,1]; michael@0: gPages[4] = [4,1]; michael@0: // Add a page into history michael@0: addPageBook(5, 0); michael@0: gPages[6] = [6,1]; 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: Plain keyword query", michael@0: keyKey + " term", [1]], michael@0: ["1: Multi-word keyword query", michael@0: keyKey + " multi word", [2]], michael@0: ["2: Keyword query with +", michael@0: keyKey + " blocking+", [3]], michael@0: ["3: Unescaped term in query", michael@0: keyKey + " " + unescaped, [4]], michael@0: ["4: Keyword that happens to match a page", michael@0: keyKey + " " + pageInHistory, [5]], michael@0: ["5: Keyword without query (without space)", michael@0: keyKey, [6]], michael@0: ["6: Keyword without query (with space)", michael@0: keyKey + " ", [6]], michael@0: michael@0: // This adds a second keyword so anything after this will match 2 keywords michael@0: ["7: Two keywords matched", michael@0: keyKey + " twoKey", [8,9], michael@0: function() { michael@0: // Add the keyword search as well as search results michael@0: addPageBook(7, 0, 1, [], keyKey); michael@0: gPages[8] = [8,1]; michael@0: gPages[9] = [9,1]; michael@0: }] michael@0: ];