1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/queries/test_searchterms-bookmarklets.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Check that bookmarklets are returned by searches with searchTerms. 1.8 + 1.9 +let testData = [ 1.10 + { isInQuery: true 1.11 + , isBookmark: true 1.12 + , title: "bookmark 1" 1.13 + , uri: "http://mozilla.org/script/" 1.14 + }, 1.15 + 1.16 + { isInQuery: true 1.17 + , isBookmark: true 1.18 + , title: "bookmark 2" 1.19 + , uri: "javascript:alert('moz');" 1.20 + } 1.21 +]; 1.22 + 1.23 +function run_test() 1.24 +{ 1.25 + run_next_test(); 1.26 +} 1.27 + 1.28 +add_task(function test_initalize() 1.29 +{ 1.30 + yield task_populateDB(testData); 1.31 +}); 1.32 + 1.33 +add_test(function test_search_by_title() 1.34 +{ 1.35 + let query = PlacesUtils.history.getNewQuery(); 1.36 + query.searchTerms = "bookmark"; 1.37 + let options = PlacesUtils.history.getNewQueryOptions(); 1.38 + options.queryType = options.QUERY_TYPE_BOOKMARKS; 1.39 + let root = PlacesUtils.history.executeQuery(query, options).root; 1.40 + root.containerOpen = true; 1.41 + compareArrayToResult(testData, root); 1.42 + root.containerOpen = false; 1.43 + 1.44 + run_next_test(); 1.45 +}); 1.46 + 1.47 +add_test(function test_search_by_schemeToken() 1.48 +{ 1.49 + let query = PlacesUtils.history.getNewQuery(); 1.50 + query.searchTerms = "script"; 1.51 + let options = PlacesUtils.history.getNewQueryOptions(); 1.52 + options.queryType = options.QUERY_TYPE_BOOKMARKS; 1.53 + let root = PlacesUtils.history.executeQuery(query, options).root; 1.54 + root.containerOpen = true; 1.55 + compareArrayToResult(testData, root); 1.56 + root.containerOpen = false; 1.57 + 1.58 + run_next_test(); 1.59 +}); 1.60 + 1.61 +add_test(function test_search_by_uriAndTitle() 1.62 +{ 1.63 + let query = PlacesUtils.history.getNewQuery(); 1.64 + query.searchTerms = "moz"; 1.65 + let options = PlacesUtils.history.getNewQueryOptions(); 1.66 + options.queryType = options.QUERY_TYPE_BOOKMARKS; 1.67 + let root = PlacesUtils.history.executeQuery(query, options).root; 1.68 + root.containerOpen = true; 1.69 + compareArrayToResult(testData, root); 1.70 + root.containerOpen = false; 1.71 + 1.72 + run_next_test(); 1.73 +});