Bug 561496 - Desktop Bookmarks synced with Weave Can Not be opened on Fennec [r=vingtetun]
authorMark Finkle <mfinkle@mozilla.com>
Tue, 27 Apr 2010 01:10:52 -0400
changeset 66173 c2fbf2fedc02a46469fc41d9017b54509a2c21b3
parent 66172 69eb47a9120e8a85429a965633200a5c4c958a2d
child 66174 3086ac7a025589488b374755ebedab4ce97fb34f
push id19389
push userffxbld
push dateWed, 06 Apr 2011 21:33:21 +0000
treeherdermozilla-central@8e9f90073a20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs561496
Bug 561496 - Desktop Bookmarks synced with Weave Can Not be opened on Fennec [r=vingtetun]
mobile/chrome/content/bindings.xml
mobile/chrome/tests/browser_bookmarks.js
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -725,16 +725,25 @@
           { 
             itemId: PlacesUtils.toolbarFolderId, tags: "", uri: "",
             title: PlacesUtils.bookmarks.getItemTitle(PlacesUtils.toolbarFolderId),
             type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER
           }
         ];
       ]]></field>
 
+      <field name="_readOnlyFolders"><![CDATA[
+        [
+          this._desktopFolderId,
+          PlacesUtils.bookmarks.unfiledBookmarksFolder,
+          PlacesUtils.bookmarksMenuFolderId,
+          PlacesUtils.toolbarFolderId
+        ];
+      ]]></field>
+
       <field name="_type"/>
       <field name="_mode"/>
       <field name="_activeItem">null</field>
       <field name="_ignoreEditing">false</field>
       <field name="_manageUI">false</field>
       <field name="_parents">
         document.getAnonymousElementByAttribute(this, "anonid", "parent-items");
       </field>
@@ -748,17 +757,17 @@
 
       <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");
+            let currentFolderId = this._parents.lastChild.itemId;
             return currentFolderId == this.mobileRoot;
           ]]>
         </getter>
       </property>
 
       <property name="activeItem">
         <getter>
           <![CDATA[
@@ -834,17 +843,17 @@
 
       <method name="_getFirstVisibleChild">
         <body>
           <![CDATA[
             let children = this._children.childNodes;
             for (let i = 0; i < children.length; i++) {
               let rect = children[i].getBoundingClientRect();
               let position = rect.top - rect.height;
-              if (position > 0 && children[i].getAttribute("itemid") != this._desktopFolderId)
+              if (position > 0 && this._readOnlyFolders.indexOf(parseInt(children[i].itemId)) == -1)
                 return children[i];
             }
             return null;
           ]]>
         </body>
       </method>
 
       <method name="_getChildren">
@@ -971,20 +980,20 @@
       </method>
 
       <method name="_fireOpen">
         <parameter name="aEvent"/>
         <parameter name="aItem"/>
         <body>
           <![CDATA[
             let target = aEvent.originalTarget;
-            if (target.localName == "button" || this._activeItem == aItem || this._desktopFolderId == aItem.getAttribute("itemid"))
+            if (target.localName == "button" || this._activeItem == aItem)
               return;
 
-            if (this._manageUI) {
+            if (this._manageUI && this._readOnlyFolders.indexOf(parseInt(aItem.itemId)) == -1) {
               aItem.startEditing();
               return;
             }
 
             if (aItem.type == "folder") {
               this.openFolder(aItem.itemId);
             }
             else {
--- a/mobile/chrome/tests/browser_bookmarks.js
+++ b/mobile/chrome/tests/browser_bookmarks.js
@@ -231,8 +231,61 @@ gTests.push({
     bookmark = PlacesUtils.getMostRecentBookmarkForURI(makeURI(testURL_01));
     ok(bookmark == -1, testURL_01 + " should no longer in bookmark");
 
     BookmarkList.close();
 
     runNextTest();
   }
 });
+
+//------------------------------------------------------------------------------
+// Case: Test editing title of desktop folder
+gTests.push({
+  desc: "Test editing title of desktop folder",
+  bmId: null,
+  
+  run: function() {
+    // Add a bookmark to the desktop area so the desktop folder is displayed
+    gCurrentTest.bmId = PlacesUtils.bookmarks
+                                   .insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
+                                                   makeURI(testURL_02),
+                                                   Ci.nsINavBookmarksService.DEFAULT_INDEX,
+                                                   testURL_02);
+
+    // Open the bookmark list
+    BookmarkList.show();
+
+    // Go into edit mode
+    BookmarkList.toggleManage();
+
+    waitFor(gCurrentTest.onBookmarksReady, function() { return document.getElementById("bookmark-items").manageUI == true; });
+  },
+  
+  onBookmarksReady: function() {
+    // Is the "desktop" folder showing?
+    var first = BookmarkList._bookmarks._children.firstChild;
+    is(first.itemId, BookmarkList._bookmarks._desktopFolderId, "Desktop folder is showing");
+
+    // Is the "desktop" folder in edit mode?
+    is(first.isEditing, false, "Desktop folder is not in edit mode");
+
+
+    // Do not allow the "desktop" folder to be editable by tap
+    EventUtils.synthesizeMouse(first, first.clientWidth / 2, first.clientHeight / 2, {});
+
+    // A tap on the "desktop" folder _should_ open the folder, not put it into edit mode.
+    // So we need to get the first item again.
+    first = BookmarkList._bookmarks._children.firstChild;
+
+    // It should not be the "desktop" folder
+    isnot(first.itemId, BookmarkList._bookmarks._desktopFolderId, "Desktop folder is not showing after mouse click");
+
+    // But it should be one of the other readonly bookmark roots
+    isnot(BookmarkList._bookmarks._readOnlyFolders.indexOf(parseInt(first.itemId)), -1, "Desktop subfolder is showing after mouse click");
+    
+    BookmarkList.close();
+
+    PlacesUtils.bookmarks.removeItem(gCurrentTest.bmId);
+
+    runNextTest();
+  }
+});