Bug 1393771 - Fix issues in tests that cause failures when they are re-ordered. r?mak draft
authorMark Banner <standard8@mozilla.com>
Tue, 29 Aug 2017 20:47:21 +0100
changeset 656029 c4d9d78c4c4f9c311cbf00c28f9e491ea481b071
parent 656028 eb80d17c81d9df20354c8741c083656c1f074943
child 728979 c0105187a7247b88f09101ee68e64148e5ef7a7f
push id77032
push userbmo:standard8@mozilla.com
push dateWed, 30 Aug 2017 16:57:54 +0000
reviewersmak
bugs1393771
milestone57.0a1
Bug 1393771 - Fix issues in tests that cause failures when they are re-ordered. r?mak MozReview-Commit-ID: 8PUTruIRPK8
browser/components/places/tests/browser/browser_library_views_liveupdate.js
browser/components/places/tests/browser/browser_toolbar_drop_text.js
--- a/browser/components/places/tests/browser/browser_library_views_liveupdate.js
+++ b/browser/components/places/tests/browser/browser_library_views_liveupdate.js
@@ -60,20 +60,20 @@ function startTest() {
                          PlacesUtils._uri("http://bmf1.mozilla.org/"),
                          bs.DEFAULT_INDEX,
                          "bmf1");
   addedBookmarks.push(id);
   bs.moveItem(id, bs.bookmarksMenuFolder, 0);
 
   // TOOLBAR
   ok(true, "*** Acting on toolbar bookmarks");
-  bs.insertBookmark(bs.toolbarFolder,
-                    PlacesUtils._uri("http://tb1.mozilla.org/"),
-                    bs.DEFAULT_INDEX,
-                    "tb1");
+  id = bs.insertBookmark(bs.toolbarFolder,
+                         PlacesUtils._uri("http://tb1.mozilla.org/"),
+                         bs.DEFAULT_INDEX,
+                         "tb1");
   bs.setItemTitle(id, "tb1_edited");
   addedBookmarks.push(id);
   id = bs.insertBookmark(bs.toolbarFolder,
                          PlacesUtils._uri("place:"),
                          bs.DEFAULT_INDEX,
                          "tb2");
   bs.setItemTitle(id, "tb2_edited");
   addedBookmarks.push(id);
--- a/browser/components/places/tests/browser/browser_toolbar_drop_text.js
+++ b/browser/components/places/tests/browser/browser_toolbar_drop_text.js
@@ -19,32 +19,36 @@ add_task(async function test() {
     });
   }
 
   // Setup the node we will use to be dropped. The actual node used does not
   // matter because we will set its data, effect, and mimeType manually.
   let placesItems = document.getElementById("PlacesToolbarItems");
   ok(placesItems, "PlacesToolbarItems should not be null");
   ok(placesItems.localName == "scrollbox", "PlacesToolbarItems should not be null");
-  ok(placesItems.childNodes[0], "PlacesToolbarItems must have at least one child");
 
   /**
    * Simulates a drop of a URI onto the bookmarks bar.
    *
    * @param aEffect
    *        The effect to use for the drop operation: move, copy, or link.
    * @param aMimeType
    *        The mime type to use for the drop operation.
    */
   let simulateDragDrop = async function(aEffect, aMimeType) {
     const url = "http://www.mozilla.org/D1995729-A152-4e30-8329-469B01F30AA7";
     let promiseItemAddedNotification = promiseBookmarksNotification(
       "onItemAdded", (itemId, parentId, index, type, uri, guid) => uri.spec == url);
 
-    EventUtils.synthesizeDrop(placesItems.childNodes[0],
+    // We use the toolbar as the drag source, as we just need almost any node
+    // to simulate the drag. The actual data for the drop is passed via the
+    // drag data. Note: The toolbar is used rather than another bookmark node,
+    // as we need something that is immovable from a places perspective, as this
+    // forces the move into a copy.
+    EventUtils.synthesizeDrop(toolbar,
                               placesItems,
                               [[{type: aMimeType,
                                 data: url}]],
                               aEffect, window);
 
     await promiseItemAddedNotification;
 
     // Verify that the drop produces exactly one bookmark.
@@ -75,17 +79,18 @@ add_task(async function test() {
     if (aMimeType == "text/x-moz-url")
       data = urls.map(spec => spec + "\n" + spec).join("\n");
     else
       data = urls.join("\n");
 
     let promiseItemAddedNotification = promiseBookmarksNotification(
       "onItemAdded", (itemId, parentId, index, type, uri, guid) => uri.spec == urls[2]);
 
-    EventUtils.synthesizeDrop(placesItems.childNodes[0],
+    // See notes for EventUtils.synthesizeDrop in simulateDragDrop().
+    EventUtils.synthesizeDrop(toolbar,
                               placesItems,
                               [[{type: aMimeType,
                                  data}]],
                               aEffect, window);
 
     await promiseItemAddedNotification;
 
     // Verify that the drop produces exactly one bookmark per each URL.