Bug 1393771 - Fix issues in tests that cause failures when they are re-ordered. r=mak
authorMark Banner <standard8@mozilla.com>
Tue, 29 Aug 2017 20:47:21 +0100
changeset 377821 8e979942519c5e0900beb1c8d4af5573e80e7aca
parent 377820 8516c3269916bb4684002167622fd713cd603e5e
child 377822 043653ff777987f0b881fcefe15610b796e1e3a0
push id94338
push userkwierso@gmail.com
push dateThu, 31 Aug 2017 02:58:58 +0000
treeherdermozilla-inbound@9ca18987dabb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1393771
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.