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
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Check that bookmarklets are returned by searches with searchTerms.
6 let testData = [
7 { isInQuery: true
8 , isBookmark: true
9 , title: "bookmark 1"
10 , uri: "http://mozilla.org/script/"
11 },
13 { isInQuery: true
14 , isBookmark: true
15 , title: "bookmark 2"
16 , uri: "javascript:alert('moz');"
17 }
18 ];
20 function run_test()
21 {
22 run_next_test();
23 }
25 add_task(function test_initalize()
26 {
27 yield task_populateDB(testData);
28 });
30 add_test(function test_search_by_title()
31 {
32 let query = PlacesUtils.history.getNewQuery();
33 query.searchTerms = "bookmark";
34 let options = PlacesUtils.history.getNewQueryOptions();
35 options.queryType = options.QUERY_TYPE_BOOKMARKS;
36 let root = PlacesUtils.history.executeQuery(query, options).root;
37 root.containerOpen = true;
38 compareArrayToResult(testData, root);
39 root.containerOpen = false;
41 run_next_test();
42 });
44 add_test(function test_search_by_schemeToken()
45 {
46 let query = PlacesUtils.history.getNewQuery();
47 query.searchTerms = "script";
48 let options = PlacesUtils.history.getNewQueryOptions();
49 options.queryType = options.QUERY_TYPE_BOOKMARKS;
50 let root = PlacesUtils.history.executeQuery(query, options).root;
51 root.containerOpen = true;
52 compareArrayToResult(testData, root);
53 root.containerOpen = false;
55 run_next_test();
56 });
58 add_test(function test_search_by_uriAndTitle()
59 {
60 let query = PlacesUtils.history.getNewQuery();
61 query.searchTerms = "moz";
62 let options = PlacesUtils.history.getNewQueryOptions();
63 options.queryType = options.QUERY_TYPE_BOOKMARKS;
64 let root = PlacesUtils.history.executeQuery(query, options).root;
65 root.containerOpen = true;
66 compareArrayToResult(testData, root);
67 root.containerOpen = false;
69 run_next_test();
70 });