mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
b=421235, r=gavin, a1.9=dsicore. Add new bookmark roots to FUEL
This commit is contained in:
parent
e818e971a0
commit
4aa97befa7
@ -108,7 +108,7 @@ var gAddedEngines = [];
|
||||
function setupKeywords() {
|
||||
var searchService = Cc["@mozilla.org/browser/search-service;1"].
|
||||
getService(Ci.nsIBrowserSearchService);
|
||||
gBMFolder = Application.bookmarks.addFolder("keyword-test");
|
||||
gBMFolder = Application.bookmarks.menu.addFolder("keyword-test");
|
||||
for each (var item in testData) {
|
||||
var data = item[0];
|
||||
if (data instanceof bmKeywordData) {
|
||||
|
@ -540,6 +540,35 @@ interface fuelIBookmarkFolder : nsISupports
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Interface representing a container for bookmark roots. Roots
|
||||
* are the top level parents for the various types of bookmarks in the system.
|
||||
*/
|
||||
[scriptable, uuid(c9a80870-eb3c-11dc-95ff-0800200c9a66)]
|
||||
interface fuelIBookmarkRoots : nsISupports
|
||||
{
|
||||
/**
|
||||
* The folder for the 'bookmarks menu' root.
|
||||
*/
|
||||
readonly attribute fuelIBookmarkFolder menu;
|
||||
|
||||
/**
|
||||
* The folder for the 'personal toolbar' root.
|
||||
*/
|
||||
readonly attribute fuelIBookmarkFolder toolbar;
|
||||
|
||||
/**
|
||||
* The folder for the 'tags' root.
|
||||
*/
|
||||
readonly attribute fuelIBookmarkFolder tags;
|
||||
|
||||
/**
|
||||
* The folder for the 'unfiled bookmarks' root.
|
||||
*/
|
||||
readonly attribute fuelIBookmarkFolder unfiled;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Interface representing a browser window.
|
||||
*/
|
||||
@ -685,8 +714,9 @@ interface fuelIApplication : nsISupports
|
||||
|
||||
/**
|
||||
* The root bookmarks object for the application.
|
||||
* Contains all the bookmark roots in the system.
|
||||
*/
|
||||
readonly attribute fuelIBookmarkFolder bookmarks;
|
||||
readonly attribute fuelIBookmarkRoots bookmarks;
|
||||
|
||||
/**
|
||||
* An array of browser windows within the application.
|
||||
|
@ -959,9 +959,6 @@ Bookmark.prototype = {
|
||||
// BookmarkFolder implementation
|
||||
function BookmarkFolder(aId, aParent) {
|
||||
this._id = aId;
|
||||
if (this._id == null)
|
||||
this._id = Utilities.bookmarks.bookmarksMenuFolder;
|
||||
|
||||
this._parent = aParent;
|
||||
|
||||
this._annotations = new Annotations(this._id);
|
||||
@ -1121,6 +1118,53 @@ BookmarkFolder.prototype = {
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIBookmarkFolder, Ci.nsINavBookmarkObserver])
|
||||
};
|
||||
|
||||
//=================================================
|
||||
// BookmarkRoots implementation
|
||||
function BookmarkRoots() {
|
||||
var self = this;
|
||||
gShutdown.push(function() { self._shutdown(); });
|
||||
}
|
||||
|
||||
BookmarkRoots.prototype = {
|
||||
_shutdown : function bmr_shutdown() {
|
||||
this._menu = null;
|
||||
this._toolbar = null;
|
||||
this._tags = null;
|
||||
this._unfiled = null;
|
||||
},
|
||||
|
||||
get menu() {
|
||||
if (!this._menu)
|
||||
this._menu = new BookmarkFolder(Utilities.bookmarks.bookmarksMenuFolder, null);
|
||||
|
||||
return this._menu;
|
||||
},
|
||||
|
||||
get toolbar() {
|
||||
if (!this._toolbar)
|
||||
this._toolbar = new BookmarkFolder(Utilities.bookmarks.toolbarFolder, null);
|
||||
|
||||
return this._toolbar;
|
||||
},
|
||||
|
||||
get tags() {
|
||||
if (!this._tags)
|
||||
this._tags = new BookmarkFolder(Utilities.bookmarks.tagsFolder, null);
|
||||
|
||||
return this._tags;
|
||||
},
|
||||
|
||||
get unfiled() {
|
||||
if (!this._unfiled)
|
||||
this._unfiled = new BookmarkFolder(Utilities.bookmarks.unfiledBookmarksFolder, null);
|
||||
|
||||
return this._unfiled;
|
||||
},
|
||||
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.fuelIBookmarkRoots])
|
||||
};
|
||||
|
||||
|
||||
//=================================================
|
||||
// Factory - Treat Application as a singleton
|
||||
// XXX This is required, because we're registered for the 'JavaScript global
|
||||
@ -1285,7 +1329,7 @@ Application.prototype = {
|
||||
|
||||
get bookmarks() {
|
||||
if (this._bookmarks == null)
|
||||
this._bookmarks = new BookmarkFolder(null, null);
|
||||
this._bookmarks = new BookmarkRoots();
|
||||
|
||||
return this._bookmarks;
|
||||
},
|
||||
|
@ -10,7 +10,40 @@ function url(spec) {
|
||||
}
|
||||
|
||||
function test() {
|
||||
var root = Application.bookmarks;
|
||||
// Some very basic tests on the tags root
|
||||
var tags = Application.bookmarks.tags;
|
||||
ok(tags, "Check access to bookmark tags root");
|
||||
ok(!tags.parent, "Check tags parent (should be null)");
|
||||
|
||||
//----------------------------------------------
|
||||
|
||||
// Some very basic tests on the unfiled root
|
||||
var unfiled = Application.bookmarks.unfiled;
|
||||
ok(unfiled, "Check access to bookmark unfiled root");
|
||||
ok(!unfiled.parent, "Check unfiled parent (should be null)");
|
||||
|
||||
//----------------------------------------------
|
||||
|
||||
// Some basic tests on the toolbar root
|
||||
var toolbar = Application.bookmarks.toolbar;
|
||||
ok(toolbar, "Check access to bookmark toolbar root");
|
||||
ok(!toolbar.parent, "Check toolbar parent (should be null)");
|
||||
|
||||
var toolbarKidCount = toolbar.children.length;
|
||||
|
||||
// test adding folders
|
||||
var testFolderToolbar = toolbar.addFolder("FUEL in Toolbar");
|
||||
ok(testFolderToolbar, "Check folder creation");
|
||||
is(testFolderToolbar.type, "folder", "Check 'folder.type' after creation");
|
||||
ok(testFolderToolbar.parent, "Check parent after folder creation");
|
||||
|
||||
toolbarKidCount++;
|
||||
is(toolbar.children.length, toolbarKidCount, "Check toolbar folder child count after adding a child folder");
|
||||
|
||||
//----------------------------------------------
|
||||
|
||||
// Main testing is done on the bookmarks menu root
|
||||
var root = Application.bookmarks.menu;
|
||||
ok(root, "Check access to bookmark root");
|
||||
ok(!root.parent, "Check root parent (should be null)");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user