Bug 1062388: Add add-on signedState to telemetry environment. r=vladan, r=gfritzsche
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 29 May 2015 12:45:33 -0700
changeset 246667 3c6c755707d5a30618a18a9b159b181d964940d6
parent 246666 ce72fec8fe5a05e40e753f6592726fd0cf58a203
child 246668 cf8b81b08f0766c759a0c7dfb2be16ef1198e5b8
push id28838
push userkwierso@gmail.com
push dateWed, 03 Jun 2015 01:12:22 +0000
treeherdermozilla-central@535ab0825603 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan, gfritzsche
bugs1062388
milestone41.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 1062388: Add add-on signedState to telemetry environment. r=vladan, r=gfritzsche
toolkit/components/telemetry/TelemetryEnvironment.jsm
toolkit/components/telemetry/docs/environment.rst
toolkit/components/telemetry/tests/addons/signed/META-INF/manifest.mf
toolkit/components/telemetry/tests/addons/signed/META-INF/mozilla.rsa
toolkit/components/telemetry/tests/addons/signed/META-INF/mozilla.sf
toolkit/components/telemetry/tests/addons/signed/install.rdf
toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -490,17 +490,21 @@ EnvironmentAddonBuilder.prototype = {
         appDisabled: addon.appDisabled,
         version: addon.version,
         scope: addon.scope,
         type: addon.type,
         foreignInstall: addon.foreignInstall,
         hasBinaryComponents: addon.hasBinaryComponents,
         installDay: Utils.millisecondsToDays(installDate.getTime()),
         updateDay: Utils.millisecondsToDays(updateDate.getTime()),
+        signedState: addon.signedState,
       };
+
+      if (addon.signedState !== undefined)
+        activeAddons[addon.id].signedState = addon.signedState;
     }
 
     return activeAddons;
   }),
 
   /**
    * Get the currently active theme data in object form.
    * @return Promise<object> containing the active theme data.
--- a/toolkit/components/telemetry/docs/environment.rst
+++ b/toolkit/components/telemetry/docs/environment.rst
@@ -140,16 +140,17 @@ Structure::
             appDisabled: <bool>,
             version: <string>,
             scope: <integer>,
             type: <string>, // "extension", "service", ...
             foreignInstall: <bool>,
             hasBinaryComponents: <bool>
             installDay: <number>, // days since UNIX epoch, 0 on failure
             updateDay: <number>, // days since UNIX epoch, 0 on failure
+            signedState: <integer>, // whether the add-on is signed by AMO, only present for extensions
           },
           ...
         },
         theme: { // the active theme
           id: <string>,
           blocklisted: <bool>,
           description: <string>,
           name: <string>,
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/addons/signed/META-INF/manifest.mf
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+
+Name: install.rdf
+Digest-Algorithms: MD5 SHA1
+MD5-Digest: YEilRfaecTg2bMNPoYqexQ==
+SHA1-Digest: GEnQKM8Coyw83phx/z1oNh327+0=
+
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8e5a92650e80e75cc7c603c0375763eebfcf3b9e
GIT binary patch
literal 4190
zc%0o=XH-;a(xxLh*$7CG1_UKE+$JXpO<b}hLAFI`a%w`;BuNb-C@5h>kQ|yQAVCl$
zC;|eaFd#XH5d;+w#8!d}Iy27B_v8DuXV2Mx_qp{{-KzJ#_0%bV#BvEvD;ld8`<W3$
z4bCI67yu*|T`&lQrUz)@Ffk?wm<vV)(ElWX@<<FX01~VRAVD7FLBJp|7!ESZSKfjF
zjDNB~^hZunUEhO1ETM1&*wP%$18^M!It0Q9AL8ceX^+&z`}yGg><MmoZ?q(UI=0dy
zg#WN=7?~hV{qT+fxMKp++|9+?&D#ZO?&L>w!#SbRfaI|Q1aZ#iPZG-i2ML9<m#}wq
z#C!Woc>Rbbf%kJk%K%b;rbr877xMoR${&UI@fZ8S|KYFxhZhd-1)Sz!M9TuQQi^Cr
zSt%LCOGi-d2rB#zfv9LS0$}}-Jl)TP|Gjv2fbAGiBN&bF0p0|AH*chsn^Pc~`RLTX
z9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etpnX@Q}c|F-Y|f<LWL^pSSd4D$-hmVbfXxtVrqgrj&0H{DMCx6uV9fvFnb
z#7KCC_=YL1YUIEJPRE|_LRjH0J>64;UI3j`kH2aLkJ%l-VKP|4pR|{#N>&F+6&Nko
znS>%{VzC~)A*}rfX}y>CnyrJTMCo#JQsEH}HT9T9m%c8}6W!KsJ0`qb{W|MC3gvJ1
z3m31hQ2CYJaf@TL50Y(Po+Av$Gb{`DeXgQ2(4=p<F5jK)YL|eUJ=~QoV6F)`(Lsw%
zs1*(DG77mCIHXsXkm+vG=6@#cAXiMos-gE=uCP8<UOd}u#O7+fV7uNwalhiG$dwsB
zP}5p_)`Tr|dWliG*!H2Gq4+xG@p;{DRRTnB%`eMYJXk)M^kLig%KfX{w=de;<`sSL
zydZsTUNKJE^=__m-7+-tY1WI($zf(abqL>FikhMEbr^5DDM!HAE!X(azAyKjU5U-3
z+bSnj7TuW>THT%!1(pUfIWvaNz1{Vn3r@`2@k%h>3`vSYU!<IUaA<@1dga5|NJT<Z
z>qF<XBJ5Nj*P=nsV?jH)YuHY|DYg|`Wlrvbgo?e0dS;-O&&~<XBBcDBa^Wmfwn%>^
z3gtC%z(dMdIT%?RYbrG4R;rk@bYS&JQT7tNK+}4W_Wt0OMRQCl<94+4^5J5>4&Qcw
yQ5~I%;+oW>%Lq%0CZ;k%ifXxplbYOZn%d2J8h4dFreXWRj)V9LG^j4^<i7yrJhN5+
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/addons/signed/META-INF/mozilla.sf
@@ -0,0 +1,4 @@
+Signature-Version: 1.0
+MD5-Digest-Manifest: Ko2bKTrwTXCdstWHWqCR4w==
+SHA1-Digest-Manifest: k6+jfNGFxXtDd1cSX0ZoIyQ1cww=
+
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/addons/signed/install.rdf
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>tel-signed-xpi@tests.mozilla.org</em:id>
+    <em:version>1.0</em:version>
+
+    <em:targetApplication>
+      <Description>
+        <em:id>toolkit@mozilla.org</em:id>
+        <em:minVersion>0</em:minVersion>
+        <em:maxVersion>*</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+    <!-- Front End MetaData -->
+    <em:name>XPI Telemetry Signed Test</em:name>
+    <em:description>A signed addon which gets enabled without a reboot.</em:description>
+    <em:bootstrap>true</em:bootstrap>
+
+  </Description>
+</RDF>
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -436,16 +436,17 @@ function checkActiveAddon(data){
     appDisabled: "boolean",
     version: "string",
     scope: "number",
     type: "string",
     foreignInstall: "boolean",
     hasBinaryComponents: "boolean",
     installDay: "number",
     updateDay: "number",
+    signedState: "number",
   };
 
   for (let f in EXPECTED_ADDON_FIELDS_TYPES) {
     Assert.ok(f in data, f + " must be available.");
     Assert.equal(typeof data[f], EXPECTED_ADDON_FIELDS_TYPES[f],
                  f + " must have the correct type.");
   }
 
@@ -852,16 +853,17 @@ add_task(function* test_addonsAndPlugins
     appDisabled: false,
     version: "1.0",
     scope: 1,
     type: "extension",
     foreignInstall: false,
     hasBinaryComponents: false,
     installDay: ADDON_INSTALL_DATE,
     updateDay: ADDON_INSTALL_DATE,
+    signedState: AddonManager.SIGNEDSTATE_MISSING,
   };
 
   const EXPECTED_PLUGIN_DATA = {
     name: FLASH_PLUGIN_NAME,
     version: FLASH_PLUGIN_VERSION,
     description: FLASH_PLUGIN_DESC,
     blocklisted: false,
     disabled: false,
@@ -898,16 +900,59 @@ add_task(function* test_addonsAndPlugins
   Assert.ok(targetPlugin.mimeTypes.find(m => m == PLUGIN_MIME_TYPE1));
   Assert.ok(targetPlugin.mimeTypes.find(m => m == PLUGIN_MIME_TYPE2));
   Assert.ok(!targetPlugin.mimeTypes.find(m => m == "Not There."));
 
   let personaId = (gIsGonk) ? null : PERSONA_ID;
   Assert.equal(data.addons.persona, personaId, "The correct Persona Id must be reported.");
 });
 
+add_task(function* test_signedAddon() {
+  const ADDON_INSTALL_URL = gDataRoot + "signed.xpi";
+  const ADDON_ID = "tel-signed-xpi@tests.mozilla.org";
+  const ADDON_INSTALL_DATE = truncateToDays(Date.now());
+  const EXPECTED_ADDON_DATA = {
+    blocklisted: false,
+    description: "A signed addon which gets enabled without a reboot.",
+    name: "XPI Telemetry Signed Test",
+    userDisabled: false,
+    appDisabled: false,
+    version: "1.0",
+    scope: 1,
+    type: "extension",
+    foreignInstall: false,
+    hasBinaryComponents: false,
+    installDay: ADDON_INSTALL_DATE,
+    updateDay: ADDON_INSTALL_DATE,
+    signedState: AddonManager.SIGNEDSTATE_SIGNED,
+  };
+
+  // Set the clock in the future so our changes don't get throttled.
+  gNow = fakeNow(futureDate(gNow, 10 * MILLISECONDS_PER_MINUTE));
+  let deferred = PromiseUtils.defer();
+  TelemetryEnvironment.registerChangeListener("test_signedAddon", deferred.resolve);
+
+  // Install the addon.
+  yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
+
+  yield deferred.promise;
+  // Unregister the listener.
+  TelemetryEnvironment.unregisterChangeListener("test_signedAddon");
+
+  let data = TelemetryEnvironment.currentEnvironment;
+  checkEnvironmentData(data);
+
+  // Check addon data.
+  Assert.ok(ADDON_ID in data.addons.activeAddons, "Add-on should be in the environment.");
+  let targetAddon = data.addons.activeAddons[ADDON_ID];
+  for (let f in EXPECTED_ADDON_DATA) {
+    Assert.equal(targetAddon[f], EXPECTED_ADDON_DATA[f], f + " must have the correct value.");
+  }
+});
+
 add_task(function* test_changeThrottling() {
   const PREF_TEST = "toolkit.telemetry.test.pref1";
   const PREFS_TO_WATCH = new Map([
     [PREF_TEST, TelemetryEnvironment.RECORD_PREF_STATE],
   ]);
   Preferences.reset(PREF_TEST);
 
   gNow = futureDate(gNow, 10 * MILLISECONDS_PER_MINUTE);