mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 611559 - Backgrounds never have PERM_CAN_DISABLE, even when they can be disabled; r,a=Mossop
This commit is contained in:
parent
c0dfc07fb4
commit
87196854cb
@ -87,10 +87,11 @@ __defineSetter__("_maxUsedThemes", function(aVal) {
|
||||
return this._maxUsedThemes = aVal;
|
||||
});
|
||||
|
||||
// Holds the ID of the theme being enabled while sending out the events so
|
||||
// cached AddonWrapper instances can return correct values for permissions and
|
||||
// pendingOperations
|
||||
// Holds the ID of the theme being enabled or disabled while sending out the
|
||||
// events so cached AddonWrapper instances can return correct values for
|
||||
// permissions and pendingOperations
|
||||
var _themeIDBeingEnabled = null;
|
||||
var _themeIDBeingDisbled = null;
|
||||
|
||||
var LightweightThemeManager = {
|
||||
get usedThemes () {
|
||||
@ -330,6 +331,7 @@ var LightweightThemeManager = {
|
||||
if (current) {
|
||||
if (current.id == id)
|
||||
return;
|
||||
_themeIDBeingDisbled = current.id;
|
||||
let wrapper = new AddonWrapper(current);
|
||||
if (aPendingRestart) {
|
||||
Services.prefs.setCharPref(PREF_LWTHEME_TO_SELECT, "");
|
||||
@ -340,6 +342,7 @@ var LightweightThemeManager = {
|
||||
this.themeChanged(null);
|
||||
AddonManagerPrivate.callAddonListeners("onDisabled", wrapper);
|
||||
}
|
||||
_themeIDBeingDisbled = null;
|
||||
}
|
||||
|
||||
if (id) {
|
||||
@ -477,12 +480,16 @@ function AddonWrapper(aTheme) {
|
||||
let permissions = AddonManager.PERM_CAN_UNINSTALL;
|
||||
if (this.userDisabled)
|
||||
permissions |= AddonManager.PERM_CAN_ENABLE;
|
||||
else
|
||||
permissions |= AddonManager.PERM_CAN_DISABLE;
|
||||
return permissions;
|
||||
});
|
||||
|
||||
this.__defineGetter__("userDisabled", function() {
|
||||
if (_themeIDBeingEnabled == aTheme.id)
|
||||
return false;
|
||||
if (_themeIDBeingDisbled == aTheme.id)
|
||||
return true;
|
||||
|
||||
try {
|
||||
let toSelect = Services.prefs.getCharPref(PREF_LWTHEME_TO_SELECT);
|
||||
|
@ -4,6 +4,10 @@
|
||||
|
||||
// Bug 591465 - Context menu of add-ons miss context related state change entries
|
||||
|
||||
|
||||
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm");
|
||||
|
||||
|
||||
const PREF_GETADDONS_MAXRESULTS = "extensions.getAddons.maxResults";
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const SEARCH_URL = TESTROOT + "browser_bug591465.xml";
|
||||
@ -12,6 +16,18 @@ const SEARCH_QUERY = "SEARCH";
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
var gContextMenu;
|
||||
var gLWTheme = {
|
||||
id: "4",
|
||||
version: "1",
|
||||
name: "Bling",
|
||||
description: "SO MUCH BLING!",
|
||||
author: "Pixel Pusher",
|
||||
homepageURL: "http://localhost:4444/data/index.html",
|
||||
headerURL: "http://localhost:4444/data/header.png",
|
||||
footerURL: "http://localhost:4444/data/footer.png",
|
||||
previewURL: "http://localhost:4444/data/preview.png",
|
||||
iconURL: "http://localhost:4444/data/icon.png"
|
||||
};
|
||||
|
||||
|
||||
function test() {
|
||||
@ -47,6 +63,7 @@ function test() {
|
||||
permissions: 0
|
||||
}]);
|
||||
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gContextMenu = aWindow.document.getElementById("addonitem-popup");
|
||||
@ -227,6 +244,96 @@ add_test(function() {
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
LightweightThemeManager.currentTheme = gLWTheme;
|
||||
|
||||
var el = get_addon_element(gManagerWindow, "4@personas.mozilla.org");
|
||||
|
||||
gContextMenu.addEventListener("popupshown", function() {
|
||||
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
check_contextmenu(true, true, false, false, false);
|
||||
|
||||
gContextMenu.hidePopup();
|
||||
run_next_test();
|
||||
}, false);
|
||||
|
||||
info("Opening context menu on enabled LW theme item");
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
LightweightThemeManager.currentTheme = null;
|
||||
|
||||
var el = get_addon_element(gManagerWindow, "4@personas.mozilla.org");
|
||||
|
||||
gContextMenu.addEventListener("popupshown", function() {
|
||||
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
check_contextmenu(true, false, false, false, false);
|
||||
|
||||
gContextMenu.hidePopup();
|
||||
run_next_test();
|
||||
}, false);
|
||||
|
||||
info("Opening context menu on disabled LW theme item");
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
LightweightThemeManager.currentTheme = gLWTheme;
|
||||
|
||||
gManagerWindow.loadView("addons://detail/4@personas.mozilla.org");
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
|
||||
gContextMenu.addEventListener("popupshown", function() {
|
||||
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
check_contextmenu(true, true, false, true, false);
|
||||
|
||||
gContextMenu.hidePopup();
|
||||
run_next_test();
|
||||
}, false);
|
||||
|
||||
info("Opening context menu on enabled LW theme, in detail view");
|
||||
var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
LightweightThemeManager.currentTheme = null;
|
||||
|
||||
gManagerWindow.loadView("addons://detail/4@personas.mozilla.org");
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
|
||||
gContextMenu.addEventListener("popupshown", function() {
|
||||
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
check_contextmenu(true, false, false, true, false);
|
||||
|
||||
gContextMenu.hidePopup();
|
||||
|
||||
AddonManager.getAddonByID("4@personas.mozilla.org", function(aAddon) {
|
||||
aAddon.uninstall();
|
||||
run_next_test();
|
||||
});
|
||||
}, false);
|
||||
|
||||
info("Opening context menu on disabled LW theme, in detail view");
|
||||
var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
gManagerWindow.loadView("addons://detail/addon1@tests.mozilla.org");
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
// Tests the list view
|
||||
|
||||
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm");
|
||||
|
||||
|
||||
var gProvider;
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
@ -14,6 +17,20 @@ var gBlocklistURL = Services.urlFormatter.formatURLPref("extensions.blocklist.de
|
||||
var gPluginURL = Services.urlFormatter.formatURLPref("plugins.update.url");
|
||||
var gDate = new Date(2010, 7, 16);
|
||||
|
||||
var gLWTheme = {
|
||||
id: "4",
|
||||
version: "1",
|
||||
name: "Bling",
|
||||
description: "SO MUCH BLING!",
|
||||
author: "Pixel Pusher",
|
||||
homepageURL: "http://localhost:4444/data/index.html",
|
||||
headerURL: "http://localhost:4444/data/header.png",
|
||||
footerURL: "http://localhost:4444/data/footer.png",
|
||||
previewURL: "http://localhost:4444/data/preview.png",
|
||||
iconURL: "http://localhost:4444/data/icon.png"
|
||||
};
|
||||
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
@ -629,3 +646,32 @@ add_test(function() {
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
info("Enabling lightweight theme");
|
||||
LightweightThemeManager.currentTheme = gLWTheme;
|
||||
|
||||
gManagerWindow.loadView("addons://list/theme");
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
var addon = get_addon_element(gManagerWindow, "4@personas.mozilla.org");
|
||||
|
||||
is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
|
||||
is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
|
||||
is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
|
||||
is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
|
||||
|
||||
info("Disabling lightweight theme");
|
||||
LightweightThemeManager.currentTheme = null;
|
||||
|
||||
is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
|
||||
is_element_visible(get_node(addon, "enable-btn"), "Enable button should be hidden");
|
||||
is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be visible");
|
||||
is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
|
||||
|
||||
AddonManager.getAddonByID("4@personas.mozilla.org", function(aAddon) {
|
||||
aAddon.uninstall();
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -258,7 +258,7 @@ function run_test_3() {
|
||||
do_check_eq(p1.blocklistState, 0);
|
||||
do_check_true(p1.isActive);
|
||||
do_check_eq(p1.pendingOperations, 0);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_DISABLE);
|
||||
do_check_eq(p1.scope, AddonManager.SCOPE_PROFILE);
|
||||
do_check_true("isCompatibleWith" in p1);
|
||||
do_check_true("findUpdates" in p1);
|
||||
@ -324,14 +324,14 @@ function run_test_4() {
|
||||
do_check_false(p2.userDisabled);
|
||||
do_check_true(p2.isActive);
|
||||
do_check_eq(p2.pendingOperations, 0);
|
||||
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
||||
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_DISABLE);
|
||||
|
||||
do_check_neq(null, p1);
|
||||
do_check_false(p1.appDisabled);
|
||||
do_check_true(p1.userDisabled);
|
||||
do_check_false(p1.isActive);
|
||||
do_check_eq(p1.pendingOperations, 0);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_ENABLE);
|
||||
|
||||
AddonManager.getAddonsByTypes(["theme"], function(addons) {
|
||||
let seen = false;
|
||||
|
@ -273,7 +273,7 @@ function run_test_3() {
|
||||
do_check_eq(p1.blocklistState, 0);
|
||||
do_check_true(p1.isActive);
|
||||
do_check_eq(p1.pendingOperations, 0);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_DISABLE);
|
||||
do_check_eq(p1.scope, AddonManager.SCOPE_PROFILE);
|
||||
do_check_true("isCompatibleWith" in p1);
|
||||
do_check_true("findUpdates" in p1);
|
||||
@ -347,7 +347,7 @@ function run_test_4() {
|
||||
do_check_false(p2.userDisabled);
|
||||
do_check_true(p2.isActive);
|
||||
do_check_eq(p2.pendingOperations, 0);
|
||||
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
||||
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_DISABLE);
|
||||
do_check_eq(p2.installDate.getTime(), p2.updateDate.getTime());
|
||||
|
||||
// Should have been installed sometime in the last few seconds.
|
||||
@ -362,7 +362,7 @@ function run_test_4() {
|
||||
do_check_true(p1.userDisabled);
|
||||
do_check_false(p1.isActive);
|
||||
do_check_eq(p1.pendingOperations, 0);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE);
|
||||
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL | AddonManager.PERM_CAN_ENABLE);
|
||||
|
||||
AddonManager.getAddonsByTypes(["theme"], function(addons) {
|
||||
let seen = false;
|
||||
|
Loading…
Reference in New Issue
Block a user