From 9a6a4b23e7c10b1b18be78c26a56a7b189231988 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Mon, 3 Jun 2013 12:17:36 +0200 Subject: [PATCH] Bug 874407 - new visits are inserted incorrectly in the Library and the sidebar treeviews. r=Mano --- browser/components/places/content/treeView.js | 8 +- .../components/places/tests/chrome/head.js | 14 +++ .../places/tests/chrome/test_bug549192.xul | 100 +++++++++--------- 3 files changed, 71 insertions(+), 51 deletions(-) diff --git a/browser/components/places/content/treeView.js b/browser/components/places/content/treeView.js index c7975a8d973..a197f556bd8 100644 --- a/browser/components/places/content/treeView.js +++ b/browser/components/places/content/treeView.js @@ -718,7 +718,13 @@ PlacesTreeView.prototype = { if (PlacesUtils.nodeIsSeparator(aNode) && this.isSorted()) return; - let oldRow = this._getRowForNode(aNode, true); + // 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; // If this node is a container it could take up more than one row. let count = this._countVisibleRowsForNodeAtRow(oldRow); diff --git a/browser/components/places/tests/chrome/head.js b/browser/components/places/tests/chrome/head.js index 90d19c9defe..878c28c9291 100644 --- a/browser/components/places/tests/chrome/head.js +++ b/browser/components/places/tests/chrome/head.js @@ -53,3 +53,17 @@ 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(); +} diff --git a/browser/components/places/tests/chrome/test_bug549192.xul b/browser/components/places/tests/chrome/test_bug549192.xul index e5916431ccd..f193bf82cd1 100644 --- a/browser/components/places/tests/chrome/test_bug549192.xul +++ b/browser/components/places/tests/chrome/test_bug549192.xul @@ -35,9 +35,9 @@