toolkit/mozapps/extensions/test/browser/browser_bug573062.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 function test() {
michael@0 6 waitForExplicitFinish();
michael@0 7
michael@0 8 var gProvider = new MockProvider();
michael@0 9 let perms = AddonManager.PERM_CAN_UNINSTALL |
michael@0 10 AddonManager.PERM_CAN_ENABLE | AddonManager.PERM_CAN_DISABLE;
michael@0 11
michael@0 12 gProvider.createAddons([{
michael@0 13 id: "restart-enable-disable@tests.mozilla.org",
michael@0 14 name: "restart-enable-disable",
michael@0 15 description: "foo",
michael@0 16 permissions: perms,
michael@0 17 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_ENABLE |
michael@0 18 AddonManager.OP_NEEDS_RESTART_DISABLE
michael@0 19 },
michael@0 20 {
michael@0 21 id: "restart-uninstall@tests.mozilla.org",
michael@0 22 name: "restart-uninstall",
michael@0 23 description: "foo",
michael@0 24 permissions: perms,
michael@0 25 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL
michael@0 26 },
michael@0 27 {
michael@0 28 id: "no-restart-required@tests.mozilla.org",
michael@0 29 name: "no-restart-required",
michael@0 30 description: "bar",
michael@0 31 permissions: perms,
michael@0 32 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
michael@0 33 }]);
michael@0 34
michael@0 35 open_manager("addons://list/extension", function(aWindow) {
michael@0 36 let addonList = aWindow.document.getElementById("addon-list");
michael@0 37 let ed_r_Item, un_r_Item, no_r_Item;
michael@0 38 for (let addonItem of addonList.childNodes) {
michael@0 39 let name = addonItem.getAttribute("name");
michael@0 40 switch (name) {
michael@0 41 case "restart-enable-disable":
michael@0 42 ed_r_Item = addonItem;
michael@0 43 break;
michael@0 44 case "restart-uninstall":
michael@0 45 un_r_Item = addonItem;
michael@0 46 break;
michael@0 47 case "no-restart-required":
michael@0 48 no_r_Item = addonItem;
michael@0 49 break;
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 // Check the buttons in the list view.
michael@0 54 function checkTooltips(aItem, aEnable, aDisable, aRemove) {
michael@0 55 ok(aItem._enableBtn.getAttribute("tooltiptext") == aEnable);
michael@0 56 ok(aItem._disableBtn.getAttribute("tooltiptext") == aDisable);
michael@0 57 ok(aItem._removeBtn.getAttribute("tooltiptext") == aRemove);
michael@0 58 }
michael@0 59
michael@0 60 let strs = aWindow.gStrings.ext;
michael@0 61 addonList.selectedItem = ed_r_Item;
michael@0 62 let ed_args = [ed_r_Item,
michael@0 63 strs.GetStringFromName("enableAddonRestartRequiredTooltip"),
michael@0 64 strs.GetStringFromName("disableAddonRestartRequiredTooltip"),
michael@0 65 strs.GetStringFromName("uninstallAddonTooltip")];
michael@0 66 checkTooltips.apply(null, ed_args);
michael@0 67
michael@0 68 addonList.selectedItem = un_r_Item;
michael@0 69 let un_args = [un_r_Item,
michael@0 70 strs.GetStringFromName("enableAddonTooltip"),
michael@0 71 strs.GetStringFromName("disableAddonTooltip"),
michael@0 72 strs.GetStringFromName("uninstallAddonRestartRequiredTooltip")];
michael@0 73 checkTooltips.apply(null, un_args);
michael@0 74
michael@0 75 addonList.selectedItem = no_r_Item;
michael@0 76 let no_args = [no_r_Item,
michael@0 77 strs.GetStringFromName("enableAddonTooltip"),
michael@0 78 strs.GetStringFromName("disableAddonTooltip"),
michael@0 79 strs.GetStringFromName("uninstallAddonTooltip")];
michael@0 80 checkTooltips.apply(null, no_args)
michael@0 81
michael@0 82 // Check the buttons in the details view.
michael@0 83 function checkTooltips2(aItem, aEnable, aDisable, aRemove) {
michael@0 84 let detailEnable = aWindow.document.getElementById("detail-enable-btn");
michael@0 85 let detailDisable = aWindow.document.getElementById("detail-disable-btn");
michael@0 86 let detailUninstall = aWindow.document.getElementById("detail-uninstall-btn");
michael@0 87 ok(detailEnable.getAttribute("tooltiptext") == aEnable);
michael@0 88 ok(detailDisable.getAttribute("tooltiptext") == aDisable);
michael@0 89 ok(detailUninstall.getAttribute("tooltiptext") == aRemove);
michael@0 90 }
michael@0 91
michael@0 92 function showInDetailView(aAddonId) {
michael@0 93 aWindow.gViewController.loadView("addons://detail/" +
michael@0 94 aWindow.encodeURIComponent(aAddonId));
michael@0 95 }
michael@0 96
michael@0 97 // enable-disable:
michael@0 98 showInDetailView("restart-enable-disable@tests.mozilla.org");
michael@0 99 wait_for_view_load(aWindow, function() {
michael@0 100 checkTooltips2.apply(null, ed_args);
michael@0 101 // uninstall:
michael@0 102 showInDetailView("restart-uninstall@tests.mozilla.org");
michael@0 103 wait_for_view_load(aWindow, function() {
michael@0 104 checkTooltips2.apply(null, un_args);
michael@0 105 // no restart:
michael@0 106 showInDetailView("no-restart-required@tests.mozilla.org");
michael@0 107 wait_for_view_load(aWindow, function() {
michael@0 108 checkTooltips2.apply(null, no_args);
michael@0 109 aWindow.close();
michael@0 110 finish();
michael@0 111 });
michael@0 112 });
michael@0 113 });
michael@0 114
michael@0 115 });
michael@0 116 }

mercurial