test_providerPlaces_duplicate_entries.js (1170B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function test_duplicates() { 7 const TEST_URL = "https://history.mozilla.org/"; 8 await PlacesTestUtils.addVisits([ 9 { uri: TEST_URL, title: "Test history" }, 10 { uri: TEST_URL + "?#", title: "Test history" }, 11 { uri: TEST_URL + "#", title: "Test history" }, 12 ]); 13 14 let controller = UrlbarTestUtils.newMockController(); 15 let searchString = "^Hist"; 16 let context = createContext(searchString, { isPrivate: false }); 17 await controller.startQuery(context); 18 19 // The first result will be a search heuristic, which we don't care about for 20 // this test. 21 info( 22 "Results:\n" + 23 context.results.map(m => `${m.title} - ${m.payload.url}`).join("\n") 24 ); 25 Assert.equal( 26 context.results.length, 27 2, 28 "Found the expected number of matches" 29 ); 30 Assert.equal( 31 context.results[1].type, 32 UrlbarUtils.RESULT_TYPE.URL, 33 "Should have a history result" 34 ); 35 Assert.equal( 36 context.results[1].payload.url, 37 TEST_URL + "#", 38 "Check result URL" 39 ); 40 41 await PlacesUtils.history.clear(); 42 });