Bug 1232222 - provide telemetry environment data on which addons are system addons r=gfritzsche

MozReview-Commit-ID: 89M0HnzfIrd

--HG--
extra : histedit_source : c632502381dcb810b7d7857b98d3884fb90d1260
This commit is contained in:
Robert Helmer 2016-02-13 17:51:26 -08:00
Родитель 7560b7fefb
Коммит 21f0df9c9c
5 изменённых файлов: 51 добавлений и 1 удалений

Просмотреть файл

@ -540,6 +540,7 @@ EnvironmentAddonBuilder.prototype = {
installDay: Utils.millisecondsToDays(installDate.getTime()),
updateDay: Utils.millisecondsToDays(updateDate.getTime()),
signedState: addon.signedState,
isSystem: addon.isSystem,
};
if (addon.signedState !== undefined)

Просмотреть файл

@ -195,6 +195,7 @@ Structure::
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
isSystem: <bool>, // true if this is a System Add-on
},
...
},

Просмотреть файл

@ -166,6 +166,10 @@ function loadAddonManager(id, name, version, platformVersion) {
let uri = ns.Services.io.newFileURI(file);
ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
createAppInfo(id, name, version, platformVersion);
// As we're not running in application, we need to setup the features directory
// used by system add-ons.
const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "app0"], true);
registerDirectory("XREAppFeat", distroDir);
startupManager();
}

Просмотреть файл

@ -9,6 +9,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://testing-common/AddonManagerTesting.jsm");
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/MockRegistrar.jsm", this);
Cu.import("resource://gre/modules/FileUtils.jsm");
// Lazy load |LightweightThemeManager|, we won't be using it on Gonk.
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
@ -67,6 +68,9 @@ const PERSONA_DESCRIPTION = "A nice theme/persona description.";
const PLUGIN_UPDATED_TOPIC = "plugins-list-updated";
// system add-ons are enabled at startup, so record date when the test starts
const SYSTEM_ADDON_INSTALL_DATE = Date.now();
/**
* Used to mock plugin tags in our fake plugin host.
*/
@ -571,6 +575,11 @@ function checkSystemSection(data) {
}
function checkActiveAddon(data){
let signedState = mozinfo.addon_signing ? "number" : "undefined";
// system add-ons have an undefined signState
if (data.isSystem)
signedState = "undefined";
const EXPECTED_ADDON_FIELDS_TYPES = {
blocklisted: "boolean",
name: "string",
@ -583,7 +592,8 @@ function checkActiveAddon(data){
hasBinaryComponents: "boolean",
installDay: "number",
updateDay: "number",
signedState: mozinfo.addon_signing ? "number" : "undefined",
signedState: signedState,
isSystem: "boolean",
};
for (let f in EXPECTED_ADDON_FIELDS_TYPES) {
@ -715,6 +725,13 @@ function run_test() {
do_test_pending();
spoofGfxAdapter();
do_get_profile();
// The system add-on must be installed before AddonManager is started.
const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "app0"], true);
do_get_file("system.xpi").copyTo(distroDir, "tel-system-xpi@tests.mozilla.org.xpi");
let system_addon = FileUtils.File(distroDir.path);
system_addon.append("tel-system-xpi@tests.mozilla.org.xpi");
system_addon.lastModifiedTime = SYSTEM_ADDON_INSTALL_DATE;
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
// Spoof the persona ID, but not on Gonk.
@ -1016,6 +1033,24 @@ add_task(function* test_addonsAndPlugins() {
installDay: ADDON_INSTALL_DATE,
updateDay: ADDON_INSTALL_DATE,
signedState: mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED,
isSystem: false,
};
const SYSTEM_ADDON_ID = "tel-system-xpi@tests.mozilla.org";
const EXPECTED_SYSTEM_ADDON_DATA = {
blocklisted: false,
description: "A system addon which is shipped with Firefox.",
name: "XPI Telemetry System Add-on Test",
userDisabled: false,
appDisabled: false,
version: "1.0",
scope: 1,
type: "extension",
foreignInstall: false,
hasBinaryComponents: false,
installDay: truncateToDays(SYSTEM_ADDON_INSTALL_DATE),
updateDay: truncateToDays(SYSTEM_ADDON_INSTALL_DATE),
signedState: undefined,
isSystem: true,
};
const EXPECTED_PLUGIN_DATA = {
@ -1040,6 +1075,13 @@ add_task(function* test_addonsAndPlugins() {
Assert.equal(targetAddon[f], EXPECTED_ADDON_DATA[f], f + " must have the correct value.");
}
// Check system add-on data.
Assert.ok(SYSTEM_ADDON_ID in data.addons.activeAddons, "We must have one active system addon.");
let targetSystemAddon = data.addons.activeAddons[SYSTEM_ADDON_ID];
for (let f in EXPECTED_SYSTEM_ADDON_DATA) {
Assert.equal(targetSystemAddon[f], EXPECTED_SYSTEM_ADDON_DATA[f], f + " must have the correct value.");
}
// Check theme data.
let theme = data.addons.theme;
Assert.equal(theme.id, (PERSONA_ID + PERSONA_ID_SUFFIX));

Просмотреть файл

@ -12,6 +12,7 @@ support-files =
experiment.xpi
extension.xpi
extension-2.xpi
system.xpi
restartless.xpi
theme.xpi
generated-files =
@ -19,6 +20,7 @@ generated-files =
experiment.xpi
extension.xpi
extension-2.xpi
system.xpi
restartless.xpi
theme.xpi