Bug 1232222 - Expose isSystem flag if add-on is a system add-on. r=Mossop

--HG--
extra : transplant_source : %11%BA%DA%AE%3D%0B%EE%BF%D2M%C6g%7F%86A%F2%BFh%03%22
This commit is contained in:
Robert Helmer 2016-01-25 12:35:24 -08:00
parent ac7fca4ef2
commit 9845218d0f
6 changed files with 60 additions and 1 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-system-xpi@tests.mozilla.org</em:id>
<em:version>1.0</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>XPI Telemetry System Add-on Test</em:name>
<em:description>A system addon which is shipped with Firefox.</em:description>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

View File

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -7050,6 +7050,12 @@ AddonWrapper.prototype = {
addon._installLocation.name == KEY_APP_SYSTEM_ADDONS);
},
get isSystem() {
let addon = addonFor(this);
return (addon._installLocation.name == KEY_APP_SYSTEM_DEFAULTS ||
addon._installLocation.name == KEY_APP_SYSTEM_ADDONS);
},
isCompatibleWith: function(aAppVersion, aPlatformVersion) {
return addonFor(this).isCompatibleWith(aAppVersion, aPlatformVersion);
},

View File

@ -185,6 +185,7 @@ function check_test_1(installSyncGUID) {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_eq(getStartupReason(), ADDON_INSTALL);
@ -291,6 +292,7 @@ function run_test_4() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_eq(getStartupReason(), ADDON_ENABLE);
@ -333,6 +335,7 @@ function run_test_5() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_false(isExtensionInAddonsList(profileDir, b1.id));
do_check_bootstrappedPref(run_test_6);
@ -376,6 +379,7 @@ function check_test_6() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
BootstrapMonitor.checkAddonStarted(ID1, "2.0");
do_check_eq(getStartupReason(), ADDON_UPGRADE);
@ -446,6 +450,7 @@ function run_test_8() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_eq(getStartupReason(), ADDON_INSTALL);
@ -516,6 +521,7 @@ function check_test_10_pt1() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
BootstrapMonitor.checkAddonStarted(ID1, "2.0");
do_check_eq(getStartupReason(), ADDON_INSTALL);
@ -560,6 +566,7 @@ function check_test_10_pt2() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_eq(getStartupReason(), ADDON_DOWNGRADE);
@ -626,6 +633,7 @@ function run_test_12() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_eq(getStartupReason(), ADDON_INSTALL);
@ -754,6 +762,7 @@ function run_test_15() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
@ -826,6 +835,7 @@ function run_test_16() {
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_eq(b1.iconURL, "chrome://foo/skin/icon.png");
do_check_eq(b1.aboutURL, "chrome://foo/content/about.xul");
do_check_eq(b1.optionsURL, "chrome://foo/content/options.xul");
@ -883,6 +893,7 @@ function run_test_17() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_bootstrappedPref(run_test_18);
});
@ -899,6 +910,7 @@ function run_test_18() {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_eq(getShutdownReason(), ADDON_UPGRADE);
do_check_eq(getUninstallReason(), ADDON_UPGRADE);
@ -941,6 +953,7 @@ function check_test_19() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
// TODO these reasons really should be ADDON_DOWNGRADE (bug 607818)
do_check_eq(getShutdownReason(), ADDON_UNINSTALL);
@ -974,6 +987,7 @@ function run_test_20() {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_eq(getShutdownReason(), APP_SHUTDOWN);
do_check_eq(getUninstallReason(), ADDON_UPGRADE);
@ -1008,6 +1022,7 @@ function run_test_21() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
// This won't be set as the bootstrap script was gone so we couldn't
// uninstall it properly
@ -1051,6 +1066,7 @@ function run_test_22() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
shutdownManager();
@ -1071,6 +1087,7 @@ function run_test_22() {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
// This won't be set as the bootstrap script was gone so we couldn't
// uninstall it properly
@ -1150,6 +1167,7 @@ function check_test_23() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");
do_check_eq(getStartupReason(), ADDON_INSTALL);
@ -1238,6 +1256,7 @@ function run_test_25() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_true(hasFlag(b1.pendingOperations, AddonManager.PENDING_UPGRADE));
restartManager();
@ -1251,6 +1270,7 @@ function run_test_25() {
do_check_neq(b1, null);
do_check_eq(b1.version, "4.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
do_check_bootstrappedPref(run_test_26);
@ -1275,6 +1295,7 @@ function run_test_26() {
do_check_neq(b1, null);
do_check_eq(b1.version, "4.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_true(hasFlag(b1.pendingOperations, AddonManager.PENDING_UPGRADE));
restartManager();
@ -1288,6 +1309,7 @@ function run_test_26() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
do_check_bootstrappedPref(run_test_27);
@ -1368,6 +1390,7 @@ function run_test_28() {
b1.userDisabled = false;
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
do_check_false(b1.isSystem);
do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
BootstrapMonitor.checkAddonStarted(ID1, "1.0");

View File

@ -46,6 +46,7 @@ function* check_installed(inProfile, ...versions) {
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UPGRADE));
do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UNINSTALL));
do_check_true(addon.hidden);
do_check_true(addon.isSystem);
// Verify the add-ons file is in the right place
let file = expectedDir.clone();

View File

@ -162,6 +162,7 @@ function* check_installed(inProfile, ...versions) {
do_check_true(addon.isActive);
do_check_false(addon.foreignInstall);
do_check_true(addon.hidden);
do_check_true(addon.isSystem);
// Verify the add-ons file is in the right place
let file = expectedDir.clone();

View File

@ -54,6 +54,7 @@ add_task(function*() {
do_check_true(addon.isCompatible);
do_check_false(addon.appDisabled);
do_check_true(addon.isActive);
do_check_false(addon.isSystem);
do_check_eq(addon.type, "extension");
do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_MISSING : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
@ -81,6 +82,7 @@ add_task(function*() {
do_check_true(addon.isCompatible);
do_check_false(addon.appDisabled);
do_check_true(addon.isActive);
do_check_false(addon.isSystem);
do_check_eq(addon.type, "extension");
do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_MISSING : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
@ -134,6 +136,7 @@ add_task(function*() {
do_check_true(addon.isCompatible);
do_check_false(addon.appDisabled);
do_check_true(addon.isActive);
do_check_false(addon.isSystem);
do_check_eq(addon.type, "extension");
do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_MISSING : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
@ -252,6 +255,7 @@ add_task(function*() {
do_check_neq(first_addon, null);
do_check_false(first_addon.appDisabled);
do_check_true(first_addon.isActive);
do_check_false(first_addon.isSystem);
let manifestjson_id= "last-webextension2@tests.mozilla.org";
let last_addon = yield promiseAddonByID(manifestjson_id);