mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 744833: Rebuild the bootstrapped add-ons list when the profile moves to a different directory. r=Unfocused
This commit is contained in:
parent
d38b916352
commit
46aef94182
@ -2396,6 +2396,12 @@ var XPIProvider = {
|
||||
if (aOldAddon.visible) {
|
||||
visibleAddons[aOldAddon.id] = aOldAddon;
|
||||
|
||||
if (aOldAddon.bootstrap) {
|
||||
let bootstrap = oldBootstrappedAddons[aOldAddon.id];
|
||||
bootstrap.descriptor = aAddonState.descriptor;
|
||||
XPIProvider.bootstrappedAddons[aOldAddon.id] = bootstrap;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
9
toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js
vendored
Normal file
9
toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function startup(data, reason) {
|
||||
Services.prefs.setIntPref("bootstraptest.active_version", 1);
|
||||
}
|
||||
|
||||
function shutdown(data, reason) {
|
||||
Services.prefs.setIntPref("bootstraptest.active_version", 0);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?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>addon2@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
<em:name>Test 2</em:name>
|
||||
<em:bootstrap>true</em:bootstrap>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>2</em:minVersion>
|
||||
<em:maxVersion>2</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</RDF>
|
@ -664,6 +664,67 @@ function setExtensionModifiedTime(aExt, aTime) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually installs an XPI file into an install location by either copying the
|
||||
* XPI there or extracting it depending on whether unpacking is being tested
|
||||
* or not.
|
||||
*
|
||||
* @param aXPIFile
|
||||
* The XPI file to install.
|
||||
* @param aInstallLocation
|
||||
* The install location (an nsIFile) to install into.
|
||||
* @param aID
|
||||
* The ID to install as.
|
||||
*/
|
||||
function manuallyInstall(aXPIFile, aInstallLocation, aID) {
|
||||
if (TEST_UNPACKED) {
|
||||
let dir = aInstallLocation.clone();
|
||||
dir.append(aID);
|
||||
dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
|
||||
createInstance(AM_Ci.nsIZipReader);
|
||||
zip.open(aXPIFile);
|
||||
let entries = zip.findEntries(null);
|
||||
while (entries.hasMore()) {
|
||||
let entry = entries.getNext();
|
||||
let target = dir.clone();
|
||||
entry.split("/").forEach(function(aPart) {
|
||||
target.append(aPart);
|
||||
});
|
||||
zip.extract(entry, target);
|
||||
}
|
||||
zip.close();
|
||||
|
||||
return dir;
|
||||
}
|
||||
else {
|
||||
let target = aInstallLocation.clone();
|
||||
target.append(aID + ".xpi");
|
||||
aXPIFile.copyTo(target.parent, target.leafName);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually uninstalls an add-on by removing its files from the install
|
||||
* location.
|
||||
*
|
||||
* @param aInstallLocation
|
||||
* The nsIFile of the install location to remove from.
|
||||
* @param aID
|
||||
* The ID of the add-on to remove.
|
||||
*/
|
||||
function manuallyUninstall(aInstallLocation, aID) {
|
||||
let file = getFileForAddon(aInstallLocation, aID);
|
||||
|
||||
// In reality because the app is restarted a flush isn't necessary for XPIs
|
||||
// removed outside the app, but for testing we must flush manually.
|
||||
if (file.isFile())
|
||||
Services.obs.notifyObservers(file, "flush-cache-entry", null);
|
||||
|
||||
file.remove(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nsIFile for where an add-on is installed. It may point to a file or
|
||||
* a directory depending on whether add-ons are being installed unpacked or not.
|
||||
|
@ -81,46 +81,6 @@ function getUninstallReason() {
|
||||
return Services.prefs.getIntPref("bootstraptest.uninstall_reason");
|
||||
}
|
||||
|
||||
function manuallyInstall(aXPIFile, aInstallLocation, aID) {
|
||||
if (TEST_UNPACKED) {
|
||||
let dir = aInstallLocation.clone();
|
||||
dir.append(aID);
|
||||
dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
|
||||
createInstance(AM_Ci.nsIZipReader);
|
||||
zip.open(aXPIFile);
|
||||
let entries = zip.findEntries(null);
|
||||
while (entries.hasMore()) {
|
||||
let entry = entries.getNext();
|
||||
let target = dir.clone();
|
||||
entry.split("/").forEach(function(aPart) {
|
||||
target.append(aPart);
|
||||
});
|
||||
zip.extract(entry, target);
|
||||
}
|
||||
zip.close();
|
||||
|
||||
return dir;
|
||||
}
|
||||
else {
|
||||
let target = aInstallLocation.clone();
|
||||
target.append(aID + ".xpi");
|
||||
aXPIFile.copyTo(target.parent, target.leafName);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
function manuallyUninstall(aInstallLocation, aID) {
|
||||
let file = getFileForAddon(aInstallLocation, aID);
|
||||
|
||||
// In reality because the app is restarted a flush isn't necessary for XPIs
|
||||
// removed outside the app, but for testing we must flush manually.
|
||||
if (file.isFile())
|
||||
Services.obs.notifyObservers(file, "flush-cache-entry", null);
|
||||
|
||||
file.remove(true);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
|
||||
|
@ -58,14 +58,23 @@ function run_test() {
|
||||
var dir = writeInstallRDFForExtension(addon1, userDir);
|
||||
setExtensionModifiedTime(dir, time);
|
||||
|
||||
manuallyInstall(do_get_addon("test_bug655254_2"), userDir, "addon2@tests.mozilla.org");
|
||||
|
||||
startupManager();
|
||||
|
||||
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
|
||||
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org"], function([a1, a2]) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(a1.appDisabled);
|
||||
do_check_false(a1.isActive);
|
||||
do_check_false(isExtensionInAddonsList(userDir, a1.id));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_false(a2.appDisabled);
|
||||
do_check_true(a2.isActive);
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
|
||||
|
||||
a1.findUpdates({
|
||||
onUpdateFinished: function() {
|
||||
restartManager();
|
||||
@ -78,6 +87,8 @@ function run_test() {
|
||||
|
||||
shutdownManager();
|
||||
|
||||
do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
|
||||
|
||||
userDir.parent.moveTo(gProfD, "extensions3");
|
||||
userDir = gProfD.clone();
|
||||
userDir.append("extensions3");
|
||||
@ -86,12 +97,19 @@ function run_test() {
|
||||
|
||||
startupManager(false);
|
||||
|
||||
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
|
||||
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org"], function([a1, a2]) {
|
||||
do_check_neq(a1, null);
|
||||
do_check_false(a1.appDisabled);
|
||||
do_check_true(a1.isActive);
|
||||
do_check_true(isExtensionInAddonsList(userDir, a1.id));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_false(a2.appDisabled);
|
||||
do_check_true(a2.isActive);
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
|
||||
|
||||
testserver.stop(do_test_finished);
|
||||
});
|
||||
});
|
||||
|
@ -17,35 +17,6 @@ function getInstalledVersion() {
|
||||
return Services.prefs.getIntPref("bootstraptest.installed_version");
|
||||
}
|
||||
|
||||
function manuallyInstall(aXPIFile, aInstallLocation, aID) {
|
||||
if (TEST_UNPACKED) {
|
||||
let dir = aInstallLocation.clone();
|
||||
dir.append(aID);
|
||||
dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
|
||||
createInstance(AM_Ci.nsIZipReader);
|
||||
zip.open(aXPIFile);
|
||||
let entries = zip.findEntries(null);
|
||||
while (entries.hasMore()) {
|
||||
let entry = entries.getNext();
|
||||
let target = dir.clone();
|
||||
entry.split("/").forEach(function(aPart) {
|
||||
target.append(aPart);
|
||||
});
|
||||
zip.extract(entry, target);
|
||||
}
|
||||
zip.close();
|
||||
|
||||
return dir;
|
||||
}
|
||||
else {
|
||||
let target = aInstallLocation.clone();
|
||||
target.append(aID + ".xpi");
|
||||
aXPIFile.copyTo(target.parent, target.leafName);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user