diff --git a/toolkit/components/passwordmgr/test/mochitest/prompt_common.js b/toolkit/components/passwordmgr/test/mochitest/prompt_common.js index d2b1834bc9767..3a2dd6190ef1e 100644 --- a/toolkit/components/passwordmgr/test/mochitest/prompt_common.js +++ b/toolkit/components/passwordmgr/test/mochitest/prompt_common.js @@ -70,3 +70,19 @@ function getDialogDoc() { return null; } + +function checkPromptState(promptState, expectedState) { + // is(promptState.title, expectedState.title, "Checking expected title"); + is(promptState.msg, expectedState.msg, "Checking expected message"); + is(promptState.textValue, expectedState.textValue, "Checking textbox value"); + is(promptState.passValue, expectedState.passValue, "Checking passbox value"); +} + +function getPromptState(ui) { + let state = {}; + state.msg = ui.infoBody.textContent; + state.title = ui.infoTitle.textContent; + state.textValue = ui.loginTextbox.getAttribute("value"); + state.passValue = ui.password1Textbox.getAttribute("value"); + return state; +} diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt.html index 37a9aa385d687..0be9b69b67c52 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_prompt.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt.html @@ -268,12 +268,11 @@ ok(true, "Time is " + (new Date()).toUTCString()); dumpNotifications(); - var body = doc.getElementById("info.body"); - var userfield = doc.getElementById("loginTextbox"); - var passfield = doc.getElementById("password1Textbox"); - var username = userfield.getAttribute("value"); - var password = passfield.getAttribute("value"); var dialog = doc.getElementById("commonDialog"); + var ui = doc.defaultView.Dialog.ui; + var actualState = getPromptState(ui); + + checkPromptState(actualState, state); switch(testNum) { case 1: @@ -281,7 +280,6 @@ buttonClick : "ok", textField : "xyz", }; - is(username, "abc", "Checking provided username"); // Temporarily commented out because of Bug #718543 // is(doc.activeElement, userfield.inputField, "focus correct for test" + testNum); // doc.commandDispatcher.rewindFocus(); @@ -297,7 +295,6 @@ buttonClick : "ok", passField : "secret", }; - is(password, "inputpw", "Checking provided password"); // Temporarily commented out because of Bug #718543 // is(doc.activeElement, passfield.inputField, "focus correct for test" + testNum); break; @@ -305,21 +302,18 @@ action = { buttonClick : "cancel", }; - is(password, "inputpw", "Checking provided password"); break; case 12: action = { buttonClick : "ok", passField : "secret", }; - is(password, "", "Checking provided password"); break; case 14: action = { buttonClick : "ok", passField : "secret", }; - is(password, "", "Checking provided password"); break; case 30: case 31: @@ -327,7 +321,6 @@ buttonClick : "ok", passField : "fill2pass", }; - is(password, "", "Checking provided password"); break; case 100: action = { @@ -335,8 +328,6 @@ textField : "outuser", passField : "outpass", }; - is(username, "inuser", "Checking provided username"); - is(password, "inpass", "Checking provided password"); break; case 101: action = { @@ -347,45 +338,33 @@ action = { buttonClick : "ok", }; - is(username, "", "Checking provided username"); - is(password, "examplepass", "Checking provided password"); break; case 103: action = { buttonClick : "ok", }; - ok(username == "user1name" || username == "user2name", "Checking filled username"); - ok(password == "user1pass" || password == "user2pass", "Checking filled password"); break; case 104: action = { buttonClick : "ok", }; - is(username, "user1name", "Checking filled username"); - is(password, "user1pass", "Checking filled password"); break; case 105: action = { buttonClick : "ok", }; - is(username, "user2name", "Checking filled username"); - is(password, "user2pass", "Checking filled password"); break; case 106: action = { buttonClick : "ok", passField : "NEWuser2pass", }; - is(username, "user2name", "Checking filled username"); - is(password, "user2pass", "Checking filled password"); break; case 107: action = { buttonClick : "ok", passField : "user2pass", }; - is(username, "user2name", "Checking filled username"); - is(password, "NEWuser2pass", "Checking filled password"); break; case 120: case 121: @@ -394,8 +373,6 @@ textField : "fill2user", passField : "fill2pass", }; - is(username, "", "Checking filled username"); - is(password, "", "Checking filled password"); break; case 500: action = { @@ -403,8 +380,6 @@ textField : "outuser", passField : "outpass", }; - is(username, "inuser", "Checking unfilled username"); - is(password, "inpass", "Checking unfilled password"); break; case 501: action = { @@ -415,16 +390,11 @@ action = { buttonClick : "ok", }; - is(username, "", "Checking filled username"); - is(password, "examplepass", "Checking filled password"); break; case 503: action = { buttonClick : "ok", }; - // either of the two logins might have been filled in - ok(username == "user1name" || username == "user2name", "Checking filled username"); - ok(password == "user1pass" || password == "user2pass", "Checking filled password"); break; case 504: // enter one of the known logins, test 504+505 exercise the two possible states. @@ -433,9 +403,6 @@ textField : "user1name", passField : "user1pass", }; - // either of the two logins might have been filled in - ok(username == "user1name" || username == "user2name", "Checking filled username"); - ok(password == "user1pass" || password == "user2pass", "Checking filled password"); break; case 505: // enter one of the known logins, test 504+505 exercise the two possible states. @@ -444,9 +411,6 @@ textField : "user2name", passField : "user2pass", }; - // either of the two logins might have been filled in - ok(username == "user1name" || username == "user2name", "Checking filled username"); - ok(password == "user1pass" || password == "user2pass", "Checking filled password"); break; case 506: // force to user2, and change the password @@ -455,9 +419,6 @@ textField : "user2name", passField : "NEWuser2pass", }; - // either of the two logins might have been filled in - ok(username == "user1name" || username == "user2name", "Checking filled username"); - ok(password == "user1pass" || password == "user2pass", "Checking filled password"); break; case 507: // force to user2, and change the password back @@ -466,45 +427,32 @@ textField : "user2name", passField : "user2pass", }; - // either of the two logins might have been filled in - ok(username == "user1name" || username == "user2name", "Checking filled username"); - ok(password == "user1pass" || password == "user2pass", "Checking filled password"); break; case 508: action = { buttonClick : "ok", }; - is(username, "proxuser", "Checking filled username"); - is(password, "proxpass", "Checking filled password"); break; // No case 509, it's unprompted. case 510: action = { buttonClick : "ok", }; - is(username, "proxuser", "Checking filled username"); - is(password, "proxpass", "Checking filled password"); break; case 511: action = { buttonClick : "ok", }; - is(username, "proxuser", "Checking filled username"); - is(password, "proxpass", "Checking filled password"); break; case 1000: action = { buttonClick : "ok", }; - is(username, "mochiuser1", "Checking filled username"); - is(password, "mochipass1", "Checking filled password"); break; case 1001: action = { buttonClick : "ok", }; - is(username, "mochiuser2", "Checking filled username"); - is(password, "mochipass2", "Checking filled password"); break; // (1002 doesn't trigger a dialog) case 1003: @@ -512,16 +460,12 @@ buttonClick : "ok", passField : "mochipass1-new", }; - is(username, "mochiuser1", "Checking filled username"); - is(password, "mochipass1", "Checking filled password"); break; case 1004: action = { buttonClick : "ok", passField : "mochipass3-new", }; - is(username, "mochiuser3", "Checking filled username"); - is(password, "mochipass3-old", "Checking filled password"); break; case 1005: action = { @@ -529,8 +473,6 @@ textField : "mochiuser3", passField : "mochipass3-old", }; - is(username, "", "Checking filled username"); - is(password, "", "Checking filled password"); break; default: ok(false, "Uhh, unhandled switch for testNum #" + testNum); @@ -578,6 +520,13 @@ is(authok, "PASS", "Checking for successful authentication"); is(username, "mochiuser1", "Checking for echoed username"); is(password, "mochipass1", "Checking for echoed password"); + + state = { + msg : "A username and password are being requested by http://mochi.test:8888. The site says: \"mochitest2\"", + title : "Authentication Required", + textValue : "mochiuser2", + passValue : "mochipass2", + }; startCallbackTimer(); // We've already authenticated to this host:port. For this next // request, the existing auth should be sent, we'll get a 401 reply, @@ -603,6 +552,12 @@ // Same realm we've already authenticated to, but with a different // expected password (to trigger an auth prompt, and change-password // popup notification). + state = { + msg : "A username and password are being requested by http://mochi.test:8888. The site says: \"mochitest\"", + title : "Authentication Required", + textValue : "mochiuser1", + passValue : "mochipass1", + }; startCallbackTimer(); iframe.src = "authenticate.sjs?user=mochiuser1&pass=mochipass1-new"; break; @@ -630,6 +585,12 @@ // Same as last test, but for a realm we haven't already authenticated // to (but have an existing saved login for, so that we'll trigger // a change-password popup notification. + state = { + msg : "A username and password are being requested by http://mochi.test:8888. The site says: \"mochitest3\"", + title : "Authentication Required", + textValue : "mochiuser3", + passValue : "mochipass3-old", + }; startCallbackTimer(); iframe.src = "authenticate.sjs?user=mochiuser3&pass=mochipass3-new&realm=mochitest3"; break; @@ -639,6 +600,12 @@ is(username, "mochiuser3", "Checking for echoed username"); is(password, "mochipass3-new", "Checking for echoed password"); + state = { + msg : "A username and password are being requested by http://mochi.test:8888. The site says: \"mochitest3\"", + title : "Authentication Required", + textValue : "", + passValue : "", + }; // Housekeeping: change it back to the original login4. Actually, // just delete it and we'll re-add it as the next test. function clearIt() { @@ -728,13 +695,14 @@ var prompter1 = promptFac.getPrompt(window, Ci.nsIAuthPrompt); var prompter2 = promptFac.getPrompt(window, Ci.nsIAuthPrompt2); - function dialogTitle() { return "nsILoginManagerPrompter test #" + testNum; } - var dialogText = "This dialog should be modified and dismissed by the test."; var uname = { value : null }; var pword = { value : null }; var result = { value : null }; var isOk; + const defaultTitle = "the title"; + const defaultMsg = "the message"; + // popupNotifications (not *popup*) is a constant, per-tab container. So, we // only need to fetch it once. var popupNotifications = getPopupNotifications(window.top); @@ -742,8 +710,14 @@ // ===== test 1 ===== testNum = 1; + state = { + msg : "the message", + title : "the title", + textValue : "abc", + passValue : "", + }; startCallbackTimer(); - isOk = prompter1.prompt(dialogTitle(), dialogText, "http://example.com", + isOk = prompter1.prompt(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, "abc", result); ok(isOk, "Checking dialog return value (accept)"); @@ -752,8 +726,14 @@ // ===== test 2 ===== testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "abc", + passValue : "", + }; startCallbackTimer(); - isOk = prompter1.prompt(dialogTitle(), dialogText, "http://example.com", + isOk = prompter1.prompt(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, "abc", result); ok(didDialog, "handleDialog was invoked"); ok(!isOk, "Checking dialog return value (cancel)"); @@ -761,9 +741,15 @@ // ===== test 10 ===== // Default password provided, existing logins are ignored. testNum = 10; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "inputpw", + }; pword.value = "inputpw"; startCallbackTimer(); - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://example.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -772,9 +758,15 @@ // ===== test 11 ===== // Default password provided, existing logins are ignored. testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "inputpw", + }; pword.value = "inputpw"; startCallbackTimer(); - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://example.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(!isOk, "Checking dialog return value (cancel)"); ok(didDialog, "handleDialog was invoked"); @@ -782,9 +774,15 @@ // ===== test 12 ===== // No default password provided, realm does not match existing login. testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "", + }; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://nonexample.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://nonexample.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -794,7 +792,7 @@ // No default password provided, matching login is returned w/o prompting. testNum++; pword.value = null; - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://example.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); is(pword.value, "examplepass", "Checking returned password"); @@ -803,9 +801,15 @@ // No default password provided, none of the logins from this host are // password-only so the user is prompted. testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "", + }; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://example2.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -815,7 +819,7 @@ // No default password provided, matching login is returned w/o prompting. testNum++; pword.value = null; - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://user1name@example2.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://user1name@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); is(pword.value, "user1pass", "Checking returned password"); @@ -824,7 +828,7 @@ // No default password provided, matching login is returned w/o prompting. testNum++; pword.value = null; - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://user2name@example2.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://user2name@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); is(pword.value, "user2pass", "Checking returned password"); @@ -833,7 +837,7 @@ // No default password provided, matching login is returned w/o prompting. testNum++; pword.value = null; - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://user3%2Ename%40host@example2.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://user3%2Ename%40host@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); is(pword.value, "user3pass", "Checking returned password"); @@ -842,7 +846,7 @@ // No default password provided, matching login is returned w/o prompting. testNum++; pword.value = null; - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://100@beef@example2.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://100@beef@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); is(pword.value, "user3pass", "Checking returned password"); @@ -851,7 +855,7 @@ // No default password provided, matching login is returned w/o prompting. testNum++; pword.value = null; - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "http://100%25beef@example2.com", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "http://100%25beef@example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); is(pword.value, "user3pass", "Checking returned password"); @@ -861,9 +865,15 @@ // ===== test 30 ===== // We don't pre-fill or save for NS_GetAuthKey-generated realms, but we should still prompt testNum = 30; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "", + }; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "example2.com:80 (somerealm)", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -872,9 +882,15 @@ // ===== test 31 ===== // We don't pre-fill or save for NS_GetAuthKey-generated realms, but we should still prompt testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "", + }; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptPassword(dialogTitle(), dialogText, "example2.com:80 (somerealm)", + isOk = prompter1.promptPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -882,10 +898,16 @@ // ===== test 100 ===== testNum = 100; + state = { + msg : "the message", + title : "the title", + textValue : "inuser", + passValue : "inpass", + }; uname.value = "inuser"; pword.value = "inpass"; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://nonexample.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://nonexample.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -894,10 +916,16 @@ // ===== test 101 ===== testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "inuser", + passValue : "inpass", + }; uname.value = "inuser"; pword.value = "inpass"; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://nonexample.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://nonexample.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, uname, pword); ok(!isOk, "Checking dialog return value (cancel)"); ok(didDialog, "handleDialog was invoked"); @@ -905,10 +933,16 @@ // ===== test 102 ===== // test filling in existing password-only login testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "examplepass", + }; uname.value = null; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://example.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://example.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -918,10 +952,17 @@ // ===== test 103 ===== // test filling in existing login (undetermined from multiple selection) testNum++; + // user2name/user2pass would also be valid to fill here. + state = { + msg : "the message", + title : "the title", + textValue : "user1name", + passValue : "user1pass", + }; uname.value = null; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://example2.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -931,10 +972,16 @@ // ===== test 104 ===== // test filling in existing login (user1 from multiple selection) testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "user1name", + passValue : "user1pass", + }; uname.value = "user1name"; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://example2.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -944,10 +991,16 @@ // ===== test 105 ===== // test filling in existing login (user2 from multiple selection) testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "user2name", + passValue : "user2pass", + }; uname.value = "user2name"; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://example2.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -957,10 +1010,16 @@ // ===== test 106 ===== // test changing password testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "user2name", + passValue : "user2pass", + }; uname.value = "user2name"; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://example2.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -970,10 +1029,16 @@ // ===== test 107 ===== // test changing password (back to original value) testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "user2name", + passValue : "NEWuser2pass", + }; uname.value = "user2name"; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "http://example2.com", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "http://example2.com", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -983,10 +1048,16 @@ // ===== test 120 ===== // We don't pre-fill or save for NS_GetAuthKey-generated realms, but we should still prompt testNum = 120; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "", + }; uname.value = null; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "example2.com:80 (somerealm)", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_NEVER, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -996,10 +1067,16 @@ // ===== test 121 ===== // We don't pre-fill or save for NS_GetAuthKey-generated realms, but we should still prompt testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "", + passValue : "", + }; uname.value = null; pword.value = null; startCallbackTimer(); - isOk = prompter1.promptUsernameAndPassword(dialogTitle(), dialogText, "example2.com:80 (somerealm)", + isOk = prompter1.promptUsernameAndPassword(defaultTitle, defaultMsg, "example2.com:80 (somerealm)", Ci.nsIAuthPrompt.SAVE_PASSWORD_PERMANENTLY, uname, pword); ok(isOk, "Checking dialog return value (accept)"); ok(didDialog, "handleDialog was invoked"); @@ -1029,6 +1106,12 @@ // ===== test 500 ===== testNum = 500; + state = { + msg : "A username and password are being requested by http://example.com. The site says: \"some realm\"", + title : "Authentication Required", + textValue : "inuser", + passValue : "inpass", + }; authinfo.username = "inuser"; authinfo.password = "inpass"; authinfo.realm = "some realm"; @@ -1043,6 +1126,12 @@ // ===== test 501 ===== testNum++; + state = { + msg : "A username and password are being requested by http://example.com. The site says: \"some realm\"", + title : "Authentication Required", + textValue : "outuser", + passValue : "outpass", + }; startCallbackTimer(); isOk = prompter2.promptAuth(channel1, level, authinfo); @@ -1052,6 +1141,12 @@ // ===== test 502 ===== // test filling in password-only login testNum++; + state = { + msg : "A username and password are being requested by http://example.com. The site says: \"http://example.com\"", + title : "Authentication Required", + textValue : "", + passValue : "examplepass", + }; authinfo.username = ""; authinfo.password = ""; authinfo.realm = "http://example.com"; @@ -1067,6 +1162,13 @@ // ===== test 503 ===== // test filling in existing login (undetermined from multiple selection) testNum++; + // user2name/user2pass would also be valid to fill here. + state = { + msg : "A username and password are being requested by http://example2.com. The site says: \"http://example2.com\"", + title : "Authentication Required", + textValue : "user1name", + passValue : "user1pass", + }; authinfo.username = ""; authinfo.password = ""; authinfo.realm = "http://example2.com"; @@ -1082,6 +1184,13 @@ // ===== test 504 ===== // test filling in existing login (undetermined --> user1) testNum++; + // user2name/user2pass would also be valid to fill here. + state = { + msg : "A username and password are being requested by http://example2.com. The site says: \"http://example2.com\"", + title : "Authentication Required", + textValue : "user1name", + passValue : "user1pass", + }; authinfo.username = ""; authinfo.password = ""; authinfo.realm = "http://example2.com"; @@ -1097,6 +1206,13 @@ // ===== test 505 ===== // test filling in existing login (undetermined --> user2) testNum++; + // user2name/user2pass would also be valid to fill here. + state = { + msg : "A username and password are being requested by http://example2.com. The site says: \"http://example2.com\"", + title : "Authentication Required", + textValue : "user1name", + passValue : "user1pass", + }; authinfo.username = ""; authinfo.password = ""; authinfo.realm = "http://example2.com"; @@ -1113,6 +1229,13 @@ // ===== test 506 ===== // test changing a password (undetermined --> user2 w/ newpass) testNum++; + // user2name/user2pass would also be valid to fill here. + state = { + msg : "A username and password are being requested by http://example2.com. The site says: \"http://example2.com\"", + title : "Authentication Required", + textValue : "user1name", + passValue : "user1pass", + }; authinfo.username = ""; authinfo.password = ""; authinfo.realm = "http://example2.com"; @@ -1129,6 +1252,13 @@ // ===== test 507 ===== // test changing a password (undetermined --> user2 w/ origpass) testNum++; + // user2name/user2pass would also be valid to fill here. + state = { + msg : "A username and password are being requested by http://example2.com. The site says: \"http://example2.com\"", + title : "Authentication Required", + textValue : "user1name", + passValue : "user1pass", + }; authinfo.username = ""; authinfo.password = ""; authinfo.realm = "http://example2.com"; @@ -1145,6 +1275,12 @@ // ===== test 508 ===== // test proxy login (default = no autologin), make sure it prompts. testNum++; + state = { + msg : "The proxy moz-proxy://127.0.0.1:8888 is requesting a username and password. The site says: \"Proxy Realm\"", + title : "Authentication Required", + textValue : "proxuser", + passValue : "proxpass", + }; proxyAuthinfo.username = ""; proxyAuthinfo.password = ""; proxyAuthinfo.realm = "Proxy Realm"; @@ -1186,6 +1322,12 @@ // ===== test 510 ===== // test proxy login (with autologin), ensure it prompts after a failed auth. testNum++; + state = { + msg : "The proxy moz-proxy://127.0.0.1:8888 is requesting a username and password. The site says: \"Proxy Realm\"", + title : "Authentication Required", + textValue : "proxuser", + passValue : "proxpass", + }; proxyAuthinfo.username = ""; proxyAuthinfo.password = ""; @@ -1206,6 +1348,12 @@ // ===== test 511 ===== // test proxy login (with autologin), ensure it prompts in Private Browsing mode. testNum++; + state = { + msg : "the message", + title : "the title", + textValue : "proxuser", + passValue : "proxpass", + }; proxyAuthinfo.username = ""; proxyAuthinfo.password = ""; @@ -1229,6 +1377,12 @@ // ===== test 1000 ===== testNum = 1000; + state = { + msg : "A username and password are being requested by http://mochi.test:8888. The site says: \"mochitest\"", + title : "Authentication Required", + textValue : "mochiuser1", + passValue : "mochipass1", + }; startCallbackTimer(); iframe.src = "authenticate.sjs?user=mochiuser1&pass=mochipass1";