toolkit/components/places/tests/autocomplete/test_keyword_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 392143 that puts keyword results into the autocomplete. Makes
michael@0 7 * sure that multiple parameter queries get spaces converted to +, + converted
michael@0 8 * to %2B, non-ascii become escaped, and pages in history that match the
michael@0 9 * keyword uses the page's title.
michael@0 10 *
michael@0 11 * Also test for bug 249468 by making sure multiple keyword bookmarks with the
michael@0 12 * same keyword appear in the list.
michael@0 13 */
michael@0 14
michael@0 15 // Details for the keyword bookmark
michael@0 16 let keyBase = "http://abc/?search=";
michael@0 17 let keyKey = "key";
michael@0 18
michael@0 19 // A second keyword bookmark with the same keyword
michael@0 20 let otherBase = "http://xyz/?foo=";
michael@0 21
michael@0 22 let unescaped = "ユニコード";
michael@0 23 let pageInHistory = "ThisPageIsInHistory";
michael@0 24
michael@0 25 // Define some shared uris and titles (each page needs its own uri)
michael@0 26 let kURIs = [
michael@0 27 keyBase + "%s",
michael@0 28 keyBase + "term",
michael@0 29 keyBase + "multi+word",
michael@0 30 keyBase + "blocking%2B",
michael@0 31 keyBase + unescaped,
michael@0 32 keyBase + pageInHistory,
michael@0 33 keyBase,
michael@0 34 otherBase + "%s",
michael@0 35 keyBase + "twoKey",
michael@0 36 otherBase + "twoKey"
michael@0 37 ];
michael@0 38 let kTitles = [
michael@0 39 "Generic page title",
michael@0 40 "Keyword title",
michael@0 41 ];
michael@0 42
michael@0 43 // Add the keyword bookmark
michael@0 44 addPageBook(0, 0, 1, [], keyKey);
michael@0 45 // Add in the "fake pages" for keyword searches
michael@0 46 gPages[1] = [1,1];
michael@0 47 gPages[2] = [2,1];
michael@0 48 gPages[3] = [3,1];
michael@0 49 gPages[4] = [4,1];
michael@0 50 // Add a page into history
michael@0 51 addPageBook(5, 0);
michael@0 52 gPages[6] = [6,1];
michael@0 53
michael@0 54 // Provide for each test: description; search terms; array of gPages indices of
michael@0 55 // pages that should match; optional function to be run before the test
michael@0 56 let gTests = [
michael@0 57 ["0: Plain keyword query",
michael@0 58 keyKey + " term", [1]],
michael@0 59 ["1: Multi-word keyword query",
michael@0 60 keyKey + " multi word", [2]],
michael@0 61 ["2: Keyword query with +",
michael@0 62 keyKey + " blocking+", [3]],
michael@0 63 ["3: Unescaped term in query",
michael@0 64 keyKey + " " + unescaped, [4]],
michael@0 65 ["4: Keyword that happens to match a page",
michael@0 66 keyKey + " " + pageInHistory, [5]],
michael@0 67 ["5: Keyword without query (without space)",
michael@0 68 keyKey, [6]],
michael@0 69 ["6: Keyword without query (with space)",
michael@0 70 keyKey + " ", [6]],
michael@0 71
michael@0 72 // This adds a second keyword so anything after this will match 2 keywords
michael@0 73 ["7: Two keywords matched",
michael@0 74 keyKey + " twoKey", [8,9],
michael@0 75 function() {
michael@0 76 // Add the keyword search as well as search results
michael@0 77 addPageBook(7, 0, 1, [], keyKey);
michael@0 78 gPages[8] = [8,1];
michael@0 79 gPages[9] = [9,1];
michael@0 80 }]
michael@0 81 ];

mercurial