mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 628703: Should not pass the ID of add-ons that have opted out of metadata pings to the discovery view.r=Unfocused, a=blocks-final
This commit is contained in:
parent
f025e0d6f8
commit
2721ad7a0a
@ -54,6 +54,7 @@ const PREF_BACKGROUND_UPDATE = "extensions.update.enabled";
|
||||
const PREF_CHECK_COMPATIBILITY = "extensions.checkCompatibility";
|
||||
const PREF_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
|
||||
const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
|
||||
const PREF_GETADDONS_CACHE_ENABLED = "extensions.%ID%.getAddons.cache.enabled";
|
||||
|
||||
const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi;
|
||||
|
||||
@ -1623,6 +1624,11 @@ var gDiscoverView = {
|
||||
AddonManager.getAllAddons(function(aAddons) {
|
||||
var list = {};
|
||||
aAddons.forEach(function(aAddon) {
|
||||
var prefName = PREF_GETADDONS_CACHE_ENABLED.replace("%ID%", aAddon.id);
|
||||
try {
|
||||
if (!Services.prefs.getBoolPref(prefName))
|
||||
return;
|
||||
} catch (e) { }
|
||||
list[aAddon.id] = {
|
||||
name: aAddon.name,
|
||||
version: aAddon.version,
|
||||
|
@ -100,7 +100,7 @@ function getHash(aBrowser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function testHash(aBrowser, aCallback) {
|
||||
function testHash(aBrowser, aTestAddonVisible, aCallback) {
|
||||
var hash = getHash(aBrowser);
|
||||
isnot(hash, null, "There should be a hash");
|
||||
try {
|
||||
@ -114,19 +114,31 @@ function testHash(aBrowser, aCallback) {
|
||||
is(typeof data, "object", "Hash should be a JS object");
|
||||
|
||||
// Ensure that at least the test add-ons are present
|
||||
ok("addon1@tests.mozilla.org" in data, "Test add-on 1 should be listed");
|
||||
ok("addon2@tests.mozilla.org" in data, "Test add-on 2 should be listed");
|
||||
ok("addon3@tests.mozilla.org" in data, "Test add-on 3 should be listed");
|
||||
if (aTestAddonVisible[0])
|
||||
ok("addon1@tests.mozilla.org" in data, "Test add-on 1 should be listed");
|
||||
else
|
||||
ok(!("addon1@tests.mozilla.org" in data), "Test add-on 1 should not be listed");
|
||||
if (aTestAddonVisible[1])
|
||||
ok("addon2@tests.mozilla.org" in data, "Test add-on 2 should be listed");
|
||||
else
|
||||
ok(!("addon2@tests.mozilla.org" in data), "Test add-on 2 should not be listed");
|
||||
if (aTestAddonVisible[2])
|
||||
ok("addon3@tests.mozilla.org" in data, "Test add-on 3 should be listed");
|
||||
else
|
||||
ok(!("addon3@tests.mozilla.org" in data), "Test add-on 3 should not be listed");
|
||||
|
||||
// Test against all the add-ons the manager knows about since plugins and
|
||||
// app extensions may exist
|
||||
AddonManager.getAllAddons(function(aAddons) {
|
||||
aAddons.forEach(function(aAddon) {
|
||||
info("Testing data for add-on " + aAddon.id);
|
||||
if (!aAddon.id in data) {
|
||||
ok(false, "Add-on was not included in the data");
|
||||
if (!(aAddon.id in data)) {
|
||||
// Test add-ons will have shown an error if necessary above
|
||||
if (aAddon.id.substring(6) != "@tests.mozilla.org")
|
||||
ok(false, "Add-on " + aAddon.id + " was not included in the data");
|
||||
return;
|
||||
}
|
||||
|
||||
info("Testing data for add-on " + aAddon.id);
|
||||
var addonData = data[aAddon.id];
|
||||
is(addonData.name, aAddon.name, "Name should be correct");
|
||||
is(addonData.version, aAddon.version, "Version should be correct");
|
||||
@ -178,7 +190,7 @@ add_test(function() {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
testHash(browser, function() {
|
||||
testHash(browser, [true, true, true], function() {
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
});
|
||||
@ -190,6 +202,10 @@ add_test(function() {
|
||||
// Tests that loading the add-ons manager with the discovery view as the last
|
||||
// selected view displays the right url
|
||||
add_test(function() {
|
||||
// Hide one of the test add-ons
|
||||
Services.prefs.setBoolPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled", false);
|
||||
Services.prefs.setBoolPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled", true);
|
||||
|
||||
open_manager(null, function(aWindow) {
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
is(gCategoryUtilities.selectedCategory, "discover", "Should have loaded the right view");
|
||||
@ -197,7 +213,7 @@ add_test(function() {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
testHash(browser, function() {
|
||||
testHash(browser, [true, false, true], function() {
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
}, function(aWindow) {
|
||||
@ -209,6 +225,9 @@ add_test(function() {
|
||||
// Tests that loading the add-ons manager with the discovery view as the initial
|
||||
// view displays the right url
|
||||
add_test(function() {
|
||||
Services.prefs.clearUserPref("extensions.addon2@tests.mozilla.org.getAddons.cache.enabled");
|
||||
Services.prefs.setBoolPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled", false);
|
||||
|
||||
open_manager(null, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
@ -221,7 +240,8 @@ add_test(function() {
|
||||
var browser = gManagerWindow.document.getElementById("discover-browser");
|
||||
is(getURL(browser), MAIN_URL, "Should have loaded the right url");
|
||||
|
||||
testHash(browser, function() {
|
||||
testHash(browser, [true, true, false], function() {
|
||||
Services.prefs.clearUserPref("extensions.addon3@tests.mozilla.org.getAddons.cache.enabled");
|
||||
close_manager(gManagerWindow, run_next_test);
|
||||
});
|
||||
}, function(aWindow) {
|
||||
|
Loading…
Reference in New Issue
Block a user