зеркало из https://github.com/mozilla/gecko-dev.git
Bug 656011 - Password Manager now allows to copy username; r=MattN
--HG-- extra : rebase_source : 570214fbb1e966d73bd715988dafee9b7cf628a1
This commit is contained in:
Родитель
c8f2fb5da8
Коммит
bd58047409
|
@ -325,13 +325,26 @@ function CopyPassword() {
|
|||
clipboard.copyString(password, document);
|
||||
}
|
||||
|
||||
function CopyUsername() {
|
||||
// Copy selected signon's username to clipboard
|
||||
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
|
||||
getService(Components.interfaces.nsIClipboardHelper);
|
||||
var row = document.getElementById("signonsTree").currentIndex;
|
||||
var username = signonsTreeView.getCellText(row, {id : "userCol" });
|
||||
clipboard.copyString(username);
|
||||
}
|
||||
|
||||
function UpdateCopyPassword() {
|
||||
var singleSelection = (signonsTreeView.selection.count == 1);
|
||||
var menuitem = document.getElementById("context-copypassword");
|
||||
if (singleSelection)
|
||||
menuitem.removeAttribute("disabled");
|
||||
else
|
||||
menuitem.setAttribute("disabled", "true");
|
||||
var passwordMenuitem = document.getElementById("context-copypassword");
|
||||
var usernameMenuitem = document.getElementById("context-copyusername");
|
||||
if (singleSelection) {
|
||||
usernameMenuitem.removeAttribute("disabled");
|
||||
passwordMenuitem.removeAttribute("disabled");
|
||||
} else {
|
||||
usernameMenuitem.setAttribute("disabled", "true");
|
||||
passwordMenuitem.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
function masterPasswordLogin(noPasswordCallback) {
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
<popupset id="signonsTreeContextSet">
|
||||
<menupopup id="signonsTreeContextMenu"
|
||||
onpopupshowing="UpdateCopyPassword()">
|
||||
<menuitem id="context-copyusername"
|
||||
label="©UsernameCmd.label;"
|
||||
oncommand="CopyUsername()"/>
|
||||
<menuitem id="context-copypassword"
|
||||
label="©PasswordCmd.label;"
|
||||
accesskey="©PasswordCmd.accesskey;"
|
||||
|
|
|
@ -33,24 +33,24 @@ function test() {
|
|||
let pwmgrdlg = window.openDialog(PWMGR_DLG, "Toolkit:PasswordManager", "");
|
||||
SimpleTest.waitForFocus(doTest, pwmgrdlg);
|
||||
|
||||
// Test if "Copy Password" works
|
||||
// Test if "Copy Username" and "Copy Password" works
|
||||
function doTest() {
|
||||
let doc = pwmgrdlg.document;
|
||||
let selection = doc.getElementById("signonsTree").view.selection;
|
||||
let menuitem = doc.getElementById("context-copypassword");
|
||||
let menuitem = doc.getElementById("context-copyusername");
|
||||
|
||||
function copyPassword() {
|
||||
function copyField() {
|
||||
selection.selectAll();
|
||||
is(isMenuitemEnabled(), false, "Copy Password should be disabled");
|
||||
is(isMenuitemEnabled(), false, "Copy should be disabled");
|
||||
|
||||
selection.select(0);
|
||||
is(isMenuitemEnabled(), true, "Copy Password should be enabled");
|
||||
is(isMenuitemEnabled(), true, "Copy should be enabled");
|
||||
|
||||
selection.clearSelection();
|
||||
is(isMenuitemEnabled(), false, "Copy Password should be disabled");
|
||||
is(isMenuitemEnabled(), false, "Copy should be disabled");
|
||||
|
||||
selection.select(2);
|
||||
is(isMenuitemEnabled(), true, "Copy Password should be enabled");
|
||||
is(isMenuitemEnabled(), true, "Copy should be enabled");
|
||||
menuitem.doCommand();
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,14 @@ function test() {
|
|||
});
|
||||
pwmgrdlg.close();
|
||||
}
|
||||
|
||||
waitForClipboard("coded", copyPassword, cleanUp, cleanUp);
|
||||
|
||||
function testPassword() {
|
||||
menuitem = doc.getElementById("context-copypassword");
|
||||
info("Testing Copy Password");
|
||||
waitForClipboard("coded", copyField, cleanUp, cleanUp);
|
||||
}
|
||||
|
||||
info("Testing Copy Username");
|
||||
waitForClipboard("ehsan", copyField, testPassword, testPassword);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,3 +26,5 @@
|
|||
|
||||
<!ENTITY copyPasswordCmd.label "Copy Password">
|
||||
<!ENTITY copyPasswordCmd.accesskey "C">
|
||||
|
||||
<!ENTITY copyUsernameCmd.label "Copy Username">
|
||||
|
|
Загрузка…
Ссылка в новой задаче