mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 593535 - Failure to download extension causes about:addons to list the addon with no way to restart the download; fix broken hasResource, getResource; f=dtownsend r=dtownsend,robert.bugzilla a=blocking2.0
This commit is contained in:
parent
e20afb330c
commit
8a73fd60c1
@ -4029,6 +4029,15 @@ var XPIDatabase = {
|
|||||||
DB_BOOL_METADATA.forEach(function(aProp) {
|
DB_BOOL_METADATA.forEach(function(aProp) {
|
||||||
addon[aProp] = aRow[aProp] != 0;
|
addon[aProp] = aRow[aProp] != 0;
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
addon._sourceBundle = addon._installLocation.getLocationForID(addon.id);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// An exception will be thrown if the add-on appears in the database but
|
||||||
|
// not on disk. In general this should only happen during startup as
|
||||||
|
// this change is being detected.
|
||||||
|
}
|
||||||
|
|
||||||
this.addonCache[aRow.internal_id] = Components.utils.getWeakReference(addon);
|
this.addonCache[aRow.internal_id] = Components.utils.getWeakReference(addon);
|
||||||
return addon;
|
return addon;
|
||||||
},
|
},
|
||||||
@ -4210,6 +4219,14 @@ var XPIDatabase = {
|
|||||||
DB_BOOL_METADATA.forEach(function(aProp) {
|
DB_BOOL_METADATA.forEach(function(aProp) {
|
||||||
addon[aProp] = aRow.getResultByName(aProp) != 0;
|
addon[aProp] = aRow.getResultByName(aProp) != 0;
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
addon._sourceBundle = addon._installLocation.getLocationForID(addon.id);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// An exception will be thrown if the add-on appears in the database but
|
||||||
|
// not on disk. In general this should only happen during startup as
|
||||||
|
// this change is being detected.
|
||||||
|
}
|
||||||
|
|
||||||
this.addonCache[internal_id] = Components.utils.getWeakReference(addon);
|
this.addonCache[internal_id] = Components.utils.getWeakReference(addon);
|
||||||
addon._pendingCallbacks = [aCallback];
|
addon._pendingCallbacks = [aCallback];
|
||||||
@ -5668,6 +5685,7 @@ AddonInstall.prototype = {
|
|||||||
cleanStagingDir(stagedAddon.parent, []);
|
cleanStagingDir(stagedAddon.parent, []);
|
||||||
|
|
||||||
// Update the metadata in the database
|
// Update the metadata in the database
|
||||||
|
this.addon._sourceBundle = file;
|
||||||
this.addon._installLocation = this.installLocation;
|
this.addon._installLocation = this.installLocation;
|
||||||
this.addon.updateDate = recursiveLastModifiedTime(file);
|
this.addon.updateDate = recursiveLastModifiedTime(file);
|
||||||
this.addon.visible = true;
|
this.addon.visible = true;
|
||||||
@ -6560,14 +6578,7 @@ function AddonWrapper(aAddon) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.hasResource = function(aPath) {
|
this.hasResource = function(aPath) {
|
||||||
let bundle = null;
|
let bundle = aAddon._sourceBundle.clone();
|
||||||
if (aAddon instanceof DBAddonInternal) {
|
|
||||||
bundle = aAddon._sourceBundle = aAddon._installLocation
|
|
||||||
.getLocationForID(aAddon.id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bundle = aAddon._sourceBundle.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bundle.isDirectory()) {
|
if (bundle.isDirectory()) {
|
||||||
if (aPath) {
|
if (aPath) {
|
||||||
@ -6587,14 +6598,7 @@ function AddonWrapper(aAddon) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
this.getResourceURI = function(aPath) {
|
this.getResourceURI = function(aPath) {
|
||||||
let bundle = null;
|
let bundle = aAddon._sourceBundle.clone();
|
||||||
if (aAddon instanceof DBAddonInternal) {
|
|
||||||
bundle = aAddon._sourceBundle = aAddon._installLocation
|
|
||||||
.getLocationForID(aAddon.id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bundle = aAddon._sourceBundle.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bundle.isDirectory()) {
|
if (bundle.isDirectory()) {
|
||||||
if (aPath) {
|
if (aPath) {
|
||||||
|
@ -27,6 +27,9 @@ userExtDir.append("extensions2");
|
|||||||
userExtDir.append(gAppInfo.ID);
|
userExtDir.append(gAppInfo.ID);
|
||||||
registerDirectory("XREUSysExt", userExtDir.parent);
|
registerDirectory("XREUSysExt", userExtDir.parent);
|
||||||
|
|
||||||
|
do_load_httpd_js();
|
||||||
|
var testserver;
|
||||||
|
|
||||||
function resetPrefs() {
|
function resetPrefs() {
|
||||||
Services.prefs.setIntPref("bootstraptest.active_version", -1);
|
Services.prefs.setIntPref("bootstraptest.active_version", -1);
|
||||||
Services.prefs.setIntPref("bootstraptest.installed_version", -1);
|
Services.prefs.setIntPref("bootstraptest.installed_version", -1);
|
||||||
@ -65,6 +68,11 @@ function run_test() {
|
|||||||
|
|
||||||
resetPrefs();
|
resetPrefs();
|
||||||
|
|
||||||
|
// Create and configure the HTTP server.
|
||||||
|
testserver = new nsHttpServer();
|
||||||
|
testserver.registerDirectory("/addons/", do_get_file("addons"));
|
||||||
|
testserver.start(4444);
|
||||||
|
|
||||||
startupManager();
|
startupManager();
|
||||||
|
|
||||||
run_test_1();
|
run_test_1();
|
||||||
@ -91,6 +99,7 @@ function run_test_1() {
|
|||||||
AddonManager.OP_NEEDS_RESTART_INSTALL, 0);
|
AddonManager.OP_NEEDS_RESTART_INSTALL, 0);
|
||||||
do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
|
do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
|
||||||
|
|
||||||
|
let addon = install.addon;
|
||||||
prepare_test({
|
prepare_test({
|
||||||
"bootstrap1@tests.mozilla.org": [
|
"bootstrap1@tests.mozilla.org": [
|
||||||
["onInstalling", false],
|
["onInstalling", false],
|
||||||
@ -99,7 +108,10 @@ function run_test_1() {
|
|||||||
}, [
|
}, [
|
||||||
"onInstallStarted",
|
"onInstallStarted",
|
||||||
"onInstallEnded",
|
"onInstallEnded",
|
||||||
], check_test_1);
|
], function() {
|
||||||
|
do_check_true(addon.hasResource("install.rdf"));
|
||||||
|
check_test_1();
|
||||||
|
});
|
||||||
install.install();
|
install.install();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1017,7 +1029,87 @@ function run_test_22() {
|
|||||||
do_check_eq(getInstallReason(), ADDON_UPGRADE);
|
do_check_eq(getInstallReason(), ADDON_UPGRADE);
|
||||||
do_check_eq(getStartupReason(), APP_STARTUP);
|
do_check_eq(getStartupReason(), APP_STARTUP);
|
||||||
|
|
||||||
do_test_finished();
|
b1.uninstall();
|
||||||
|
|
||||||
|
run_test_23();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Tests that installing from a URL doesn't require a restart
|
||||||
|
function run_test_23() {
|
||||||
|
prepare_test({ }, [
|
||||||
|
"onNewInstall"
|
||||||
|
]);
|
||||||
|
|
||||||
|
let url = "http://localhost:4444/addons/test_bootstrap1_1.xpi";
|
||||||
|
AddonManager.getInstallForURL(url, function(install) {
|
||||||
|
ensure_test_completed();
|
||||||
|
|
||||||
|
do_check_neq(install, null);
|
||||||
|
|
||||||
|
prepare_test({ }, [
|
||||||
|
"onDownloadStarted",
|
||||||
|
"onDownloadEnded"
|
||||||
|
], function() {
|
||||||
|
do_check_eq(install.type, "extension");
|
||||||
|
do_check_eq(install.version, "1.0");
|
||||||
|
do_check_eq(install.name, "Test Bootstrap 1");
|
||||||
|
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
||||||
|
do_check_true(install.addon.hasResource("install.rdf"));
|
||||||
|
do_check_true(install.addon.hasResource("bootstrap.js"));
|
||||||
|
do_check_false(install.addon.hasResource("foo.bar"));
|
||||||
|
do_check_eq(install.addon.operationsRequiringRestart &
|
||||||
|
AddonManager.OP_NEEDS_RESTART_INSTALL, 0);
|
||||||
|
do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
|
||||||
|
|
||||||
|
let addon = install.addon;
|
||||||
|
prepare_test({
|
||||||
|
"bootstrap1@tests.mozilla.org": [
|
||||||
|
["onInstalling", false],
|
||||||
|
"onInstalled"
|
||||||
|
]
|
||||||
|
}, [
|
||||||
|
"onInstallStarted",
|
||||||
|
"onInstallEnded",
|
||||||
|
], function() {
|
||||||
|
do_check_true(addon.hasResource("install.rdf"));
|
||||||
|
check_test_23();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
install.install();
|
||||||
|
}, "application/x-xpinstall");
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_test_23() {
|
||||||
|
AddonManager.getAllInstalls(function(installs) {
|
||||||
|
// There should be no active installs now since the install completed and
|
||||||
|
// doesn't require a restart.
|
||||||
|
do_check_eq(installs.length, 0);
|
||||||
|
|
||||||
|
AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
|
||||||
|
do_check_neq(b1, null);
|
||||||
|
do_check_eq(b1.version, "1.0");
|
||||||
|
do_check_false(b1.appDisabled);
|
||||||
|
do_check_false(b1.userDisabled);
|
||||||
|
do_check_true(b1.isActive);
|
||||||
|
do_check_eq(getInstalledVersion(), 1);
|
||||||
|
do_check_eq(getActiveVersion(), 1);
|
||||||
|
do_check_eq(getStartupReason(), ADDON_INSTALL);
|
||||||
|
do_check_true(b1.hasResource("install.rdf"));
|
||||||
|
do_check_true(b1.hasResource("bootstrap.js"));
|
||||||
|
do_check_false(b1.hasResource("foo.bar"));
|
||||||
|
do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
|
||||||
|
|
||||||
|
let dir = do_get_addon_root_uri(profileDir, "bootstrap1@tests.mozilla.org");
|
||||||
|
do_check_eq(b1.getResourceURI("bootstrap.js").spec, dir + "bootstrap.js");
|
||||||
|
|
||||||
|
AddonManager.getAddonsWithOperationsByTypes(null, function(list) {
|
||||||
|
do_check_eq(list.length, 0);
|
||||||
|
|
||||||
|
testserver.stop(do_test_finished);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user