Bug 1359939 - Run a Telemetry experiment on Nightly to vet animated image caching. r=felipe
authorAnthony Hughes <anthony.s.hughes@gmail.com>
Mon, 01 May 2017 19:14:02 -0300
changeset 124 e6409d179187
parent 123 f49eea745072
child 125 61e8757c63b9
push id97
push userfelipc@gmail.com
push dateMon, 01 May 2017 22:14:27 +0000
reviewersfelipe
bugs1359939
Bug 1359939 - Run a Telemetry experiment on Nightly to vet animated image caching. r=felipe
experiments/animated-image-discarding-nightly55/code/bootstrap.js
experiments/animated-image-discarding-nightly55/code/install.rdf
experiments/animated-image-discarding-nightly55/manifest.json
new file mode 100644
--- /dev/null
+++ b/experiments/animated-image-discarding-nightly55/code/bootstrap.js
@@ -0,0 +1,67 @@
+let {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource:///modules/experiments/Experiments.jsm");
+Cu.import("resource://gre/modules/Task.jsm");
+Cu.import("resource://gre/modules/Preferences.jsm");
+
+var gStarted = false;
+
+const kSELF_ID = "animated-image-discarding-nightly55@experiments.mozilla.org";
+const prefs = new Preferences();
+
+function startup() {
+  // Seems startup() function is launched twice after install, we're
+  // unsure why so far. We only want it to run once.
+  if (gStarted) {
+    return;
+  }
+  gStarted = true;
+
+  Task.spawn(function*() {
+    let branch = yield Experiments.instance().getExperimentBranch(kSELF_ID);
+    if (branch == null) {
+      let r = Math.random() * 2;
+      if (r < 1) {
+        branch = "control";
+      } else {
+        branch = "disabled";
+        prefs.set("image.mem.animated.discardable", false);
+      }
+      yield Experiments.instance().setExperimentBranch(kSELF_ID, branch);
+    } else {
+      // Exclude the user if they've manually changed the pref
+      let pref = prefs.get("image.mem.animated.discardable");
+      let isBranchValid = true;
+      if (branch == "disabled") {
+        isBranchValid = (pref == false);
+      } else if (branch == "control") {
+        isBranchValid = (pref == true);
+      }
+      if (!isBranchValid) {
+        branch = "usermod";
+        yield Experiments.instance().setExperimentBranch(kSELF_ID, branch);
+      }
+    }
+  }).then(
+    function() {
+    },
+    function(e) {
+      Cu.reportError("Got error during bootstrap startup: " + e);
+    });
+}
+
+function shutdown(reason) {
+  if (reason == ADDON_DISABLE || reason == ADDON_UNINSTALL) {
+    // when the add-on is being disabled/uninstalled
+    prefs.reset("image.mem.animated.discardable");
+  }
+}
+
+function install() {
+  // no-op
+}
+
+function uninstall() {
+  prefs.reset("image.mem.animated.discardable");
+}
+
new file mode 100644
--- /dev/null
+++ b/experiments/animated-image-discarding-nightly55/code/install.rdf
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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>animated-image-discarding-nightly55@experiments.mozilla.org</em:id>
+    <em:version>1.0.0</em:version>
+    <em:type>128</em:type>
+    <em:bootstrap>true</em:bootstrap>
+    <em:unpack>false</em:unpack>
+
+    <!-- Firefox -->
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+        <em:minVersion>55.0a1</em:minVersion>
+        <em:maxVersion>55.0a1</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+    <!-- Front End MetaData -->
+    <em:name>Animated Image Discarding Nightly 55</em:name>
+    <em:description>Measures the impact of enabling animate image discarding in Firefox Nightly 55</em:description>
+    <em:aboutURL>https://bugzilla.mozilla.org/show_bug.cgi?id=686905</em:aboutURL>
+  </Description>
+</RDF>
new file mode 100644
--- /dev/null
+++ b/experiments/animated-image-discarding-nightly55/manifest.json
@@ -0,0 +1,18 @@
+{
+  "publish"     : true,
+  "priority"    : 2,
+  "name"        : "Animated Image Discarding Nightly 55",
+  "description" : "Measures the impact of enabling animate image discarding in Firefox Nightly 55",
+  "info"        : "<p><a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=686905\">Related bug</a></p>",
+  "manifest"    : {
+    "id"               : "animated-image-discarding-nightly55@experiments.mozilla.org",
+    "startTime"        : 1493676124,
+    "endTime"          : 1494720000,
+    "maxActiveSeconds" : 864000,
+    "appName"          : ["Firefox"],
+    "channel"          : ["nightly"],
+    "minVersion"       : "55.0a1",
+    "maxVersion"       : "55.0a1",
+    "sample"           : 0.5
+  }
+}