Bug 568287 - Expand test for 'Copy Password' context menu item in Password Manager [r=dolske]

This commit is contained in:
Frank Yan 2010-06-09 13:55:46 -07:00
Родитель fc409beff8
Коммит a14771fc6f
2 изменённых файлов: 22 добавлений и 8 удалений

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

@ -65,13 +65,13 @@
</keyset>
<popupset id="signonsTreeContextSet">
<popup id="signonsTreeContextMenu"
<menupopup id="signonsTreeContextMenu"
onpopupshowing="UpdateCopyPassword()">
<menuitem id="context-copypassword"
label="&copyPasswordCmd.label;"
accesskey="&copyPasswordCmd.accesskey;"
oncommand="CopyPassword()"/>
</popup>
</menupopup>
</popupset>
<!-- saved signons -->

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

@ -71,14 +71,28 @@ function test() {
// Test if "Copy Password" works
function doTest() {
let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
let data = "";
let polls = 0;
let doc = pwmgrdlg.document;
let selection = doc.getElementById("signonsTree").view.selection;
let menuitem = doc.getElementById("context-copypassword");
function copyPassword() {
let doc = pwmgrdlg.document;
doc.getElementById("signonsTree").currentIndex = 2;
doc.getElementById("context-copypassword").doCommand();
selection.selectAll();
is(isMenuitemEnabled(), false, "Copy Password should be disabled");
selection.select(0);
is(isMenuitemEnabled(), true, "Copy Password should be enabled");
selection.clearSelection();
is(isMenuitemEnabled(), false, "Copy Password should be disabled");
selection.select(2);
is(isMenuitemEnabled(), true, "Copy Password should be enabled");
menuitem.doCommand();
}
function isMenuitemEnabled() {
doc.defaultView.UpdateCopyPassword();
return !menuitem.getAttribute("disabled");
}
function cleanUp() {