Bug 1347530 - Part 1: Add a unit test for 360se bookmark imports. r?Gijs
MozReview-Commit-ID: 6DZVjePu3yS
new file mode 100644
--- /dev/null
+++ b/browser/components/migration/tests/unit/AppData/Roaming/360se6/apps/data/users/0f3ab103a522f4463ecacc36d34eb996/360sefav.db
@@ -0,0 +1,1 @@
+Placeholder file to satisfy the resource existence check, not a real SQLite db.
new file mode 100644
index 0000000000000000000000000000000000000000..1835c33583b3f1c3ce21302e9cdccf30175d1733
GIT binary patch
literal 6144
zc%1E6Z%i9y7=Pcs*D|UoSxgX#@yJ5fO8*@NHvP1Yb%e=agJMQ1sYiPqmt9-dJ3ta+
zgaKn?4v34}0JDipK*_MUxilN|Pl8{z81YYxAB-Oi*J~3qH6bxs{NVfEwNM~N<CmG)
zU)txn_j%su_dM^PdwbXB!}Ywx(ZNVG#7eXiPyj-(ho%7l+rdU4{DoO<2>u}o&>uh#
z4*=vsU%*v3jV~WUyr?%6l^4SvJ{;g)>13l^Sn}}!pW2k#eL=R{P}AggdE9he!#?*B
zdQ%s=v4PgQnbthCtGUK}h{C+(uvKE)1x`FJ;N|j(-0?0h?BCqfrxSQwd+XiwCZ{RP
zhBymunfni*yrSY_I1o`ewXB+?HZXWKV;gPq@_{y7x5r)UZlVu0)g5#-wbC!RTWME|
zr?IX9M;&xGcr4zv(%Wc0EYSfj$aV=5?XY-x(HD#e0WR7`OMJMOc>Num|Cnjbfg@;>
z!@`)&7O%uh0@p@&vr&Hs8#Pr_RbyjUR9H7Lj*3cb>x_t7Qu(7Ciw7?8AxzQEAH{Bq
zS71fS7m5V<VDARcrW)HhQChDs%NONDF51m)9+<f=ALbR6l)yedGnpY?^rw|>%XAVe
zna^Wf@A_D(E6v%HYVmfnLRZ%CnTp-!zpiDUd%vrt-h*qg>I_A$5(v}{m0o_fONyv%
zUpl*wNneornJT~np#^~Mq0h0(A%`6P%h-;nvd3YdUA?h=LWB)4V5g3<GQ_4Ha$;{-
zJ>eK9Q^{0RIh@Yj6&1T27@!bRrD||D7Zv$Pm;pvW?*F?0-9<m3-yZbfa>yZve~Cg=
zw&7erPax}-LqYc#D$P0oAo=|_f}a8U7LB1=RIFRl1>qv>g$y=6WT-Jdg5Pc!J2V*Z
zOAc^WJLLIO^5AUZqtWEduzYd0Ly|h5x7$U|hJ7}F*bd>>Ki-es35*f_8Q<_S0Q>U^
zNtsI}p@4kyihMFA4^6Jz97%_VxgOER2f6T3n?Dk=hj_tmAn_A{9m^RFfNPt|vn$P`
z+#XL{cr(>Mugou`dAJbE3pS?OsnY04==mERzh*Q5eLM3W#T<R2Gfk2hn^H!`k~2f8
z>2d2y{Hi>8J2gEd4-P961In#Md2Cqo;bh9(MN8u9yUMBI)ZB$cd{A@9Q?ts=Pm(kJ
z%G8KOK6^<Xp41#G@zX1dmo0d*aI9t`$*xbQYn8ffVx*%>t&}1ap393bXEXpW8OUH;
zpUX_zmG_i0b5e*E1QKDjDq};56W5e;mlD@+;Z&NRP>Yzmr>DoZ*4K^*>%i%!U(aX&
zn)QVJusy^6@x1)Tgf%rWnmB(0OL;0LkB%#6V~Mw7sSl^t7pjNj+aoHej*z{^p8y#R
zfQ3@mr$E~*P>#oybF<pSsl8u)=b6Hc2A~#^-c{N{K(e*8>G@^xOmk!E?aRs7LiTXP
zthA*q-#aoIfW10GRGvko?NRxI#pLk&8IBG%vSEup_4|%J84bX*kZ_c0rBe`hq?O6I
zJa|p*`{a?YVnl!Q<-(`<-5d`UqE&!DIpmPT{{TjailO$`j*&e78_^O#NwkDk(LHn@
x{e<5HzC+9C&V#Nqha7VFd*~5<QZN!p<*Ra=D)UrnP^Dh&LlFs)Ds`$I{s}{pjCTM4
new file mode 100644
--- /dev/null
+++ b/browser/components/migration/tests/unit/AppData/Roaming/360se6/apps/data/users/login.ini
@@ -0,0 +1,17 @@
+# This file contains Chinese characters encoded in GBK
+[NowLogin]
+NickName=ıÖÇ»ðºü
+email=test@firefox.com.cn
+UserMd5=0f3ab103a522f4463ecacc36d34eb996
+IsLogined=1
+# Will be excluded from sourceProfiles due to missing files
+[20070606]
+NickName=ıÖÇÍøÂç
+email=test@mozillaonline.com
+UserMd5=46a579b8b64358fd45616247df4ea604
+# Will be excluded from sourceProfiles as duplication of NowLogin
+[20110303]
+NickName=ıÖÇ»ðºü
+email=test@firefox.com.cn
+UserMd5=0f3ab103a522f4463ecacc36d34eb996
+# There's also a default profile (not included here) for anonymous users
new file mode 100644
--- /dev/null
+++ b/browser/components/migration/tests/unit/test_360se_bookmarks.js
@@ -0,0 +1,58 @@
+"use strict";
+
+add_task(async function() {
+ registerFakePath("AppData", do_get_file("AppData/Roaming/"));
+
+ let migrator = MigrationUtils.getMigrator("360se");
+ // Sanity check for the source.
+ Assert.ok(migrator.sourceExists);
+
+ let profiles = migrator.sourceProfiles;
+ Assert.equal(profiles.length, 2, "Should present two profiles");
+ Assert.equal(profiles[0].name, "test@firefox.com.cn", "Current logged in user should be the first");
+ Assert.equal(profiles[profiles.length - 1].name, "Default", "Default user should be the last");
+
+ // Wait for the imported bookmarks. Check that "From 360 Secure Browser"
+ // folders are created on the toolbar.
+ let source = MigrationUtils.getLocalizedString("sourceName360se");
+ 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 == "360 \u76f8\u5173") {
+ 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() {},
+ onItemRemoved() {},
+ onItemChanged() {},
+ onItemVisited() {},
+ onItemMoved() {},
+ };
+ PlacesUtils.bookmarks.addObserver(bmObserver);
+
+ await promiseMigration(migrator, MigrationUtils.resourceTypes.BOOKMARKS, {
+ id: "default"
+ });
+ 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, 10, "Should import all 10 items.");
+ // Check that the telemetry matches:
+ Assert.equal(MigrationUtils._importQuantities.bookmarks, itemCount, "Telemetry reporting correct.");
+});
--- a/browser/components/migration/tests/unit/xpcshell.ini
+++ b/browser/components/migration/tests/unit/xpcshell.ini
@@ -1,24 +1,26 @@
[DEFAULT]
head = head_migration.js
firefox-appdir = browser
skip-if = toolkit == 'android'
support-files =
Library/**
AppData/**
+[test_360se_bookmarks.js]
+skip-if = os != "win"
[test_automigration.js]
[test_Chrome_bookmarks.js]
[test_Chrome_cookies.js]
skip-if = os != "mac" # Relies on ULibDir
[test_Chrome_passwords.js]
skip-if = os != "win"
[test_Edge_db_migration.js]
-skip-if = os != "win" || os_version == "5.1" || os_version == "5.2" # Relies on post-XP bits of ESEDB
+skip-if = os != "win"
[test_fx_telemetry.js]
[test_IE_bookmarks.js]
skip-if = os != "win"
[test_IE_cookies.js]
skip-if = os != "win"
[test_IE7_passwords.js]
skip-if = os != "win"
[test_Safari_bookmarks.js]