Bug 1314179 - Ensure `PlacesSyncUtils.bookmarks.remove` passes the correct source to observers. r=markh draft
authorKit Cambridge <kit@yakshaving.ninja>
Mon, 31 Oct 2016 16:44:56 -0700
changeset 432475 8e170b62da3b36c4d0fcf91b0aaf5cae56c45296
parent 431998 e9817b656d69c8382f39549bfc1a7ed27e7188e4
child 535662 a38736ca4bc25e86af09916f65ada83976c3eb7a
push id34324
push userbmo:kcambridge@mozilla.com
push dateWed, 02 Nov 2016 04:46:21 +0000
reviewersmarkh
bugs1314179
milestone52.0a1
Bug 1314179 - Ensure `PlacesSyncUtils.bookmarks.remove` passes the correct source to observers. r=markh MozReview-Commit-ID: 8uuwh1DTlo2
browser/components/places/tests/unit/head_bookmarks.js
toolkit/components/places/Bookmarks.jsm
--- a/browser/components/places/tests/unit/head_bookmarks.js
+++ b/browser/components/places/tests/unit/head_bookmarks.js
@@ -73,16 +73,20 @@ var createCorruptDB = Task.async(functio
  * exception generated.
  *
  * @return {Promise}
  *         Resolved when done.
  */
 function rebuildSmartBookmarks() {
   let consoleListener = {
     observe(aMsg) {
+      if (aMsg.message.startsWith("[JavaScript Warning:")) {
+        // TODO (Bug 1300416): Ignore spurious strict warnings.
+        return;
+      }
       do_throw("Got console message: " + aMsg.message);
     },
     QueryInterface: XPCOMUtils.generateQI([ Ci.nsIConsoleListener ]),
   };
   Services.console.reset();
   Services.console.registerListener(consoleListener);
   do_register_cleanup(() => {
     try {
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -422,31 +422,32 @@ var Bookmarks = Object.freeze({
     return Task.spawn(function* () {
       let item = yield fetchBookmark(removeInfo);
       if (!item)
         throw new Error("No bookmarks found for the provided GUID.");
 
       item = yield removeBookmark(item, options);
 
       // Notify onItemRemoved to listeners.
+      let { source = Bookmarks.SOURCES.DEFAULT } = options;
       let observers = PlacesUtils.bookmarks.getObservers();
       let uri = item.hasOwnProperty("url") ? PlacesUtils.toURI(item.url) : null;
       notify(observers, "onItemRemoved", [ item._id, item._parentId, item.index,
                                            item.type, uri, item.guid,
                                            item.parentGuid,
-                                           removeInfo.source ]);
+                                           source ]);
 
       let isUntagging = item._grandParentId == PlacesUtils.tagsFolderId;
       if (isUntagging) {
         for (let entry of (yield fetchBookmarksByURL(item))) {
           notify(observers, "onItemChanged", [ entry._id, "tags", false, "",
                                                PlacesUtils.toPRTime(entry.lastModified),
                                                entry.type, entry._parentId,
                                                entry.guid, entry.parentGuid,
-                                               "", removeInfo.source ]);
+                                               "", source ]);
         }
       }
 
       // Remove non-enumerable properties.
       return Object.assign({}, item);
     });
   },