Bug 1353041 - Fix Safari import of folders. r=mossop, a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 03 Apr 2017 17:46:47 +0100
changeset 379423 168d76e8a965a90b966679db03a86e677af87cdc
parent 379422 62e7b123b0e1a6bc970d8506e778cd47dc2f5cff
child 379424 f54174f7f00565276d6ec1848481b125622be063
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, lizzard
bugs1353041
milestone53.0
Bug 1353041 - Fix Safari import of folders. r=mossop, a=lizzard MozReview-Commit-ID: Jw0lmIi5aZK
browser/components/migration/SafariProfileMigrator.js
browser/components/migration/tests/unit/Library/Safari/Bookmarks.plist
browser/components/migration/tests/unit/test_Safari_bookmarks.js
--- a/browser/components/migration/SafariProfileMigrator.js
+++ b/browser/components/migration/SafariProfileMigrator.js
@@ -174,17 +174,17 @@ Bookmarks.prototype = {
           return null;
         }
         let title;
         if (entry.has("URIDictionary"))
           title = entry.get("URIDictionary").get("title");
         return { url, title };
       }
       return null;
-    }).filter(e => !!e);
+    }, this).filter(e => !!e);
   },
 };
 
 function History(aHistoryFile) {
   this._file = aHistoryFile;
 }
 History.prototype = {
   type: MigrationUtils.resourceTypes.HISTORY,
index 40783c7b150109eed37a7f4a6a007488caa8577e..8046d5e9c984ed9f908d748d813a383b0d3c00ab
GIT binary patch
literal 1956
zc${sNON<m%6o%_9C`ijwdQb?@h}@wbx2kS|i1*g53xhK_!t^|NwKd%}Gv)MjH$63s
zvokT#g$C64TDUNZ!3Bw1S4P9i1Q!!P<I2Q@#E@W&Zj5d`J=H@RLM^&;Pi}qZod5i%
z#+$WtHZ#pzvZ89b@kn-Xu3T6%l8m!PV|pfTO_xf2d^DU&Yt>d#FAb$xExG@~&_WX;
z8@nPRttG=rYc_4v%Y~gZ;x=WbhdiHhgt;qFKtqZ`CyYcyO*`V|<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4
z40Pe#a=I3AS@I;#rtTG91wRc<CEG^w=(aHTV4i4VGA+K^mdCPeXoaH)yWk=}^kEF1
z1?$9w<65pOLfj?K@>(XfW+%(^&=?$Y=uEv?Jm0paNnH|Pf*jw2Z>9;F2iz90`^<N3
z>W9J&a%fK%6h4j3xOyR-Z7g@tIz0q2n#W2fv$=_h!GbKUkk(1Nq+SV2LMlsdN^eUa
zNLQsB(jDn9>0eou_sXVxP#%;|$y4$r`F;6{{FVHj{FD5P{HuIh{!`hc6qO#uRfuv}
zIi{RfGG$J=sJy3qtbDHgpj=meRBkK3D|eND)UE1vb%%ONJ*!sL^XgmbMfFqlntEOR
zTm4TnG^ClDr449<+9@s3-q9{;?`l`IueEQqYuX*{uJ(tn>nrqv-lH=;(uF>*Cwg69
z&_C0^&@b!X>fh@>>%SQ*ja9~KW2dpl*k}00IU_d4jn|Dgj7!Fc#z)f9qsaNcbV0iB
HF+TYpz7-w`
--- a/browser/components/migration/tests/unit/test_Safari_bookmarks.js
+++ b/browser/components/migration/tests/unit/test_Safari_bookmarks.js
@@ -10,21 +10,25 @@ add_task(function* () {
   // Wait for the imported bookmarks.  Check that "From Safari"
   // folders are created on the toolbar.
   let source = MigrationUtils.getLocalizedString("sourceNameSafari");
   let label = MigrationUtils.getLocalizedString("importedBookmarksFolder", [source]);
 
   let expectedParents = [ PlacesUtils.toolbarFolderId ];
   let itemCount = 0;
 
+  let gotFolder = false;
   let bmObserver = {
     onItemAdded(aItemId, aParentId, aIndex, aItemType, aURI, aTitle) {
       if (aTitle != label) {
         itemCount++;
       }
+      if (aItemType == PlacesUtils.bookmarks.TYPE_FOLDER && aTitle == "Stuff") {
+        gotFolder = true;
+      }
       if (expectedParents.length > 0 && aTitle == label) {
         let index = expectedParents.indexOf(aParentId);
         Assert.ok(index != -1, "Found expected parent");
         expectedParents.splice(index, 1);
       }
     },
     onBeginUpdateBatch() {},
     onEndUpdateBatch() {},
@@ -35,12 +39,13 @@ add_task(function* () {
   };
   PlacesUtils.bookmarks.addObserver(bmObserver, false);
 
   yield promiseMigration(migrator, MigrationUtils.resourceTypes.BOOKMARKS);
   PlacesUtils.bookmarks.removeObserver(bmObserver);
 
   // Check the bookmarks have been imported to all the expected parents.
   Assert.ok(!expectedParents.length, "No more expected parents");
+  Assert.ok(gotFolder, "Should have seen the folder get imported");
   Assert.equal(itemCount, 13, "Should import all 13 items.");
   // Check that the telemetry matches:
   Assert.equal(MigrationUtils._importQuantities.bookmarks, itemCount, "Telemetry reporting correct.");
 });