Bug 630575: Properly distinguish soft and hard blocked items in the update pings. r=Unfocused, a=gavin

This commit is contained in:
Dave Townsend 2011-02-10 10:34:55 -08:00
Родитель e1af8052db
Коммит 26ddd470a8
4 изменённых файлов: 133 добавлений и 2 удалений

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

@ -958,8 +958,10 @@ function escapeAddonURI(aAddon, aUri, aUpdateType, aAppVersion)
if (!aAddon.isCompatible)
addonStatus += ",incompatible";
if (aAddon.blocklistState > 0)
if (aAddon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED)
addonStatus += ",blocklisted";
if (aAddon.blocklistState == Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
addonStatus += ",softblocked";
try {
var xpcomABI = Services.appinfo.XPCOMABI;

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

@ -0,0 +1,30 @@
<?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>bug335238_3@tests.mozilla.org</em:id>
<em:version>58</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<em:requires>
<Description>
<em:id>unknown@tests.mozilla.org</em:id>
<em:minVersion>2</em:minVersion>
<em:maxVersion>72</em:maxVersion>
</Description>
</em:requires>
<em:name>Bug 335238</em:name>
<em:updateURL>http://localhost:4444/2?id=%ITEM_ID%&amp;version=%ITEM_VERSION%&amp;maxAppVersion=%ITEM_MAXAPPVERSION%&amp;status=%ITEM_STATUS%&amp;appId=%APP_ID%&amp;appVersion=%APP_VERSION%&amp;appOs=%APP_OS%&amp;appAbi=%APP_ABI%&amp;locale=%APP_LOCALE%&amp;reqVersion=%REQ_VERSION%</em:updateURL>
</Description>
</RDF>

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

@ -0,0 +1,30 @@
<?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>bug335238_4@tests.mozilla.org</em:id>
<em:version>4</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2+</em:maxVersion>
</Description>
</em:targetApplication>
<em:requires>
<Description>
<em:id>unknown@tests.mozilla.org</em:id>
<em:minVersion>2</em:minVersion>
<em:maxVersion>72</em:maxVersion>
</Description>
</em:requires>
<em:name>Bug 335238</em:name>
<em:updateURL>http://localhost:4444/3?id=%ITEM_ID%&amp;version=%ITEM_VERSION%&amp;maxAppVersion=%ITEM_MAXAPPVERSION%&amp;status=%ITEM_STATUS%&amp;appId=%APP_ID%&amp;appVersion=%APP_VERSION%&amp;appOs=%APP_OS%&amp;appAbi=%APP_ABI%&amp;locale=%APP_LOCALE%&amp;reqVersion=%REQ_VERSION%</em:updateURL>
</Description>
</RDF>

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

@ -69,6 +69,30 @@ var EXPECTED = [
appAbi: "noarch-spidermonkey",
locale: "en-US",
reqVersion: "2"
},
{
id: "bug335238_3@tests.mozilla.org",
version: "58",
maxAppVersion: "*",
status: "userDisabled,softblocked",
appId: "xpcshell@tests.mozilla.org",
appVersion: "1",
appOs: "XPCShell",
appAbi: "noarch-spidermonkey",
locale: "en-US",
reqVersion: "2"
},
{
id: "bug335238_4@tests.mozilla.org",
version: "4",
maxAppVersion: "2+",
status: "userEnabled,blocklisted",
appId: "xpcshell@tests.mozilla.org",
appVersion: "1",
appOs: "XPCShell",
appAbi: "noarch-spidermonkey",
locale: "en-US",
reqVersion: "2"
}
];
@ -76,9 +100,52 @@ var ADDONS = [
{id: "bug335238_1@tests.mozilla.org",
addon: "test_bug335238_1"},
{id: "bug335238_2@tests.mozilla.org",
addon: "test_bug335238_2"}
addon: "test_bug335238_2"},
{id: "bug335238_3@tests.mozilla.org",
addon: "test_bug335238_3"},
{id: "bug335238_4@tests.mozilla.org",
addon: "test_bug335238_4"}
];
// This is a replacement for the blocklist service
var BlocklistService = {
getAddonBlocklistState: function(aId, aVersion, aAppVersion, aToolkitVersion) {
if (aId == "bug335238_3@tests.mozilla.org")
return Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
if (aId == "bug335238_4@tests.mozilla.org")
return Ci.nsIBlocklistService.STATE_BLOCKED;
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
},
getPluginBlocklistState: function(aPlugin, aVersion, aAppVersion, aToolkitVersion) {
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
},
isAddonBlocklisted: function(aId, aVersion, aAppVersion, aToolkitVersion) {
return this.getAddonBlocklistState(aId, aVersion, aAppVersion, aToolkitVersion) ==
Ci.nsIBlocklistService.STATE_BLOCKED;
},
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsIBlocklistService)
|| iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
var BlocklistServiceFactory = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return BlocklistService.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{61189e7a-6b1b-44b8-ac81-f180a6105085}"), "BlocklistService",
"@mozilla.org/extensions/blocklist;1", BlocklistServiceFactory);
var server;
var updateListener = {
@ -117,6 +184,8 @@ function run_test() {
server = new nsHttpServer();
server.registerPathHandler("/0", requestHandler);
server.registerPathHandler("/1", requestHandler);
server.registerPathHandler("/2", requestHandler);
server.registerPathHandler("/3", requestHandler);
server.start(4444);
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false);