Bug 553967: Add an install property to Addons pending install to get the AddonInstall. r=robstrong

This commit is contained in:
Dave Townsend 2010-04-07 11:16:41 -07:00
parent 5f2fa99ee0
commit 250dff6390
3 changed files with 26 additions and 5 deletions

View File

@ -3314,6 +3314,7 @@ AddonInstall.prototype = {
uri = buildJarURI(this.file, FILE_INSTALL_MANIFEST);
this.addon = loadManifestFromRDF(uri, bis);
this.addon._sourceBundle = this.file;
this.addon._install = this;
}
finally {
bis.close();
@ -3597,11 +3598,16 @@ AddonInstall.prototype = {
0);
converter.init(stream, "UTF-8", 0, 0x0000);
// A little hacky but we can't (and shouldn't) cache the source bundle.
let bundle = this.addon._sourceBundle;
// A little hacky but we can't cache certain objects.
let objs = {
sourceBundle: this.addon._sourceBundle,
install: this.addon._install
};
delete this.addon._sourceBundle;
delete this.addon._install;
converter.writeString(json.encode(this.addon));
this.addon._sourceBundle = bundle;
this.addon._sourceBundle = objs.sourceBundle;
this.addon._install = objs.install;
}
finally {
converter.close();
@ -4072,6 +4078,12 @@ function AddonWrapper(addon) {
addon.updateAutomatically = val;
});
this.__defineGetter__("install", function() {
if (!("_install" in addon) || !addon._install)
return null;
return addon._install.wrapper;
});
this.__defineGetter__("pendingUpgrade", function() {
return createWrapper(addon.pendingUpgrade);
});

View File

@ -55,6 +55,7 @@ function run_test_1() {
do_check_eq(install.name, "Test 1");
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
do_check_true(install.addon.hasResource("install.rdf"));
do_check_eq(install.addon.install, install);
let file = do_get_addon("test_install1");
let uri = Services.io.newFileURI(file).spec;
@ -172,6 +173,7 @@ function check_test_2(install) {
do_check_eq(install.version, "2.0");
do_check_eq(install.name, "Real Test 2");
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
do_check_eq(install.addon.install, install);
// Pause the install here and start it again in run_test_3
do_execute_soon(function() { run_test_3(install); });
@ -261,6 +263,7 @@ function check_test_4(install) {
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
do_check_neq(install.existingAddon);
do_check_eq(install.existingAddon.id, "addon2@tests.mozilla.org");
do_check_eq(install.addon.install, install);
run_test_5();
// Installation will continue when there is nothing returned.
@ -278,8 +281,11 @@ function run_test_5() {
], check_test_5);
}
function check_test_5() {
function check_test_5(install) {
ensure_test_completed();
do_check_eq(install.existingAddon.pendingUpgrade.install, install);
AddonManager.getAddon("addon2@tests.mozilla.org", function(olda2) {
do_check_neq(olda2, null);
do_check_true(hasFlag(olda2.pendingOperations, AddonManager.PENDING_UPGRADE));

View File

@ -210,6 +210,7 @@ function run_test_4() {
function continue_test_4(install) {
do_check_neq(install.existingAddon, null);
do_check_eq(install.existingAddon.id, "addon1@tests.mozilla.org");
prepare_test({
"addon1@tests.mozilla.org": [
"onInstalling"
@ -220,7 +221,9 @@ function continue_test_4(install) {
], check_test_4);
}
function check_test_4() {
function check_test_4(install) {
do_check_eq(install.existingAddon.pendingUpgrade.install, install);
restartManager(1);
AddonManager.getAddon("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);