Bug 1174565 - [EME] Report telemetry about which GMP files are missing - r=cpearce,spohl

* * *
Bug 1174565 - [EME] Updated xpcshell test - r=cpearce,spohl
This commit is contained in:
Gerald Squelart 2015-07-02 10:12:49 +10:00
Родитель 05fd9e5435
Коммит e91c23479e
2 изменённых файлов: 60 добавлений и 12 удалений

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

@ -51,6 +51,7 @@ const GMP_PLUGINS = [
homepageURL: "http://www.openh264.org/",
optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul",
missingKey: "VIDEO_OPENH264_GMP_DISAPPEARED",
missingFilesKey: "VIDEO_OPENH264_GMP_MISSING_FILES",
},
{
id: EME_ADOBE_ID,
@ -66,6 +67,7 @@ const GMP_PLUGINS = [
optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul",
isEME: true,
missingKey: "VIDEO_ADOBE_GMP_DISAPPEARED",
missingFilesKey: "VIDEO_ADOBE_GMP_MISSING_FILES",
}];
XPCOMUtils.defineLazyGetter(this, "pluginsBundle",
@ -148,6 +150,9 @@ GMPWrapper.prototype = {
get missingKey() {
return this._plugin.missingKey;
},
get missingFilesKey() {
return this._plugin.missingFilesKey;
},
get id() { return this._plugin.id; },
get type() { return "plugin"; },
@ -468,15 +473,44 @@ GMPWrapper.prototype = {
let id = this._plugin.id.substring(4);
let libName = AppConstants.DLL_PREFIX + id + AppConstants.DLL_SUFFIX;
return fileExists(this.gmpPath, libName) &&
fileExists(this.gmpPath, id + ".info") &&
(this._plugin.id != EME_ADOBE_ID ||
fileExists(this.gmpPath, id + ".voucher"));
return {
libraryMissing: !fileExists(this.gmpPath, libName),
infoMissing: !fileExists(this.gmpPath, id + ".info"),
voucherMissing: this._plugin.id == EME_ADOBE_ID
&& !fileExists(this.gmpPath, id + ".voucher"),
};
},
validate: function() {
return !this.isInstalled ||
this._arePluginFilesOnDisk();
if (!this.isInstalled) {
// Not installed -> Valid.
return { installed: false, valid: true };
}
// Installed -> Check if files are missing.
let status = this._arePluginFilesOnDisk();
status.installed = true;
status.valid = true;
status.missing = [];
status.telemetry = 0;
if (status.libraryMissing) {
status.valid = false;
status.missing.push('library');
status.telemetry += 1;
}
if (status.infoMissing) {
status.valid = false;
status.missing.push('info');
status.telemetry += 2;
}
if (status.voucherMissing) {
status.valid = false;
status.missing.push('voucher');
status.telemetry += 4;
}
return status;
},
};
@ -503,9 +537,13 @@ let GMPProvider = {
gmpPath);
if (gmpPath && isEnabled) {
if (!wrapper.validate()) {
let validation = wrapper.validate();
if (validation.installed) {
telemetryService.getHistogramById(wrapper.missingFilesKey).add(validation.telemetry);
}
if (!validation.valid) {
this._log.info("startup - gmp " + plugin.id +
" missing lib and/or info files, uninstalling");
" missing [" + validation.missing + "], uninstalling");
telemetryService.getHistogramById(wrapper.missingKey).add(true);
wrapper.uninstallPlugin();
continue;
@ -633,6 +671,7 @@ let GMPProvider = {
wrapper: null,
isEME: aPlugin.isEME,
missingKey: aPlugin.missingKey,
missingFilesKey: aPlugin.missingFilesKey,
};
plugin.fullDescription = this.generateFullDescription(aPlugin);
plugin.wrapper = new GMPWrapper(plugin);

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

@ -24,6 +24,7 @@ for (let plugin of GMPScope.GMP_PLUGINS) {
nameId: plugin.name,
descriptionId: plugin.description,
missingKey: plugin.missingKey,
missingFilesKey: plugin.missingFilesKey,
});
gMockAddons.set(mockAddon.id, mockAddon);
if (mockAddon.id.indexOf("gmp-eme-") == 0) {
@ -278,13 +279,13 @@ add_task(function* test_pluginRegistration() {
},
};
let reportedKeys = [];
let reportedKeys = {};
let MockTelemetry = {
getHistogramById: key => {
return {
add: value => {
reportedKeys.push(key);
reportedKeys[key] = value;
}
}
}
@ -304,8 +305,12 @@ add_task(function* test_pluginRegistration() {
Assert.deepEqual(removedPaths, [file.path]);
// Test that the GMPProvider tried to report via telemetry that the
// addon's lib file is missing.
Assert.deepEqual(reportedKeys, [addon.missingKey]);
// addon's lib files are missing.
Assert.strictEqual(reportedKeys[addon.missingKey], true);
Assert.strictEqual(reportedKeys[addon.missingFilesKey],
addon.missingFilesKey != "VIDEO_ADOBE_GMP_MISSING_FILES"
? (1+2) : (1+2+4));
reportedKeys = {};
// Create dummy GMP library/info files, and test that plugin registration
// succeeds during startup, now that we've added GMP info/lib files.
@ -318,6 +323,10 @@ add_task(function* test_pluginRegistration() {
Assert.notEqual(addedPaths.indexOf(file.path), -1);
Assert.deepEqual(removedPaths, []);
// Test that the GMPProvider tried to report via telemetry that the
// addon's lib files are NOT missing.
Assert.strictEqual(reportedKeys[addon.missingFilesKey], 0);
// Check that clearing the version doesn't trigger registration.
clearPaths();
gPrefs.clearUserPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id));