1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/autocomplete/test_swap_protocol.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 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 bug 424717 to make sure searching with an existing location like 1.10 + * http://site/ also matches https://site/ or ftp://site/. Same thing for 1.11 + * ftp://site/ and https://site/. 1.12 + * 1.13 + * Test bug 461483 to make sure a search for "w" doesn't match the "www." from 1.14 + * site subdomains. 1.15 + */ 1.16 + 1.17 +// Define some shared uris and titles (each page needs its own uri) 1.18 +let kURIs = [ 1.19 + "http://www.site/", 1.20 + "http://site/", 1.21 + "ftp://ftp.site/", 1.22 + "ftp://site/", 1.23 + "https://www.site/", 1.24 + "https://site/", 1.25 + "http://woohoo/", 1.26 + "http://wwwwwwacko/", 1.27 +]; 1.28 +let kTitles = [ 1.29 + "title", 1.30 +]; 1.31 + 1.32 +// Add various protocols of site 1.33 +addPageBook(0, 0); 1.34 +addPageBook(1, 0); 1.35 +addPageBook(2, 0); 1.36 +addPageBook(3, 0); 1.37 +addPageBook(4, 0); 1.38 +addPageBook(5, 0); 1.39 +addPageBook(6, 0); 1.40 +addPageBook(7, 0); 1.41 + 1.42 +let allSite = [0,1,2,3,4,5]; 1.43 + 1.44 +// Provide for each test: description; search terms; array of gPages indices of 1.45 +// pages that should match; optional function to be run before the test 1.46 +let gTests = [ 1.47 + ["0: http://www.site matches all site", "http://www.site", allSite], 1.48 + ["1: http://site matches all site", "http://site", allSite], 1.49 + ["2: ftp://ftp.site matches itself", "ftp://ftp.site", [2]], 1.50 + ["3: ftp://site matches all site", "ftp://site", allSite], 1.51 + ["4: https://www.site matches all site", "https://www.site", allSite], 1.52 + ["5: https://site matches all site", "https://site", allSite], 1.53 + ["6: www.site matches all site", "www.site", allSite], 1.54 + 1.55 + ["7: w matches none of www.", "w", [6,7]], 1.56 + ["8: http://w matches none of www.", "w", [6,7]], 1.57 + ["9: http://www.w matches none of www.", "w", [6,7]], 1.58 + 1.59 + ["10: ww matches none of www.", "ww", [7]], 1.60 + ["11: http://ww matches none of www.", "http://ww", [7]], 1.61 + ["12: http://www.ww matches none of www.", "http://www.ww", [7]], 1.62 + 1.63 + ["13: www matches none of www.", "www", [7]], 1.64 + ["14: http://www matches none of www.", "http://www", [7]], 1.65 + ["15: http://www.www matches none of www.", "http://www.www", [7]], 1.66 +];