1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/autocomplete/test_multi_word_search.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/** 1.9 + * Test for bug 401869 to allow multiple words separated by spaces to match in 1.10 + * the page title, page url, or bookmark title to be considered a match. All 1.11 + * terms must match but not all terms need to be in the title, etc. 1.12 + * 1.13 + * Test bug 424216 by making sure bookmark titles are always shown if one is 1.14 + * available. Also bug 425056 makes sure matches aren't found partially in the 1.15 + * page title and partially in the bookmark. 1.16 + */ 1.17 + 1.18 +// Define some shared uris and titles (each page needs its own uri) 1.19 +let kURIs = [ 1.20 + "http://a.b.c/d-e_f/h/t/p", 1.21 + "http://d.e.f/g-h_i/h/t/p", 1.22 + "http://g.h.i/j-k_l/h/t/p", 1.23 + "http://j.k.l/m-n_o/h/t/p", 1.24 +]; 1.25 +let kTitles = [ 1.26 + "f(o)o b<a>r", 1.27 + "b(a)r b<a>z", 1.28 +]; 1.29 + 1.30 +// Regular pages 1.31 +addPageBook(0, 0); 1.32 +addPageBook(1, 1); 1.33 +// Bookmarked pages 1.34 +addPageBook(2, 0, 0); 1.35 +addPageBook(3, 0, 1); 1.36 + 1.37 +// Provide for each test: description; search terms; array of gPages indices of 1.38 +// pages that should match; optional function to be run before the test 1.39 +let gTests = [ 1.40 + ["0: Match 2 terms all in url", 1.41 + "c d", [0]], 1.42 + ["1: Match 1 term in url and 1 term in title", 1.43 + "b e", [0,1]], 1.44 + ["2: Match 3 terms all in title; display bookmark title if matched", 1.45 + "b a z", [1,3]], 1.46 + ["3: Match 2 terms in url and 1 in title; make sure bookmark title is used for search", 1.47 + "k f t", [2]], 1.48 + ["4: Match 3 terms in url and 1 in title", 1.49 + "d i g z", [1]], 1.50 + ["5: Match nothing", 1.51 + "m o z i", []], 1.52 +];