Bug 1433334 - Add test assertions related to the expected install and addon installTelemetryInfo.
MozReview-Commit-ID: IIkfYpdXdXg
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
@@ -36,16 +36,20 @@ function promisePopupNotificationShown(n
}
async function checkInstallConfirmation(...names) {
let notificationCount = 0;
let observer = {
observe(aSubject, aTopic, aData) {
var installInfo = aSubject.wrappedJSObject;
isnot(installInfo.browser, null, "Notification should have non-null browser");
+ Assert.deepEqual(installInfo.installs[0].installTelemetryInfo, {
+ source: "about:addons",
+ method: "install-from-file",
+ }, "Got the expected installTelemetryInfo");
notificationCount++;
}
};
Services.obs.addObserver(observer, "addon-install-started");
let results = [];
let promise = promisePopupNotificationShown("addon-webext-permissions");
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
@@ -41,16 +41,23 @@ function promisePopupNotificationShown(n
}
async function checkInstallConfirmation(...names) {
let notificationCount = 0;
let observer = {
observe(aSubject, aTopic, aData) {
var installInfo = aSubject.wrappedJSObject;
isnot(installInfo.browser, null, "Notification should have non-null browser");
+
+ is(installInfo.installs.length, 1, "Got one AddonInstall instance as expected");
+
+ Assert.deepEqual(installInfo.installs[0].installTelemetryInfo,
+ {source: "about:addons", method: "url"},
+ "Got the expected installTelemetryInfo");
+
notificationCount++;
}
};
Services.obs.addObserver(observer, "addon-install-started");
let results = [];
let promise = promisePopupNotificationShown("addon-webext-permissions");
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js
@@ -208,16 +208,20 @@ function makeRegularTest(options, what)
// Sanity check to ensure that the test in makeInstallTest() that
// installs.size == 0 means we actually did clean up.
ok(AddonManager.webAPI.installs.size > 0, "webAPI is tracking the AddonInstall");
let addons = await promiseAddonsByIDs([ID]);
isnot(addons[0], null, "Found the addon");
+ // Check that the expected installTelemetryInfo has been stored in the addon details.
+ Assert.deepEqual(addons[0].installTelemetryInfo, {source: "test-hosts", method: "amWebAPI"},
+ "Got the expected addon.installTelemetryInfo");
+
await addons[0].uninstall();
addons = await promiseAddonsByIDs([ID]);
is(addons[0], null, "Addon was uninstalled");
});
}
add_task(makeRegularTest({url: XPI_URL}, "a basic install works"));
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js
@@ -23,16 +23,18 @@ function test() {
}
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}
function install_ended(install, addon) {
+ Assert.deepEqual(install.installTelemetryInfo, {source: "test-hosts", method: "installTrigger"},
+ "Got the expected install.installTelemetryInfo");
install.cancel();
}
const finish_test = async function(count) {
is(count, 1, "1 Add-on should have been successfully installed");
Services.perms.remove(makeURI("http://example.com"), "install");
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_url.js
@@ -13,16 +13,18 @@ function test() {
}
function confirm_install(panel) {
is(panel.getAttribute("name"), "XPI Test", "Should have seen the name");
return true;
}
function install_ended(install, addon) {
+ Assert.deepEqual(install.installTelemetryInfo, {source: "system-principal", method: "url"},
+ "Got the expected install.installTelemetryInfo");
install.cancel();
}
function finish_test(count) {
is(count, 1, "1 Add-on should have been successfully installed");
gBrowser.removeCurrentTab();
Harness.finish();
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
@@ -28,16 +28,20 @@ function runTest() {
"Location": "data:text/html,<script>window.location.href='" + TESTROOT + "amosigned.xpi'</script>"
});
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI(TESTROOT + "redirect.sjs?mode=redirect");
}
function install_blocked(installInfo) {
+ is(installInfo.installs.length, 1, "Got one AddonInstall instance as expected");
+ Assert.deepEqual(installInfo.installs[0].installTelemetryInfo,
+ {source: "null-principal", method: "url"},
+ "Got the expected install.installTelemetryInfo");
}
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
Services.perms.remove(makeURI("http://example.com"), "install");
gBrowser.removeCurrentTab();
Harness.finish();