Bug 1211404 - Add test coverage. r=gfritzsche

This commit is contained in:
Alessio Placitelli 2015-10-07 01:17:00 +02:00
parent 432e4475f9
commit 199423f245
2 changed files with 55 additions and 0 deletions

View File

@ -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-longfields-xpi@tests.mozilla.org</em:id>
<em:version>This is a really long addon version, that will get limited to 100 characters. We're much longer, we're at about 116.</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>This is a really long addon name, that will get limited to 100 characters. We're much longer, we're at about 219. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus nullam sodales. Yeah, Latin placeholder.</em:name>
<em:description>This is a really long addon description, that will get limited to 100 characters. We're much longer, we're at about 200. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus nullam sodales.</em:description>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

View File

@ -1017,6 +1017,37 @@ add_task(function* test_signedAddon() {
}
});
add_task(function* test_addonsFieldsLimit() {
const ADDON_INSTALL_URL = gDataRoot + "long-fields.xpi";
const ADDON_ID = "tel-longfields-xpi@tests.mozilla.org";
// Set the clock in the future so our changes don't get throttled.
gNow = fakeNow(futureDate(gNow, 10 * MILLISECONDS_PER_MINUTE));
// Install the addon and wait for the TelemetryEnvironment to pick it up.
let deferred = PromiseUtils.defer();
TelemetryEnvironment.registerChangeListener("test_longFieldsAddon", deferred.resolve);
yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
yield deferred.promise;
TelemetryEnvironment.unregisterChangeListener("test_longFieldsAddon");
let data = TelemetryEnvironment.currentEnvironment;
checkEnvironmentData(data);
// Check that the addon is available and that the string fields are limited.
Assert.ok(ADDON_ID in data.addons.activeAddons, "Add-on should be in the environment.");
let targetAddon = data.addons.activeAddons[ADDON_ID];
// TelemetryEnvironment limits the length of string fields for activeAddons to 100 chars,
// to mitigate misbehaving addons.
Assert.lessOrEqual(targetAddon.version.length, 100,
"The version string must have been limited");
Assert.lessOrEqual(targetAddon.name.length, 100,
"The name string must have been limited");
Assert.lessOrEqual(targetAddon.description.length, 100,
"The description string must have been limited");
});
add_task(function* test_changeThrottling() {
const PREF_TEST = "toolkit.telemetry.test.pref1";
const PREFS_TO_WATCH = new Map([