Bug 591465 - Context menu of add-ons miss context related state change entries. r=dtownsend, a=blocking-beta6

This commit is contained in:
Blair McBride 2010-09-03 16:41:06 +12:00
Родитель a9bb380e43
Коммит a1f6ff98e3
7 изменённых файлов: 392 добавлений и 10 удалений

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

@ -65,6 +65,10 @@
<!ENTITY cmd.enableAddon.accesskey "E">
<!ENTITY cmd.disableAddon.label "Disable">
<!ENTITY cmd.disableAddon.accesskey "D">
<!ENTITY cmd.enableTheme.label "Wear Theme">
<!ENTITY cmd.enableTheme.accesskey "W">
<!ENTITY cmd.disableTheme.label "Stop Wearing Theme">
<!ENTITY cmd.disableTheme.accesskey "W">
<!ENTITY cmd.installAddon.label "Install">
<!ENTITY cmd.installAddon.accesskey "I">
<!ENTITY cmd.uninstallAddon.label "Remove">

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

@ -87,6 +87,17 @@ xhtml|link {
-moz-binding: url("chrome://mozapps/content/extensions/extensions.xml#detail-row");
}
#addonitem-popup > menuitem[disabled="true"] {
display: none;
}
#addonitem-popup[addontype="theme"] > #menuitem_enableItem,
#addonitem-popup[addontype="theme"] > #menuitem_disableItem,
#addonitem-popup:not([addontype="theme"]) > #menuitem_enableTheme,
#addonitem-popup:not([addontype="theme"]) > #menuitem_disableTheme {
display: none;
}
#header-searching:not([active]) {
visibility: hidden;
}

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

@ -177,6 +177,12 @@ var gEventManager = {
Services.prefs.addObserver(PREF_CHECK_UPDATE_SECURITY, this, false);
this.refreshGlobalWarning();
var contextMenu = document.getElementById("addonitem-popup");
contextMenu.addEventListener("popupshowing", function() {
var addon = gViewController.currentViewObj.getSelectedAddon();
contextMenu.setAttribute("addontype", addon.type);
}, false);
},
shutdown: function() {
@ -762,13 +768,14 @@ var gViewController = {
return aAddon.install && aAddon.install.state == AddonManager.STATE_AVAILABLE;
},
doCommand: function(aAddon) {
// This case should never happen
if (gViewController.currentViewObj != gDetailView)
return;
gViewController.popState(function() {
function doInstall() {
gViewController.currentViewObj.getListItemForID(aAddon.id)._installStatus.installRemote();
});
}
if (gViewController.currentViewObj == gDetailView)
gViewController.popState(doInstall);
else
doInstall();
}
},

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

@ -67,9 +67,24 @@
<menuitem id="menuitem_showDetails" command="cmd_showItemDetails"
default="true" label="&cmd.showDetails.label;"
accesskey="&cmd.showDetails.accesskey;"/>
<menuitem id="menuitem_findUpdates" command="cmd_findItemUpdates"
label="&cmd.findUpdates.label;"
accesskey="&cmd.findUpdates.accesskey;"/>
<menuitem id="menuitem_enableItem" command="cmd_enableItem"
label="&cmd.enableAddon.label;"
accesskey="&cmd.enableAddon.accesskey;"/>
<menuitem id="menuitem_disableItem" command="cmd_disableItem"
label="&cmd.disableAddon.label;"
accesskey="&cmd.disableAddon.accesskey;"/>
<menuitem id="menuitem_enableTheme" command="cmd_enableItem"
label="&cmd.enableTheme.label;"
accesskey="&cmd.enableTheme.accesskey;"/>
<menuitem id="menuitem_disableTheme" command="cmd_disableItem"
label="&cmd.disableTheme.label;"
accesskey="&cmd.disableTheme.accesskey;"/>
<menuitem id="menuitem_installItem" command="cmd_installItem"
label="&cmd.installAddon.label;"
accesskey="&cmd.installAddon.accesskey;"/>
<menuitem id="menuitem_uninstallItem" command="cmd_uninstallItem"
label="&cmd.uninstallAddon.label;"
accesskey="&cmd.uninstallAddon.accesskey;"/>
<menuseparator/>
<menuitem id="menuitem_preferences" command="cmd_showItemPreferences"
#ifdef XP_WIN
@ -79,6 +94,9 @@
label="&cmd.preferencesUnix.label;"
accesskey="&cmd.preferencesUnix.accesskey;"/>
#endif
<menuitem id="menuitem_findUpdates" command="cmd_findItemUpdates"
label="&cmd.findUpdates.label;"
accesskey="&cmd.findUpdates.accesskey;"/>
<menuitem id="menuitem_about" command="cmd_showItemAbout"
label="&cmd.about.label;"
accesskey="&cmd.about.accesskey;"/>
@ -378,7 +396,7 @@
<label value="&loading.label;"/>
</hbox>
<!-- actual detail view -->
<vbox class="detail-view-container" flex="3">
<vbox class="detail-view-container" flex="3" contextmenu="addonitem-popup">
<vbox id="detail-notifications">
<hbox id="warning-container" align="center" class="warning">
<image class="warning-icon"/>

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

@ -61,6 +61,8 @@ _TEST_FILES = \
browser_bug572561.js \
browser_bug577990.js \
browser_bug581076.js \
browser_bug591465.js \
browser_bug591465.xml \
browser_details.js \
browser_dragdrop.js \
browser_list.js \

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

@ -0,0 +1,311 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Bug 591465 - Context menu of add-ons miss context related state change entries
const PREF_GETADDONS_MAXRESULTS = "extensions.getAddons.maxResults";
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
const SEARCH_URL = TESTROOT + "browser_bug591465.xml";
const SEARCH_QUERY = "SEARCH";
var gManagerWindow;
var gProvider;
var gContextMenu;
function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "addon 1",
version: "1.0"
}, {
id: "addon2@tests.mozilla.org",
name: "addon 2",
version: "1.0",
_userDisabled: true
}, {
id: "theme1@tests.mozilla.org",
name: "theme 1",
version: "1.0",
type: "theme"
}, {
id: "theme2@tests.mozilla.org",
name: "theme 2",
version: "1.0",
type: "theme",
_userDisabled: true
}]);
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gContextMenu = aWindow.document.getElementById("addonitem-popup");
run_next_test();
});
}
function end_test() {
Services.prefs.clearUserPref(PREF_GETADDONS_GETSEARCHRESULTS);
close_manager(gManagerWindow, finish);
}
function check_contextmenu(aIsTheme, aIsEnabled, aIsRemote) {
if (aIsTheme || aIsEnabled || aIsRemote)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_enableItem"),
"'Enable' should be hidden");
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_enableItem"),
"'Enable' should be visible");
if (aIsTheme || !aIsEnabled || aIsRemote)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_disableItem"),
"'Disable' should be hidden");
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_disableItem"),
"'Disable' should be visible");
if (!aIsTheme || aIsEnabled || aIsRemote)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_enableTheme"),
"'Wear Theme' should be hidden");
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_enableTheme"),
"'Wear Theme' should be visible");
if (!aIsTheme || !aIsEnabled || aIsRemote)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_disableTheme"),
"'Stop Wearing Theme' should be hidden");
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_disableTheme"),
"'Stop Wearing Theme' should be visible");
if (aIsRemote)
is_element_visible(gManagerWindow.document.getElementById("menuitem_installItem"),
"'Install' should be visible");
else
is_element_hidden(gManagerWindow.document.getElementById("menuitem_installItem"),
"'Install' should be hidden");
}
add_test(function() {
var el = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
isnot(el, null, "Should have found addon element");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on enabled extension item");
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
add_test(function() {
var el = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on disabled extension item");
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
add_test(function() {
gManagerWindow.loadView("addons://list/theme");
wait_for_view_load(gManagerWindow, function() {
var el = get_addon_element(gManagerWindow, "theme1@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on enabled theme item");
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
});
add_test(function() {
var el = get_addon_element(gManagerWindow, "theme2@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, false, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on disabled theme item");
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() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on enabled extension, 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/addon2@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on disabled extension, 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/theme1@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on enabled 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/theme2@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, false, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on disabled 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() {
info("Searching for remote addons");
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
var searchBox = gManagerWindow.document.getElementById("header-search");
searchBox.value = SEARCH_QUERY;
EventUtils.synthesizeMouse(searchBox, 2, 2, { }, gManagerWindow);
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
var filter = gManagerWindow.document.getElementById("search-filter-remote");
EventUtils.synthesizeMouse(filter, 2, 2, { }, gManagerWindow);
executeSoon(function() {
var el = get_addon_element(gManagerWindow, "remote1@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, true);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on remote extension item");
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
});
});
add_test(function() {
gManagerWindow.loadView("addons://detail/remote1@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, true);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on remote extension, 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);
});
});

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

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<searchresults total_results="100">
<addon>
<name>MAGICAL SEARCH RESULT</name>
<type id='1'>Extension</type>
<guid>remote1@tests.mozilla.org</guid>
<version>3.0</version>
<authors>
<author>
<name>Test Creator</name>
<link>http://example.com/creator.html</link>
</author>
</authors>
<status id='4'>Public</status>
<summary>Test summary - SEARCH SEARCH</summary>
<description>Test description</description>
<compatible_applications>
<application>
<name>Firefox</name>
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
<min_version>0</min_version>
<max_version>*</max_version>
</application>
</compatible_applications>
<compatible_os>ALL</compatible_os>
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_searching.xpi</install>
</addon>
</searchresults>