test_pages_alt_frecency.js (3012B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 // This is a basic autocomplete test to ensure enabling the alternative frecency 6 // algorithm doesn't break results and sorts them appropriately. 7 // A more comprehensive testing of the algorithm itself is not included since it 8 // is something that may change frequently according to experimentation results. 9 // Other existing tests will, of course, need to be adapted once an algorithm 10 // is promoted to be the default. 11 12 testEngine_setup(); 13 14 add_task(async function test_autofill() { 15 const searchString = "match"; 16 const singleVisitUrl = "https://singlevisit-match.org/"; 17 const singleVisitBookmarkedUrl = "https://singlevisitbookmarked-match.org/"; 18 const adaptiveVisitUrl = "https://adaptivevisit-match.org/"; 19 const adaptiveManyVisitsUrl = "https://adaptivemanyvisit-match.org/"; 20 const manyVisitsUrl = "https://manyvisits-match.org/"; 21 const sampledVisitsUrl = "https://sampledvisits-match.org/"; 22 const bookmarkedUrl = "https://bookmarked-match.org/"; 23 24 await PlacesUtils.bookmarks.insert({ 25 url: bookmarkedUrl, 26 title: "bookmark", 27 parentGuid: PlacesUtils.bookmarks.toolbarGuid, 28 }); 29 await PlacesUtils.bookmarks.insert({ 30 url: singleVisitBookmarkedUrl, 31 title: "visited bookmark", 32 parentGuid: PlacesUtils.bookmarks.toolbarGuid, 33 }); 34 await PlacesTestUtils.addVisits([ 35 singleVisitUrl, 36 singleVisitBookmarkedUrl, 37 adaptiveVisitUrl, 38 ...new Array(10).fill(adaptiveManyVisitsUrl), 39 ...new Array(100).fill(manyVisitsUrl), 40 ...new Array(10).fill(sampledVisitsUrl), 41 ]); 42 await UrlbarUtils.addToInputHistory(adaptiveVisitUrl, searchString); 43 await UrlbarUtils.addToInputHistory(adaptiveManyVisitsUrl, searchString); 44 45 let context = createContext(searchString, { isPrivate: false }); 46 await check_results({ 47 context, 48 matches: [ 49 makeSearchResult(context, { 50 engineName: "Suggestions", 51 heuristic: true, 52 }), 53 makeVisitResult(context, { 54 uri: adaptiveManyVisitsUrl, 55 title: `test visit for ${adaptiveManyVisitsUrl}`, 56 }), 57 makeVisitResult(context, { 58 uri: adaptiveVisitUrl, 59 title: `test visit for ${adaptiveVisitUrl}`, 60 }), 61 makeVisitResult(context, { 62 uri: manyVisitsUrl, 63 title: `test visit for ${manyVisitsUrl}`, 64 }), 65 makeVisitResult(context, { 66 uri: sampledVisitsUrl, 67 title: `test visit for ${sampledVisitsUrl}`, 68 }), 69 makeBookmarkResult(context, { 70 uri: singleVisitBookmarkedUrl, 71 title: "visited bookmark", 72 }), 73 makeBookmarkResult(context, { 74 uri: bookmarkedUrl, 75 title: "bookmark", 76 }), 77 makeVisitResult(context, { 78 uri: singleVisitUrl, 79 title: `test visit for ${singleVisitUrl}`, 80 }), 81 ], 82 }); 83 84 await PlacesUtils.history.clear(); 85 });