Backed out changeset 8c37f4a3e488 (bug 874407) for failures in test_bug549192.xul

This commit is contained in:
Ed Morley 2013-06-03 13:21:41 +01:00
parent 36b419c548
commit 9caf7472df
3 changed files with 52 additions and 72 deletions

View File

@ -718,13 +718,7 @@ PlacesTreeView.prototype = {
if (PlacesUtils.nodeIsSeparator(aNode) && this.isSorted())
return;
// Note that at this point the node has already been moved by the backend,
// so we must give hints to _getRowForNode to get the old row position.
let oldParentRow = aOldParent == this._rootNode ?
undefined : this._getRowForNode(aOldParent, true);
let oldRow = this._getRowForNode(aNode, true, oldParentRow, aOldIndex);
if (oldRow < 0)
throw Cr.NS_ERROR_UNEXPECTED;
let oldRow = this._getRowForNode(aNode, true);
// If this node is a container it could take up more than one row.
let count = this._countVisibleRowsForNodeAtRow(oldRow);

View File

@ -53,17 +53,3 @@ function addVisits(aPlaceInfo, aCallback) {
}
);
}
/**
* Clears history invoking callback when done.
*/
function waitForClearHistory(aCallback) {
const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
Services.obs.removeObserver(observer, TOPIC_EXPIRATION_FINISHED);
aCallback();
}, TOPIC_EXPIRATION_FINISHED, false);
Cc["@mozilla.org/browser/nav-history-service;1"]
.getService(Ci.nsINavHistoryService)
.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
}

View File

@ -35,9 +35,9 @@
<script type="application/javascript"><![CDATA[
/**
* Bug 874407
* Ensures that history views are updated properly after visits.
* Bug 549192
* https://bugzilla.mozilla.org/show_bug.cgi?id=549192
*
* Ensures that history views are updated after deleting entries.
*/
@ -52,64 +52,64 @@
// Add some visits.
let vtime = Date.now() * 1000;
const ttype = PlacesUtils.history.TRANSITION_TYPED;
let places =
addVisits(
[{ uri: Services.io.newURI("http://example.tld/", null, null),
visitDate: vtime, transition: ttype },
{ uri: Services.io.newURI("http://example2.tld/", null, null),
visitDate: vtime++, transition: ttype },
{ uri: Services.io.newURI("http://example3.tld/", null, null),
visitDate: vtime++, transition: ttype }];
visitDate: vtime++, transition: ttype }],
function() {
// Make a history query.
let query = PlacesUtils.history.getNewQuery();
let opts = PlacesUtils.history.getNewQueryOptions();
let queryURI = PlacesUtils.history.queriesToQueryString([query], 1, opts);
addVisits(places, function() {
// Make a history query.
let query = PlacesUtils.history.getNewQuery();
let opts = PlacesUtils.history.getNewQueryOptions();
opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
let queryURI = PlacesUtils.history.queriesToQueryString([query], 1, opts);
// Setup the places tree contents.
var tree = document.getElementById("tree");
tree.place = queryURI;
// Setup the places tree contents.
var tree = document.getElementById("tree");
tree.place = queryURI;
// loop through the rows and check formatting
let treeView = tree.view;
for (let i = 0; i < rc; i++) {
selection.select(rc);
let node = tree.selectedNode;
ok(true, "found " + node.title);
}
let rc = treeView.rowCount;
is(rc, 3, "Rows found.");
let selection = treeView.selection;
for (let i = 0; i < rc; i++) {
selection.select(0);
let node = tree.selectedNode;
tree.controller.remove("Removing page");
ok(treeView.treeIndexForNode(node) == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE,
node.uri + " removed.");
ok(treeView.rowCount == rc - i - 1, "Rows count decreased");
}
// loop through the rows and check them.
let treeView = tree.view;
let selection = treeView.selection;
let rc = treeView.rowCount;
for (let i = 0; i < rc; i++) {
selection.select(i);
let node = tree.selectedNode;
is(node.uri, places[rc - i - 1].uri.spec,
"Found expected node at position " + i + ".");
}
is(rc, 3, "Found expected number of rows.");
// First check live-update of the view when adding visits.
places.forEach(place => place.visitDate = ++vtime);
addVisits(places, function() {
for (let i = 0; i < rc; i++) {
selection.select(i);
let node = tree.selectedNode;
is(node.uri, places[rc - i - 1].uri.spec,
"Found expected node at position " + i + ".");
}
// Now remove the pages and verify live-update again.
for (let i = 0; i < rc; i++) {
selection.select(0);
let node = tree.selectedNode;
tree.controller.remove("Removing page");
ok(treeView.treeIndexForNode(node) == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE,
node.uri + " removed.");
ok(treeView.rowCount == rc - i - 1, "Rows count decreased");
}
// Cleanup.
waitForClearHistory(SimpleTest.finish);
});
});
// Cleanup.
waitForClearHistory(SimpleTest.finish);
});
}
/**
* Clears history invoking callback when done.
*/
function waitForClearHistory(aCallback) {
const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
let observer = {
observe: function(aSubject, aTopic, aData) {
Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED);
aCallback();
}
};
Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false);
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
}
]]></script>
</window>