Bug 422163 - Split History in day containers in the Library (like sidebar BY DATE), r=dietrich ui-r=beltzner

This commit is contained in:
Marco Bonardo 2009-03-30 23:08:24 +02:00
parent f4ee30d3d4
commit f783819af6
6 changed files with 152 additions and 3 deletions

View File

@ -688,6 +688,16 @@ var PlacesOrganizer = {
gEditItemOverlay.initPanel(itemId, { hiddenRows: ["folderPicker"],
forceReadOnly: readOnly });
// Dynamically generated queries, like history date containers, have
// itemId !=0 and do not exist in history. For them the panel is
// read-only, but empty, since it can't get a valid title for the object.
// In such a case we force the title using the selectedNode one, for UI
// polishness.
if (aSelectedNode.itemId == -1 &&
(PlacesUtils.nodeIsDay(aSelectedNode) ||
PlacesUtils.nodeIsHost(aSelectedNode)))
gEditItemOverlay._element("namePicker").value = aSelectedNode.title;
this._detectAndSetDetailsPaneMinimalState(aSelectedNode);
}
else if (!aSelectedNode && aNodeList[0]) {

View File

@ -62,7 +62,7 @@ const LMANNO_FEEDURI = "livemark/feedURI";
const LMANNO_SITEURI = "livemark/siteURI";
const ORGANIZER_FOLDER_ANNO = "PlacesOrganizer/OrganizerFolder";
const ORGANIZER_QUERY_ANNO = "PlacesOrganizer/OrganizerQuery";
const ORGANIZER_LEFTPANE_VERSION = 5;
const ORGANIZER_LEFTPANE_VERSION = 6;
const EXCLUDE_FROM_BACKUP_ANNO = "places/excludeFromBackup";
#ifdef XP_MACOSX
@ -1195,7 +1195,9 @@ var PlacesUIUtils = {
PlacesUtils.bookmarks.setFolderReadonly(leftPaneRoot, true);
// History Query
let uri = PlacesUtils._uri("place:sort=4&");
let uri = PlacesUtils._uri("place:type="+
Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_QUERY +
"&sort=4");
let title = self.getString("OrganizerQueryHistory");
let itemId = PlacesUtils.bookmarks.insertBookmark(leftPaneRoot, uri, -1, title);
PlacesUtils.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,

View File

@ -53,6 +53,7 @@ _BROWSER_TEST_FILES = \
browser_library_panel_leak.js \
browser_library_search.js \
browser_history_sidebar_search.js \
browser_library_left_pane_migration.js \
$(NULL)
libs:: $(_BROWSER_TEST_FILES)

View File

@ -127,6 +127,9 @@ function test() {
copyHistNode: function (){
// focus the history object
PO.selectLeftPaneQuery("History");
var histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
histContainer.containerOpen = true;
PO._places.selectNode(histContainer.getChild(0));
this.histNode = PO._content.view.nodeForTreeIndex(0);
PO._content.selectNode(this.histNode);
is(this.histNode.uri, MOZURISPEC,
@ -159,6 +162,9 @@ function test() {
historyNode: function (){
// re-focus the history again
PO.selectLeftPaneQuery("History");
var histContainer = PO._places.selectedNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
histContainer.containerOpen = true;
PO._places.selectNode(histContainer.getChild(0));
var histNode = PO._content.view.nodeForTreeIndex(0);
ok(histNode, "histNode exists: " + histNode.title);
// check to see if the history node is tagged!

View File

@ -0,0 +1,130 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Places test code.
*
* The Initial Developer of the Original Code is Mozilla Corp.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Marco Bonardo <mak77@bonardo.net> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by devaring the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not devare
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* Test we correctly migrate Library left pane to latest version
*/
const TEST_URI = "http://www.mozilla.org/";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var windowObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic === "domwindowopened") {
ww.unregisterNotification(this);
var organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
organizer.addEventListener("load", function onLoad(event) {
organizer.removeEventListener("load", onLoad, false);
executeSoon(function () {
// Check left pane.
ok(PlacesUIUtils.leftPaneFolderId > 0,
"Left pane folder correctly created");
var leftPaneItems =
PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO, {});
is(leftPaneItems.length, 1,
"We correctly have only 1 left panel folder");
var leftPaneRoot = leftPaneItems[0];
// Check version has been upgraded.
var version =
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION,
"Left pane version has been correctly upgraded");
// Check left pane is populated.
organizer.PlacesOrganizer.selectLeftPaneQuery('History');
ok(organizer.PlacesOrganizer._places.selectedNode.itemId,
"Library left pane is populated and working");
// Close Library window.
organizer.close();
// No need to cleanup anything, we have a correct left pane now.
finish();
});
}, false);
}
}
};
function test() {
waitForExplicitFinish();
// Sanity checks.
ok(PlacesUtils, "PlacesUtils is running in chrome context");
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
ok(ORGANIZER_LEFTPANE_VERSION > 0,
"Left pane version in chrome context, current version is: " + ORGANIZER_LEFTPANE_VERSION );
// Check if we have any left pane folder already set, remove it eventually.
var leftPaneItems = PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO, {});
if (leftPaneItems.length == 1)
PlacesUtils.bookmarks.removeItem(leftPaneItems[0]);
// Create a fake left pane folder with an old version (current version - 1).
var fakeLeftPaneRoot =
PlacesUtils.bookmarks.createFolder(PlacesUtils.placesRootId, "",
PlacesUtils.bookmarks.DEFAULT_INDEX);
PlacesUtils.annotations.setItemAnnotation(fakeLeftPaneRoot,
ORGANIZER_FOLDER_ANNO,
ORGANIZER_LEFTPANE_VERSION-1,
0,
PlacesUtils.annotations.EXPIRE_NEVER);
// Check fake left pane root has been correctly created.
var leftPaneItems =
PlacesUtils.annotations.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO, {});
is(leftPaneItems.length, 1, "We correctly have only 1 left panel folder");
is(leftPaneItems[0], fakeLeftPaneRoot, "left pane root itemId is correct");
// Check version.
var version = PlacesUtils.annotations.getItemAnnotation(fakeLeftPaneRoot,
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION-1, "Left pane version correctly set");
// Open Library, this will upgrade our left pane version.
ww.registerNotification(windowObserver);
ww.openWindow(null,
"chrome://browser/content/places/places.xul",
"",
"chrome,toolbar=yes,dialog=no,resizable",
null);
}

View File

@ -978,7 +978,7 @@ interface nsINavHistoryQueryOptions : nsISupports
* This option excludes all URIs and separators from a bookmarks query.
* This would be used if you just wanted a list of bookmark folders and
* queries (such as the left pane of the places page).
* Ignored for queries over history. Defaults to false.
* Defaults to false.
*/
attribute boolean excludeItems;