toolkit/components/places/tests/queries/test_searchterms-bookmarklets.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:06a50c413fe9
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 // Check that bookmarklets are returned by searches with searchTerms.
5
6 let testData = [
7 { isInQuery: true
8 , isBookmark: true
9 , title: "bookmark 1"
10 , uri: "http://mozilla.org/script/"
11 },
12
13 { isInQuery: true
14 , isBookmark: true
15 , title: "bookmark 2"
16 , uri: "javascript:alert('moz');"
17 }
18 ];
19
20 function run_test()
21 {
22 run_next_test();
23 }
24
25 add_task(function test_initalize()
26 {
27 yield task_populateDB(testData);
28 });
29
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;
40
41 run_next_test();
42 });
43
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;
54
55 run_next_test();
56 });
57
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;
68
69 run_next_test();
70 });

mercurial