Bug 974009 - Telemetry experiments: test experiment conditions and enable experiments. r=felipe,unfocused

This commit is contained in:
Georg Fritzsche 2014-03-18 22:52:28 +01:00
parent 4a434e6758
commit 642d94d03e
11 changed files with 1565 additions and 0 deletions

View File

@ -1403,3 +1403,7 @@ pref("ui.key.menuAccessKeyFocuses", true);
// Delete HTTP cache v2 data of users that didn't opt-in manually
pref("browser.cache.auto_delete_cache_version", 1);
// Telemetry experiments settings.
pref("experiments.enabled", false);
pref("experiments.manifest.fetchIntervalSeconds", 86400);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
component {f7800463-3b97-47f9-9341-b7617e6d8d49} ExperimentsService.js
contract @mozilla.org/browser/experiments-service;1 {f7800463-3b97-47f9-9341-b7617e6d8d49}
category update-timer ExperimentsService @mozilla.org/browser/experiments-service;1,getService,experiments-update-timer,experiments.manifest.fetchIntervalSeconds,86400
category profile-after-change ExperimentsService @mozilla.org/browser/experiments-service;1

View File

@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/experiments/Experiments.jsm");
function ExperimentsService() {
}
ExperimentsService.prototype = {
_experiments: null,
_pendingManifestUpdate: false,
classID: Components.ID("{f7800463-3b97-47f9-9341-b7617e6d8d49}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback, Ci.nsIObserver]),
notify: function (timer) {
if (this._experiments) {
this._experiments.updateManifest();
} else {
this._pendingManifestUpdate = true;
}
},
observe: function (subject, topic, data) {
switch(topic) {
case "profile-after-change":
Services.obs.addObserver(this, "xpcom-shutdown", false);
this._experiments = Experiments.instance();
if (this._pendingManifestUpdate) {
this._experiments.updateManifest();
this._pendingManifestUpdate = false;
}
break;
case "xpcom-shutdown":
Services.obs.removeObserver(this, "xpcom-shutdown");
this._experiments.uninit();
break;
}
},
get experiments() {
return this._experiments;
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ExperimentsService]);

View File

@ -0,0 +1,16 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_COMPONENTS += [
'Experiments.manifest',
'ExperimentsService.js',
]
JS_MODULES_PATH = 'modules/experiments'
EXTRA_JS_MODULES += [
'Experiments.jsm',
]
XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,19 @@
{
"version": 1,
"experiments": [
{
"id": "test-experiment-1@tests.mozilla.org",
"xpiURL": "https://experiments.mozilla.org/foo.xpi",
"xpiHash": "sha1:cb1eb32b89d86d78b7326f416cf404548c5e0099",
"startTime": 1393000000,
"endTime": 1394000000,
"appName": ["Firefox", "Fennec"],
"minVersion": "28",
"maxVersion": "30",
"maxActiveSeconds": 60,
"os": ["windows", "linux", "osx"],
"channel": ["daily", "weekly", "nightly"],
"jsfilter": "function filter(context) { return true; }"
}
]
}

View File

@ -0,0 +1,115 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://services-sync/healthreport.jsm", this);
Cu.import("resource://testing-common/services/healthreport/utils.jsm", this);
Cu.import("resource://gre/modules/services/healthreport/providers.jsm");
const EXPERIMENT1_ID = "test-experiment-1@tests.mozilla.org";
const EXPERIMENT1_XPI_SHA1 = "sha1:08c4d3ef1d0fc74faa455e85106ef0bc8cf8ca90";
const EXPERIMENT1_XPI_NAME = "experiment-1.xpi";
const EXPERIMENT2_ID = "test-experiment-2@tests.mozilla.org"
const EXPERIMENT2_XPI_SHA1 = "sha1:81877991ec70360fb48db84c34a9b2da7aa41d6a";
const EXPERIMENT2_XPI_NAME = "experiment-2.xpi";
let gAppInfo = null;
function getReporter(name, uri, inspected) {
return Task.spawn(function init() {
let reporter = getHealthReporter(name, uri, inspected);
yield reporter.init();
yield reporter._providerManager.registerProviderFromType(
HealthReportProvider);
throw new Task.Result(reporter);
});
}
function patchPolicy(policy, data) {
for (let key of Object.keys(data)) {
Object.defineProperty(policy, key, {
value: data[key],
writable: true,
});
}
}
function defineNow(policy, time) {
patchPolicy(policy, { now: () => new Date(time) });
}
function futureDate(date, offset) {
return new Date(date.getTime() + offset);
}
function dateToSeconds(date) {
return date.getTime() / 1000;
}
function createAppInfo(options) {
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
let options = options || {};
let id = options.id || "xpcshell@tests.mozilla.org";
let name = options.name || "XPCShell";
let version = options.version || "1.0";
let platformVersion = options.platformVersion || "1.0";
let date = options.date || new Date();
let buildID = "" + date.getYear() + date.getMonth() + date.getDate() + "01";
gAppInfo = {
// nsIXULAppInfo
vendor: "Mozilla",
name: name,
ID: id,
version: version,
appBuildID: buildID,
platformVersion: platformVersion ? platformVersion : "1.0",
platformBuildID: buildID,
// nsIXULRuntime
inSafeMode: false,
logConsoleErrors: true,
OS: "XPCShell",
XPCOMABI: "noarch-spidermonkey",
invalidateCachesOnRestart: function invalidateCachesOnRestart() {
// Do nothing
},
// nsICrashReporter
annotations: {},
annotateCrashReport: function(key, data) {
this.annotations[key] = data;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo,
Ci.nsIXULRuntime,
Ci.nsICrashReporter,
Ci.nsISupports])
};
let XULAppInfoFactory = {
createInstance: function (outer, iid) {
if (outer != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return gAppInfo.QueryInterface(iid);
}
};
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo",
XULAPPINFO_CONTRACTID, XULAppInfoFactory);
}

View File

@ -0,0 +1,7 @@
[DEFAULT]
head = head.js
tail =
firefox-appdir = browser
support-files =
experiments_1.manifest
../experiment-1.xpi

View File

@ -9,6 +9,7 @@ CONFIGURE_SUBST_FILES += ['installer/Makefile']
PARALLEL_DIRS += [
'base',
'components',
'experiments',
'fuel',
'locales',
'modules',