browser/components/places/tests/chrome/test_bug549192.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial