Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Check that bookmarklets are returned by searches with searchTerms. |
michael@0 | 5 | |
michael@0 | 6 | let testData = [ |
michael@0 | 7 | { isInQuery: true |
michael@0 | 8 | , isBookmark: true |
michael@0 | 9 | , title: "bookmark 1" |
michael@0 | 10 | , uri: "http://mozilla.org/script/" |
michael@0 | 11 | }, |
michael@0 | 12 | |
michael@0 | 13 | { isInQuery: true |
michael@0 | 14 | , isBookmark: true |
michael@0 | 15 | , title: "bookmark 2" |
michael@0 | 16 | , uri: "javascript:alert('moz');" |
michael@0 | 17 | } |
michael@0 | 18 | ]; |
michael@0 | 19 | |
michael@0 | 20 | function run_test() |
michael@0 | 21 | { |
michael@0 | 22 | run_next_test(); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | add_task(function test_initalize() |
michael@0 | 26 | { |
michael@0 | 27 | yield task_populateDB(testData); |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | add_test(function test_search_by_title() |
michael@0 | 31 | { |
michael@0 | 32 | let query = PlacesUtils.history.getNewQuery(); |
michael@0 | 33 | query.searchTerms = "bookmark"; |
michael@0 | 34 | let options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 35 | options.queryType = options.QUERY_TYPE_BOOKMARKS; |
michael@0 | 36 | let root = PlacesUtils.history.executeQuery(query, options).root; |
michael@0 | 37 | root.containerOpen = true; |
michael@0 | 38 | compareArrayToResult(testData, root); |
michael@0 | 39 | root.containerOpen = false; |
michael@0 | 40 | |
michael@0 | 41 | run_next_test(); |
michael@0 | 42 | }); |
michael@0 | 43 | |
michael@0 | 44 | add_test(function test_search_by_schemeToken() |
michael@0 | 45 | { |
michael@0 | 46 | let query = PlacesUtils.history.getNewQuery(); |
michael@0 | 47 | query.searchTerms = "script"; |
michael@0 | 48 | let options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 49 | options.queryType = options.QUERY_TYPE_BOOKMARKS; |
michael@0 | 50 | let root = PlacesUtils.history.executeQuery(query, options).root; |
michael@0 | 51 | root.containerOpen = true; |
michael@0 | 52 | compareArrayToResult(testData, root); |
michael@0 | 53 | root.containerOpen = false; |
michael@0 | 54 | |
michael@0 | 55 | run_next_test(); |
michael@0 | 56 | }); |
michael@0 | 57 | |
michael@0 | 58 | add_test(function test_search_by_uriAndTitle() |
michael@0 | 59 | { |
michael@0 | 60 | let query = PlacesUtils.history.getNewQuery(); |
michael@0 | 61 | query.searchTerms = "moz"; |
michael@0 | 62 | let options = PlacesUtils.history.getNewQueryOptions(); |
michael@0 | 63 | options.queryType = options.QUERY_TYPE_BOOKMARKS; |
michael@0 | 64 | let root = PlacesUtils.history.executeQuery(query, options).root; |
michael@0 | 65 | root.containerOpen = true; |
michael@0 | 66 | compareArrayToResult(testData, root); |
michael@0 | 67 | root.containerOpen = false; |
michael@0 | 68 | |
michael@0 | 69 | run_next_test(); |
michael@0 | 70 | }); |