Bug 562890 - Preferences button for the add-on should be placed in the entry of the digest view. r=mossop

This commit is contained in:
Blair McBride 2010-06-24 11:35:21 +12:00
Родитель 134a41bc75
Коммит be9ad89c75
6 изменённых файлов: 87 добавлений и 4 удалений

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

@ -43,6 +43,8 @@
<!ENTITY cmd.uninstallAddon.label "Remove">
<!ENTITY cmd.uninstallAddon.accesskey "R">
<!ENTITY cmd.uninstallAddon.tooltip "Uninstall this add-on">
<!ENTITY cmd.showPreferences.label "Preferences">
<!ENTITY cmd.showPreferences.tooltip "Change this add-on's preferences">
<!ENTITY cmd.contribute.label "Contribute">
<!ENTITY cmd.contribute.accesskey "C">
<!ENTITY cmd.contribute.tooltip "Contribute to the development of this add-on">

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

@ -541,14 +541,15 @@ var gViewController = {
}
},
doCommand: function(aCommand) {
doCommand: function(aCommand, aAddon) {
if (!this.supportsCommand(aCommand))
return;
var addon = this.currentViewObj.getSelectedAddon();
var cmd = this.commands[aCommand];
if (!cmd.isEnabled(addon))
if (!aAddon)
aAddon = this.currentViewObj.getSelectedAddon();
if (!cmd.isEnabled(aAddon))
return;
cmd.doCommand(addon);
cmd.doCommand(aAddon);
},
onEvent: function() {}

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

@ -723,6 +723,10 @@
</xul:vbox>
<xul:spacer flex="1"/>
<xul:hbox anonid="control-container" class="control-container">
<xul:button anonid="preferences-btn" class="addon-control"
label="&cmd.showPreferences.label;"
tooltiptext="&cmd.showPreferences.tooltip;"
oncommand="document.getBindingParent(this).showPreferences();"/>
<xul:button anonid="remove-btn" class="addon-control remove"
label="&cmd.uninstallAddon.label;"
tooltiptext="&cmd.uninstallAddon.tooltip;"
@ -835,6 +839,10 @@
document.getAnonymousElementByAttribute(this, "anonid",
"description");
</field>
<field name="_preferencesBtn">
document.getAnonymousElementByAttribute(this, "anonid",
"preferences-btn");
</field>
<field name="_enableBtn">
document.getAnonymousElementByAttribute(this, "anonid",
"enable-btn");
@ -946,6 +954,8 @@
<body><![CDATA[
this.setAttribute("incompatible", !this.mAddon.isCompatible);
this._preferencesBtn.hidden = !this.mAddon.optionsURL;
this._enableBtn.hidden = !this.hasPermission("enable");
this._disableBtn.hidden = !this.hasPermission("disable");
this._removeBtn.hidden = !this.hasPermission("uninstall");
@ -969,6 +979,12 @@
]]></body>
</method>
<method name="showPreferences">
<body><![CDATA[
gViewController.doCommand("cmd_showItemPreferences", this.mAddon);
]]></body>
</method>
<method name="showInDetailView">
<body><![CDATA[
gViewController.loadView("addons://detail/" +

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

@ -47,6 +47,7 @@ include $(DEPTH)/config/autoconf.mk
_TEST_FILES = \
head.js \
browser_bug562890.js \
browser_bug562899.js \
browser_dragdrop.js \
browser_sorting.js \

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

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="addon-test-pref-window">
<label value="Oh hai!"/>
</window>

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

@ -0,0 +1,58 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Tests the Preferences button for addons in list view
*/
function test() {
waitForExplicitFinish();
var addonPrefsURI = TESTROOT + "addon_prefs.xul";
var gProvider = new MockProvider();
gProvider.createAddons([{
id: "test1@tests.mozilla.org",
name: "Test add-on 1",
description: "foo"
},
{
id: "test2@tests.mozilla.org",
name: "Test add-on 2",
description: "bar",
optionsURL: addonPrefsURI
}]);
open_manager(null, function(aWindow) {
var addonList = aWindow.document.getElementById("addon-list");
var addonItem = addonList.childNodes[0];
var prefsBtn = aWindow.document.getAnonymousElementByAttribute(addonItem,
"anonid",
"preferences-btn");
is(prefsBtn.hidden, true, "Prefs button should be hidden for addon with no optionsURL set")
addonItem = addonList.childNodes[1];
prefsBtn = aWindow.document.getAnonymousElementByAttribute(addonItem,
"anonid",
"preferences-btn");
is(prefsBtn.hidden, false, "Prefs button should be shown for addon with a optionsURL set")
Services.ww.registerNotification(function(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed") {
Services.ww.unregisterNotification(arguments.callee);
} else if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.documentURI, addonPrefsURI, "The correct addon pref window should open"
waitForFocus(function() {
win.close();
aWindow.close();
finish();
}, win);
}
});
EventUtils.synthesizeMouse(prefsBtn, 2, 2, { }, aWindow);
});
}