Bug 1313648 - Add previousVersion to onInstalled details r=aswan
authorTomislav Jovanovic <tomica@gmail.com>
Mon, 13 Mar 2017 05:55:52 +0100
changeset 347463 93534be9656ef3e83122f4be334c3a3e8e199981
parent 347462 ce635599e0c1bf2197e6212dd9e0eb19e5d34470
child 347464 4bcf6f4ded6411df5fa166933f49e049d9ea23e0
push id31496
push usercbook@mozilla.com
push dateTue, 14 Mar 2017 13:21:57 +0000
treeherdermozilla-central@9a26ed658fdc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1313648
milestone55.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 1313648 - Add previousVersion to onInstalled details r=aswan MozReview-Commit-ID: Cmw7zp8CV7e
toolkit/components/extensions/ext-runtime.js
toolkit/components/extensions/schemas/runtime.json
toolkit/components/extensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js
--- a/toolkit/components/extensions/ext-runtime.js
+++ b/toolkit/components/extensions/ext-runtime.js
@@ -44,17 +44,17 @@ extensions.registerSchemaAPI("runtime", 
               if (Extension.browserUpdated) {
                 fire.sync({reason: "browser_update"});
               }
               break;
             case "ADDON_INSTALL":
               fire.sync({reason: "install"});
               break;
             case "ADDON_UPGRADE":
-              fire.sync({reason: "update"});
+              fire.sync({reason: "update", previousVersion: extension.addonData.oldVersion});
               break;
           }
         };
         extension.on("startup", listener);
         return () => {
           extension.off("startup", listener);
         };
       }).api(),
--- a/toolkit/components/extensions/schemas/runtime.json
+++ b/toolkit/components/extensions/schemas/runtime.json
@@ -468,17 +468,16 @@
             "properties": {
               "reason": {
                 "$ref": "OnInstalledReason",
                 "description": "The reason that this event is being dispatched."
               },
               "previousVersion": {
                 "type": "string",
                 "optional": true,
-                "unsupported": true,
                 "description": "Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'."
               },
               "id": {
                 "type": "string",
                 "optional": true,
                 "unsupported": true,
                 "description": "Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'."
               }
--- a/toolkit/components/extensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_runtime_onInstalled_and_onStartup.js
@@ -52,21 +52,24 @@ function background() {
   });
 
   browser.runtime.onUpdateAvailable.addListener(details => {
     browser.test.sendMessage("reloading");
     browser.runtime.reload();
   });
 }
 
-function* expectEvents(extension, {onStartupFired, onInstalledFired, onInstalledReason}) {
+function* expectEvents(extension, {onStartupFired, onInstalledFired, onInstalledReason, onInstalledPrevious}) {
   extension.sendMessage("get-on-installed-details");
   let details = yield extension.awaitMessage("on-installed-details");
   if (onInstalledFired) {
     equal(details.reason, onInstalledReason, "runtime.onInstalled fired with the correct reason");
+    if (onInstalledPrevious) {
+      equal(details.previousVersion, onInstalledPrevious, "runtime.onInstalled after update with correct previousVersion");
+    }
   } else {
     equal(details.fired, onInstalledFired, "runtime.onInstalled should not have fired");
   }
 
   extension.sendMessage("did-on-startup-fire");
   let fired = yield extension.awaitMessage("on-startup-fired");
   equal(fired, onStartupFired, `Expected runtime.onStartup to ${onStartupFired ? "" : "not "} fire`);
 }
@@ -152,16 +155,17 @@ add_task(function* test_should_fire_on_a
   equal(updated_addon.version, "2.0", "The updated addon has the correct version");
 
   yield extension.awaitStartup();
 
   yield expectEvents(extension, {
     onStartupFired: false,
     onInstalledFired: true,
     onInstalledReason: "update",
+    onInstalledPrevious: "1.0",
   });
 
   yield extension.unload();
 
   yield promiseShutdownManager();
 });
 
 add_task(function* test_should_fire_on_browser_update() {