1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_bug573062.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +function test() { 1.9 + waitForExplicitFinish(); 1.10 + 1.11 + var gProvider = new MockProvider(); 1.12 + let perms = AddonManager.PERM_CAN_UNINSTALL | 1.13 + AddonManager.PERM_CAN_ENABLE | AddonManager.PERM_CAN_DISABLE; 1.14 + 1.15 + gProvider.createAddons([{ 1.16 + id: "restart-enable-disable@tests.mozilla.org", 1.17 + name: "restart-enable-disable", 1.18 + description: "foo", 1.19 + permissions: perms, 1.20 + operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_ENABLE | 1.21 + AddonManager.OP_NEEDS_RESTART_DISABLE 1.22 + }, 1.23 + { 1.24 + id: "restart-uninstall@tests.mozilla.org", 1.25 + name: "restart-uninstall", 1.26 + description: "foo", 1.27 + permissions: perms, 1.28 + operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL 1.29 + }, 1.30 + { 1.31 + id: "no-restart-required@tests.mozilla.org", 1.32 + name: "no-restart-required", 1.33 + description: "bar", 1.34 + permissions: perms, 1.35 + operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE 1.36 + }]); 1.37 + 1.38 + open_manager("addons://list/extension", function(aWindow) { 1.39 + let addonList = aWindow.document.getElementById("addon-list"); 1.40 + let ed_r_Item, un_r_Item, no_r_Item; 1.41 + for (let addonItem of addonList.childNodes) { 1.42 + let name = addonItem.getAttribute("name"); 1.43 + switch (name) { 1.44 + case "restart-enable-disable": 1.45 + ed_r_Item = addonItem; 1.46 + break; 1.47 + case "restart-uninstall": 1.48 + un_r_Item = addonItem; 1.49 + break; 1.50 + case "no-restart-required": 1.51 + no_r_Item = addonItem; 1.52 + break; 1.53 + } 1.54 + } 1.55 + 1.56 + // Check the buttons in the list view. 1.57 + function checkTooltips(aItem, aEnable, aDisable, aRemove) { 1.58 + ok(aItem._enableBtn.getAttribute("tooltiptext") == aEnable); 1.59 + ok(aItem._disableBtn.getAttribute("tooltiptext") == aDisable); 1.60 + ok(aItem._removeBtn.getAttribute("tooltiptext") == aRemove); 1.61 + } 1.62 + 1.63 + let strs = aWindow.gStrings.ext; 1.64 + addonList.selectedItem = ed_r_Item; 1.65 + let ed_args = [ed_r_Item, 1.66 + strs.GetStringFromName("enableAddonRestartRequiredTooltip"), 1.67 + strs.GetStringFromName("disableAddonRestartRequiredTooltip"), 1.68 + strs.GetStringFromName("uninstallAddonTooltip")]; 1.69 + checkTooltips.apply(null, ed_args); 1.70 + 1.71 + addonList.selectedItem = un_r_Item; 1.72 + let un_args = [un_r_Item, 1.73 + strs.GetStringFromName("enableAddonTooltip"), 1.74 + strs.GetStringFromName("disableAddonTooltip"), 1.75 + strs.GetStringFromName("uninstallAddonRestartRequiredTooltip")]; 1.76 + checkTooltips.apply(null, un_args); 1.77 + 1.78 + addonList.selectedItem = no_r_Item; 1.79 + let no_args = [no_r_Item, 1.80 + strs.GetStringFromName("enableAddonTooltip"), 1.81 + strs.GetStringFromName("disableAddonTooltip"), 1.82 + strs.GetStringFromName("uninstallAddonTooltip")]; 1.83 + checkTooltips.apply(null, no_args) 1.84 + 1.85 + // Check the buttons in the details view. 1.86 + function checkTooltips2(aItem, aEnable, aDisable, aRemove) { 1.87 + let detailEnable = aWindow.document.getElementById("detail-enable-btn"); 1.88 + let detailDisable = aWindow.document.getElementById("detail-disable-btn"); 1.89 + let detailUninstall = aWindow.document.getElementById("detail-uninstall-btn"); 1.90 + ok(detailEnable.getAttribute("tooltiptext") == aEnable); 1.91 + ok(detailDisable.getAttribute("tooltiptext") == aDisable); 1.92 + ok(detailUninstall.getAttribute("tooltiptext") == aRemove); 1.93 + } 1.94 + 1.95 + function showInDetailView(aAddonId) { 1.96 + aWindow.gViewController.loadView("addons://detail/" + 1.97 + aWindow.encodeURIComponent(aAddonId)); 1.98 + } 1.99 + 1.100 + // enable-disable: 1.101 + showInDetailView("restart-enable-disable@tests.mozilla.org"); 1.102 + wait_for_view_load(aWindow, function() { 1.103 + checkTooltips2.apply(null, ed_args); 1.104 + // uninstall: 1.105 + showInDetailView("restart-uninstall@tests.mozilla.org"); 1.106 + wait_for_view_load(aWindow, function() { 1.107 + checkTooltips2.apply(null, un_args); 1.108 + // no restart: 1.109 + showInDetailView("no-restart-required@tests.mozilla.org"); 1.110 + wait_for_view_load(aWindow, function() { 1.111 + checkTooltips2.apply(null, no_args); 1.112 + aWindow.close(); 1.113 + finish(); 1.114 + }); 1.115 + }); 1.116 + }); 1.117 + 1.118 + }); 1.119 +}