|
1 <?xml version="1.0"?> |
|
2 |
|
3 <!-- |
|
4 Any copyright is dedicated to the Public Domain. |
|
5 http://creativecommons.org/licenses/publicdomain/ |
|
6 --> |
|
7 |
|
8 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
9 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
10 type="text/css"?> |
|
11 |
|
12 <?xml-stylesheet href="chrome://browser/content/places/places.css"?> |
|
13 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?> |
|
14 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?> |
|
15 |
|
16 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
17 title="549192: History view not updated after deleting entry" |
|
18 onload="runTest();"> |
|
19 |
|
20 <script type="application/javascript" |
|
21 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
22 <script type="application/javascript" src="head.js" /> |
|
23 |
|
24 <body xmlns="http://www.w3.org/1999/xhtml" /> |
|
25 |
|
26 <tree id="tree" |
|
27 type="places" |
|
28 flatList="true" |
|
29 flex="1"> |
|
30 <treecols> |
|
31 <treecol label="Title" id="title" anonid="title" primary="true" ordinal="1" flex="1"/> |
|
32 </treecols> |
|
33 <treechildren flex="1"/> |
|
34 </tree> |
|
35 |
|
36 <script type="application/javascript"><![CDATA[ |
|
37 /** |
|
38 * Bug 874407 |
|
39 * Ensures that history views are updated properly after visits. |
|
40 * Bug 549192 |
|
41 * Ensures that history views are updated after deleting entries. |
|
42 */ |
|
43 |
|
44 SimpleTest.waitForExplicitFinish(); |
|
45 |
|
46 function runTest() { |
|
47 // The mochitest page is added to history. |
|
48 waitForClearHistory(continue_test); |
|
49 } |
|
50 |
|
51 function continue_test() { |
|
52 // Add some visits. |
|
53 let vtime = Date.now() * 1000; |
|
54 const ttype = PlacesUtils.history.TRANSITION_TYPED; |
|
55 let places = |
|
56 [{ uri: Services.io.newURI("http://example.tld/", null, null), |
|
57 visitDate: ++vtime, transition: ttype }, |
|
58 { uri: Services.io.newURI("http://example2.tld/", null, null), |
|
59 visitDate: ++vtime, transition: ttype }, |
|
60 { uri: Services.io.newURI("http://example3.tld/", null, null), |
|
61 visitDate: ++vtime, transition: ttype }]; |
|
62 |
|
63 addVisits(places, function() { |
|
64 // Make a history query. |
|
65 let query = PlacesUtils.history.getNewQuery(); |
|
66 let opts = PlacesUtils.history.getNewQueryOptions(); |
|
67 opts.sortingMode = opts.SORT_BY_DATE_DESCENDING; |
|
68 let queryURI = PlacesUtils.history.queriesToQueryString([query], 1, opts); |
|
69 |
|
70 // Setup the places tree contents. |
|
71 var tree = document.getElementById("tree"); |
|
72 tree.place = queryURI; |
|
73 |
|
74 // loop through the rows and check them. |
|
75 let treeView = tree.view; |
|
76 let selection = treeView.selection; |
|
77 let rc = treeView.rowCount; |
|
78 |
|
79 for (let i = 0; i < rc; i++) { |
|
80 selection.select(i); |
|
81 let node = tree.selectedNode; |
|
82 is(node.uri, places[rc - i - 1].uri.spec, |
|
83 "Found expected node at position " + i + "."); |
|
84 } |
|
85 |
|
86 is(rc, 3, "Found expected number of rows."); |
|
87 |
|
88 // First check live-update of the view when adding visits. |
|
89 places.forEach(place => place.visitDate = ++vtime); |
|
90 addVisits(places, function() { |
|
91 for (let i = 0; i < rc; i++) { |
|
92 selection.select(i); |
|
93 let node = tree.selectedNode; |
|
94 is(node.uri, places[rc - i - 1].uri.spec, |
|
95 "Found expected node at position " + i + "."); |
|
96 } |
|
97 |
|
98 // Now remove the pages and verify live-update again. |
|
99 for (let i = 0; i < rc; i++) { |
|
100 selection.select(0); |
|
101 let node = tree.selectedNode; |
|
102 tree.controller.remove("Removing page"); |
|
103 ok(treeView.treeIndexForNode(node) == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE, |
|
104 node.uri + " removed."); |
|
105 ok(treeView.rowCount == rc - i - 1, "Rows count decreased"); |
|
106 } |
|
107 |
|
108 // Cleanup. |
|
109 waitForClearHistory(SimpleTest.finish); |
|
110 }); |
|
111 }); |
|
112 } |
|
113 |
|
114 ]]></script> |
|
115 </window> |