зеркало из https://github.com/mozilla/gecko-dev.git
Bug 595915: Download metadata for new add-ons when installed. r=robstrong, a=blocks-betaN
This commit is contained in:
Родитель
03af5fa2b0
Коммит
109b604504
|
@ -363,6 +363,8 @@ user_pref("app.update.enabled", false);
|
|||
// Only load extensions from the application and user profile
|
||||
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
|
||||
user_pref("extensions.enabledScopes", 5);
|
||||
// Disable metadata caching for installed add-ons by default
|
||||
user_pref("extensions.getAddons.cache.enabled", false);
|
||||
|
||||
user_pref("extensions.testpilot.runStudies", false);
|
||||
|
||||
|
|
|
@ -4562,6 +4562,25 @@ AddonInstall.prototype = {
|
|||
* XPI is incorrectly signed
|
||||
*/
|
||||
loadManifest: function AI_loadManifest(aCallback) {
|
||||
function addRepositoryData(aAddon) {
|
||||
// Try to load from the existing cache first
|
||||
AddonRepository.getCachedAddonByID(aAddon.id, function(aRepoAddon) {
|
||||
if (aRepoAddon) {
|
||||
aAddon._repositoryAddon = aRepoAddon;
|
||||
aCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
// It wasn't there so try to re-download it
|
||||
AddonRepository.cacheAddons([aAddon.id], function() {
|
||||
AddonRepository.getCachedAddonByID(aAddon.id, function(aRepoAddon) {
|
||||
aAddon._repositoryAddon = aRepoAddon;
|
||||
aCallback();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
|
||||
createInstance(Ci.nsIZipReader);
|
||||
try {
|
||||
|
@ -4599,7 +4618,10 @@ AddonInstall.prototype = {
|
|||
}
|
||||
|
||||
if (this.addon.type == "multipackage") {
|
||||
this.loadMultipackageManifests(zipreader, aCallback);
|
||||
let self = this;
|
||||
this.loadMultipackageManifests(zipreader, function() {
|
||||
addRepositoryData(self.addon);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4618,7 +4640,7 @@ AddonInstall.prototype = {
|
|||
//if (newIcon)
|
||||
// this.iconURL = newIcon;
|
||||
|
||||
aCallback();
|
||||
addRepositoryData(this.addon);
|
||||
},
|
||||
|
||||
observe: function AI_observe(aSubject, aTopic, aData) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="1">
|
||||
<addon>
|
||||
<name>Real Test 2</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon2@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Repository summary</summary>
|
||||
<description>Repository description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -1169,7 +1169,7 @@ function run_test_18() {
|
|||
a2.uninstall();
|
||||
restartManager();
|
||||
|
||||
end_test();
|
||||
run_test_19();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1181,3 +1181,57 @@ function run_test_18() {
|
|||
aInstall.install();
|
||||
}, "application/x-xpinstall");
|
||||
}
|
||||
|
||||
// Checks that metadata is downloaded for new installs and is visible before and
|
||||
// after restart
|
||||
function run_test_19() {
|
||||
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
|
||||
Services.prefs.setCharPref("extensions.getAddons.get.url",
|
||||
"http://localhost:4444/data/test_install.xml");
|
||||
|
||||
let url = "http://localhost:4444/addons/test_install2_1.xpi";
|
||||
AddonManager.getInstallForURL(url, function(aInstall) {
|
||||
aInstall.addListener({
|
||||
onInstallEnded: function(aInstall, aAddon) {
|
||||
do_check_eq(aAddon.fullDescription, "Repository description");
|
||||
|
||||
restartManager();
|
||||
|
||||
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_eq(a2.fullDescription, "Repository description");
|
||||
|
||||
a2.uninstall();
|
||||
restartManager();
|
||||
|
||||
run_test_20();
|
||||
});
|
||||
}
|
||||
});
|
||||
aInstall.install();
|
||||
}, "application/x-xpinstall");
|
||||
}
|
||||
|
||||
// Do the same again to make sure it works when the data is already in the cache
|
||||
function run_test_20() {
|
||||
let url = "http://localhost:4444/addons/test_install2_1.xpi";
|
||||
AddonManager.getInstallForURL(url, function(aInstall) {
|
||||
aInstall.addListener({
|
||||
onInstallEnded: function(aInstall, aAddon) {
|
||||
do_check_eq(aAddon.fullDescription, "Repository description");
|
||||
|
||||
restartManager();
|
||||
|
||||
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_eq(a2.fullDescription, "Repository description");
|
||||
|
||||
a2.uninstall();
|
||||
restartManager();
|
||||
|
||||
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", false);
|
||||
end_test();
|
||||
});
|
||||
}
|
||||
});
|
||||
aInstall.install();
|
||||
}, "application/x-xpinstall");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче