michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Check that bookmarklets are returned by searches with searchTerms. michael@0: michael@0: let testData = [ michael@0: { isInQuery: true michael@0: , isBookmark: true michael@0: , title: "bookmark 1" michael@0: , uri: "http://mozilla.org/script/" michael@0: }, michael@0: michael@0: { isInQuery: true michael@0: , isBookmark: true michael@0: , title: "bookmark 2" michael@0: , uri: "javascript:alert('moz');" michael@0: } michael@0: ]; michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function test_initalize() michael@0: { michael@0: yield task_populateDB(testData); michael@0: }); michael@0: michael@0: add_test(function test_search_by_title() michael@0: { michael@0: let query = PlacesUtils.history.getNewQuery(); michael@0: query.searchTerms = "bookmark"; michael@0: let options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.queryType = options.QUERY_TYPE_BOOKMARKS; michael@0: let root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(testData, root); michael@0: root.containerOpen = false; michael@0: michael@0: run_next_test(); michael@0: }); michael@0: michael@0: add_test(function test_search_by_schemeToken() michael@0: { michael@0: let query = PlacesUtils.history.getNewQuery(); michael@0: query.searchTerms = "script"; michael@0: let options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.queryType = options.QUERY_TYPE_BOOKMARKS; michael@0: let root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(testData, root); michael@0: root.containerOpen = false; michael@0: michael@0: run_next_test(); michael@0: }); michael@0: michael@0: add_test(function test_search_by_uriAndTitle() michael@0: { michael@0: let query = PlacesUtils.history.getNewQuery(); michael@0: query.searchTerms = "moz"; michael@0: let options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.queryType = options.QUERY_TYPE_BOOKMARKS; michael@0: let root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(testData, root); michael@0: root.containerOpen = false; michael@0: michael@0: run_next_test(); michael@0: });