зеркало из https://github.com/mozilla/pjs.git
Bug 525184: put mobile bookmarks in a virtual "Mobile" bookmarks root, r=mfinkle
This commit is contained in:
Родитель
6f1d00fd6a
Коммит
3112bdc3a5
|
@ -672,11 +672,15 @@
|
|||
|
||||
<property name="items" readonly="true" onget="return this._children.childNodes"/>
|
||||
|
||||
<field name="mobileRoot"><![CDATA[
|
||||
PlacesUtils.annotations.getItemsWithAnnotation("mobile/bookmarksRoot", {})[0];
|
||||
]]></field>
|
||||
|
||||
<property name="isRootFolder" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
let currentFolderId = this._parents.lastChild.getAttribute("itemid");
|
||||
return currentFolderId == PlacesUtils.bookmarks.unfiledBookmarksFolder;
|
||||
return currentFolderId == this.mobileRoot;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
@ -765,7 +769,7 @@
|
|||
<parameter name="aRootFolder"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
aRootFolder = aRootFolder || PlacesUtils.bookmarks.unfiledBookmarksFolder;
|
||||
aRootFolder = aRootFolder || this.mobileRoot;
|
||||
|
||||
this._activeItem = null;
|
||||
|
||||
|
|
|
@ -721,7 +721,10 @@ var BrowserUI = {
|
|||
let autoClose = false;
|
||||
|
||||
if (PlacesUtils.getMostRecentBookmarkForURI(bookmarkURI) == -1) {
|
||||
var bookmarkId = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.unfiledBookmarksFolder, bookmarkURI, PlacesUtils.bookmarks.DEFAULT_INDEX, bookmarkTitle);
|
||||
let bmsvc = PlacesUtils.bookmarks;
|
||||
let bookmarkId = bmsvc.insertBookmark(BookmarkList.mobileRoot, bookmarkURI,
|
||||
bmsvc.DEFAULT_INDEX,
|
||||
bookmarkTitle);
|
||||
this.updateStar();
|
||||
|
||||
// autoclose the bookmark popup
|
||||
|
@ -930,6 +933,11 @@ var BookmarkList = {
|
|||
_bookmarks: null,
|
||||
_manageButtton: null,
|
||||
|
||||
get mobileRoot() {
|
||||
delete this.mobileRoot;
|
||||
return this.mobileRoot = PlacesUtils.annotations.getItemsWithAnnotation("mobile/bookmarksRoot", {})[0];
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this._panel = document.getElementById("bookmarklist-container");
|
||||
this._panel.width = window.innerWidth;
|
||||
|
|
|
@ -35,7 +35,7 @@ function runNextTest() {
|
|||
else {
|
||||
// Cleanup. All tests are completed at this point
|
||||
try {
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(BookmarkList.mobileRoot);
|
||||
}
|
||||
finally {
|
||||
// We must finialize the tests
|
||||
|
|
|
@ -66,7 +66,7 @@ function runNextTest() {
|
|||
}
|
||||
else {
|
||||
// Cleanup. All tests are completed at this point
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(BookmarkList.mobileRoot);
|
||||
ok(true, "*** ALL TESTS COMPLETED ***");
|
||||
}
|
||||
}
|
||||
|
@ -187,16 +187,18 @@ gTests.push({
|
|||
|
||||
verify: function() {
|
||||
|
||||
// the test bookmarks a page, then creates a folder, and then moves the bookmark into the folder
|
||||
// creates a folder, and then moves the bookmark into the folder
|
||||
|
||||
chromeWindow.BrowserUI.doCommand("cmd_star");
|
||||
|
||||
chromeWindow.BrowserUI.showBookmarks();
|
||||
chromeWindow.BookmarkList.toggleManage();
|
||||
|
||||
// Create new folder
|
||||
var bookmarkitems = chromeWindow.document.getElementById("bookmark-items");
|
||||
var newfolderbutton = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitems, "class", "bookmark-folder-new");
|
||||
EventUtils.synthesizeMouse(newfolderbutton, newfolderbutton.clientWidth / 2, newfolderbutton.clientHeight / 2, {});
|
||||
|
||||
var folderitem = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitems, "title", "New folder");
|
||||
var nametextbox = chromeWindow.document.getAnonymousElementByAttribute(folderitem, "anonid", "name");
|
||||
nametextbox.value = "Test Folder 1";
|
||||
|
@ -204,6 +206,9 @@ gTests.push({
|
|||
donebutton.click();
|
||||
|
||||
var bookmarkitemid = PlacesUtils.getMostRecentBookmarkForURI(uri(testURL_02));
|
||||
is(PlacesUtils.bookmarks.getFolderIdForItem(bookmarkitemid), BookmarkList.mobileRoot, "bookmark starts off in root");
|
||||
|
||||
// Move bookmark
|
||||
var bookmarkitem = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitems, "itemid", bookmarkitemid);
|
||||
var movebutton = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitem, "anonid", "folder-button");
|
||||
movebutton.click();
|
||||
|
@ -212,8 +217,7 @@ gTests.push({
|
|||
var destfolder = chromeWindow.document.getAnonymousElementByAttribute(folderitems, "itemid", folderitem.itemId);
|
||||
EventUtils.synthesizeMouse(destfolder, destfolder.clientWidth / 2, destfolder.clientHeight / 2, {});
|
||||
|
||||
isnot(PlacesUtils.bookmarks.getFolderIdForItem(bookmarkitemid), PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
"Bookmark is no longer in Bookmarks Menu top level folder");
|
||||
// Check that it moved
|
||||
is(PlacesUtils.bookmarks.getFolderIdForItem(bookmarkitemid), folderitem.itemId, "Bookmark is moved to a folder");
|
||||
|
||||
chromeWindow.BookmarkList.close();
|
||||
|
@ -239,6 +243,7 @@ gTests.push({
|
|||
chromeWindow.BookmarkList.toggleManage();
|
||||
var bookmarkitems = chromeWindow.document.getElementById("bookmark-items");
|
||||
|
||||
// Create the new folder
|
||||
var newfolderbutton = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitems, "class", "bookmark-folder-new");
|
||||
EventUtils.synthesizeMouse(newfolderbutton, newfolderbutton.clientWidth / 2, newfolderbutton.clientHeight / 2, {});
|
||||
var folderitem2 = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitems, "title", "New folder");
|
||||
|
@ -247,8 +252,12 @@ gTests.push({
|
|||
var donebutton = chromeWindow.document.getAnonymousElementByAttribute(folderitem2, "anonid", "done-button");
|
||||
donebutton.click();
|
||||
|
||||
// Check the old folder
|
||||
var folderitem1 = chromeWindow.document.getAnonymousElementByAttribute(bookmarkitems, "title", "Test Folder 1");
|
||||
var foldetitem1id = folderitem1.itemId;
|
||||
var folderitem1id = folderitem1.itemId;
|
||||
is(foldetitem1id, BookmarksList.mobileRoot, "folder starts off in the root");
|
||||
|
||||
// Move new folder into old folder
|
||||
var movebutton = chromeWindow.document.getAnonymousElementByAttribute(folderitem1, "anonid", "folder-button");
|
||||
movebutton.click();
|
||||
|
||||
|
@ -256,9 +265,7 @@ gTests.push({
|
|||
var destfolder = chromeWindow.document.getAnonymousElementByAttribute(folderitems, "itemid", folderitem2.itemId);
|
||||
EventUtils.synthesizeMouse(destfolder, destfolder.clientWidth / 2, destfolder.clientHeight / 2, {});
|
||||
|
||||
isnot(PlacesUtils.bookmarks.getFolderIdForItem(foldetitem1id), PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
"Folder created in previous test is no longer in Bookmarks Menu top level folder");
|
||||
is(PlacesUtils.bookmarks.getFolderIdForItem(foldetitem1id), folderitem2.itemId, "Folder is moved to another folder");
|
||||
is(PlacesUtils.bookmarks.getFolderIdForItem(folderitem1id), folderitem2.itemId, "Folder is moved to another folder");
|
||||
|
||||
chromeWindow.BookmarkList.close();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ function runNextTest() {
|
|||
else {
|
||||
// Cleanup. All tests are completed at this point
|
||||
try {
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(BookmarkList.mobileRoot);
|
||||
}
|
||||
finally {
|
||||
// We must finialize the tests
|
||||
|
|
|
@ -35,7 +35,7 @@ function runNextTest() {
|
|||
else {
|
||||
// Cleanup. All tests are completed at this point
|
||||
try {
|
||||
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.bookmarks.unfiledBookmarksFolder);
|
||||
PlacesUtils.bookmarks.removeFolderChildren(BookmarkList.mobileRoot);
|
||||
}
|
||||
finally {
|
||||
// We must finialize the tests
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#filter substitution
|
||||
{"type":"text/x-moz-place-container","root":"placesRoot","children":
|
||||
[{"type":"text/x-moz-place-container","root":"unfiledBookmarksFolder","children":
|
||||
[{"title":"@bookmarks_title@","type":"text/x-moz-place-container","children":
|
||||
[{"type":"text/x-moz-place-container","title":"@bookmarks_title@","annos":[{"name":"mobile/bookmarksRoot","expires":4,"type":1,"value":1}],
|
||||
"children":
|
||||
[
|
||||
{ "title":"@bookmarks_welcome@", "type":"text/x-moz-place", "uri":"about:firstrun",
|
||||
"iconUri":"chrome://branding/content/favicon32.png"
|
||||
|
@ -20,5 +20,4 @@
|
|||
}
|
||||
]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче