Bug 1574431 - Preserve installTelemetryInfo when rebuilding the DB from the addons manifest files. r=kmag a=RyanVM
authorLuca Greco <lgreco@mozilla.com>
Thu, 22 Aug 2019 12:22:31 +0000
changeset 545270 6f5952cc02ac49310336350ded9f3941a2a37ebb
parent 545269 99e63b9d80064aa57932b56c5047c7bf504c92f7
child 545271 adf343d5cfe34757c1eb036700f60c2835ce98c9
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, RyanVM
bugs1574431
milestone69.0
Bug 1574431 - Preserve installTelemetryInfo when rebuilding the DB from the addons manifest files. r=kmag a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D42281
toolkit/mozapps/extensions/internal/XPIDatabase.jsm
toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js
--- a/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
@@ -2234,16 +2234,17 @@ this.XPIDatabase = {
     this.removeAddonMetadata(aOldAddon);
     aNewAddon.syncGUID = aOldAddon.syncGUID;
     aNewAddon.installDate = aOldAddon.installDate;
     aNewAddon.applyBackgroundUpdates = aOldAddon.applyBackgroundUpdates;
     aNewAddon.foreignInstall = aOldAddon.foreignInstall;
     aNewAddon.seen = aOldAddon.seen;
     aNewAddon.active =
       aNewAddon.visible && !aNewAddon.disabled && !aNewAddon.pendingUninstall;
+    aNewAddon.installTelemetryInfo = aOldAddon.installTelemetryInfo;
 
     return this.addToDatabase(aNewAddon, aPath);
   },
 
   /**
    * Synchronously removes an add-on from the database.
    *
    * @param {AddonInternal} aAddon
@@ -2941,16 +2942,17 @@ this.XPIDatabaseReconcile = {
         "foreignInstall",
         "visible",
         "active",
         "userDisabled",
         "applyBackgroundUpdates",
         "sourceURI",
         "releaseNotesURI",
         "targetApplications",
+        "installTelemetryInfo",
       ];
 
       let props = PROP_JSON_FIELDS.filter(a => !remove.includes(a));
       copyProperties(manifest, props, aOldAddon);
     }
 
     aOldAddon.appDisabled = !XPIDatabase.isUsableAddon(aOldAddon);
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js
@@ -5,16 +5,21 @@
 const PREF_DB_SCHEMA = "extensions.databaseSchema";
 
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
 
 add_task(async function run_tests() {
+  // Fake installTelemetryInfo used in the addon installation,
+  // to verify that they are preserved after the DB is updated
+  // from the addon manifests.
+  const fakeInstallTelemetryInfo = { source: "amo", method: "amWebAPI" };
+
   const ID = "schema-change@tests.mozilla.org";
 
   const xpi1 = createTempWebExtensionFile({
     manifest: {
       name: "Test Add-on",
       version: "1.0",
       applications: { gecko: { id: ID } },
     },
@@ -72,21 +77,26 @@ add_task(async function run_tests() {
       },
     },
   ];
 
   await promiseStartupManager();
 
   for (let test of TESTS) {
     info(test.what);
-    await promiseInstallFile(xpi1);
+    await promiseInstallFile(xpi1, false, fakeInstallTelemetryInfo);
 
     let addon = await promiseAddonByID(ID);
     notEqual(addon, null, "Got an addon object as expected");
     equal(addon.version, "1.0", "Got the expected version");
+    Assert.deepEqual(
+      addon.installTelemetryInfo,
+      fakeInstallTelemetryInfo,
+      "Got the expected installTelemetryInfo after installing the addon"
+    );
 
     await promiseShutdownManager();
 
     let orig = await OS.File.stat(xpiPath);
 
     xpi2.copyTo(profileDir, `${ID}.xpi`);
 
     // Make sure the timestamp is unchanged, so it is not re-scanned for that reason.
@@ -98,12 +108,17 @@ add_task(async function run_tests() {
 
     await test.action();
 
     await promiseStartupManager();
 
     addon = await promiseAddonByID(ID);
     notEqual(addon, null, "Got an addon object as expected");
     equal(addon.version, test.expectedVersion, "Got the expected version");
+    Assert.deepEqual(
+      addon.installTelemetryInfo,
+      fakeInstallTelemetryInfo,
+      "Got the expected installTelemetryInfo after rebuilding the DB"
+    );
 
     await addon.uninstall();
   }
 });