Bug 702868 - AddonInternal.hasBinaryComponents doesn't affect AddonInternal.appDisabled until after initial install. r=dtownsend

This commit is contained in:
Blair McBride 2011-11-17 17:27:23 +13:00
Родитель 95295f5468
Коммит df92a0a1e5
5 изменённых файлов: 88 добавлений и 4 удалений

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

@ -809,8 +809,6 @@ function loadManifestFromRDF(aUri, aStream) {
addon.softDisabled = addon.blocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
}
addon.appDisabled = !isUsableAddon(addon);
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
return addon;
@ -865,6 +863,7 @@ function loadManifestFromDir(aDir) {
addon.hasBinaryComponents = ChromeManifestParser.hasType(chromeManifest,
"binary-component");
addon.appDisabled = !isUsableAddon(addon);
return addon;
}
finally {
@ -907,6 +906,7 @@ function loadManifestFromZipReader(aZipReader) {
addon.hasBinaryComponents = false;
}
addon.appDisabled = !isUsableAddon(addon);
return addon;
}
finally {

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

@ -0,0 +1 @@
binary-component components/mycomponent.so

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

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!-- An extension that is incompatible with the XPCShell test suite and
has binary components, so won't be compatible-by-default. -->
<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>addon5@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<!-- Front End MetaData -->
<em:name>Real Test 5</em:name>
<em:description>Test Description</em:description>
<em:unpack>true</em:unpack>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -842,7 +842,11 @@ const InstallListener = {
},
onInstallCancelled: function(install) {
do_check_eq(install.state, AddonManager.STATE_CANCELLED);
// If the install was cancelled by a listener returning false from
// onInstallStarted, then the state will revert to STATE_DOWNLOADED.
let possibleStates = [AddonManager.STATE_CANCELLED,
AddonManager.STATE_DOWNLOADED];
do_check_true(possibleStates.indexOf(install.state) != -1);
do_check_eq(install.error, 0);
do_check_eq("onInstallCancelled", getExpectedInstall(install.addon));
return check_test_completed(arguments);

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

@ -1618,5 +1618,58 @@ function finish_test_27(aInstall) {
ensure_test_completed();
do_test_finished();
run_test_28();
}
// Tests that an install that isn't strictly compatible and has
// binary components correctly has appDisabled set (see bug 702868).
function run_test_28() {
prepare_test({ }, [
"onNewInstall"
]);
let url = "http://localhost:4444/addons/test_install5.xpi";
AddonManager.getInstallForURL(url, function(install) {
ensure_test_completed();
do_check_neq(install, null);
do_check_eq(install.version, "1.0");
do_check_eq(install.name, "Real Test 5");
do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
AddonManager.getInstallsByTypes(null, function(activeInstalls) {
do_check_eq(activeInstalls.length, 1);
do_check_eq(activeInstalls[0], install);
prepare_test({}, [
"onDownloadStarted",
"onDownloadEnded",
"onInstallStarted"
], check_test_28);
install.install();
});
}, "application/x-xpinstall", null, "Real Test 5", null, "1.0");
}
function check_test_28(install) {
ensure_test_completed();
do_check_eq(install.version, "1.0");
do_check_eq(install.name, "Real Test 5");
do_check_eq(install.state, AddonManager.STATE_INSTALLING);
do_check_eq(install.existingAddon, null);
do_check_false(install.addon.isCompatible);
do_check_true(install.addon.appDisabled);
prepare_test({}, [
"onInstallCancelled"
], finish_test_28);
return false;
}
function finish_test_28(install) {
prepare_test({}, [
"onDownloadCancelled"
], do_test_finished);
install.cancel();
}