зеркало из https://github.com/mozilla/pjs.git
Bug 573238 - Windows authentication broken. r=gavin
This commit is contained in:
Родитель
0120ae5c9f
Коммит
cd782da7d3
|
@ -314,7 +314,7 @@ let PromptUtils = {
|
|||
|
||||
// Suppress "the site says: $realm" when we synthesized a missing realm.
|
||||
if (!authInfo.realm && !isProxy)
|
||||
realm = null;
|
||||
realm = "";
|
||||
|
||||
// Trim obnoxiously long realms.
|
||||
if (realm.length > 150) {
|
||||
|
|
|
@ -22,6 +22,8 @@ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|||
|
||||
let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(Ci.nsIPromptService2);
|
||||
let ioService = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
|
||||
function checkExpectedState(doc, state) {
|
||||
let msg = doc.getElementById("info.body").textContent;
|
||||
|
@ -635,6 +637,55 @@ function handleDialog(doc, testNum) {
|
|||
clickOK = false;
|
||||
break;
|
||||
|
||||
case 100:
|
||||
// PromptAuth (no realm, ok, with checkbox)
|
||||
state = {
|
||||
msg : 'Enter username and password for http://example.com',
|
||||
title : "TestTitle",
|
||||
iconClass : "authentication-icon question-icon",
|
||||
textHidden : false,
|
||||
passHidden : false,
|
||||
checkHidden : false,
|
||||
textValue : "",
|
||||
passValue : "",
|
||||
checkMsg : "Check me out!",
|
||||
checked : false,
|
||||
};
|
||||
checkExpectedState(doc, state);
|
||||
|
||||
textField.setAttribute("value", "username");
|
||||
passField.setAttribute("value", "password");
|
||||
// XXX dumb. old code driven by oncommand.
|
||||
checkbox.setChecked(true);
|
||||
checkbox.doCommand();
|
||||
break;
|
||||
|
||||
case 101:
|
||||
// PromptAuth (long realm, ok, with checkbox)
|
||||
state = {
|
||||
msg : 'A username and password are being requested by http://example.com. The site ' +
|
||||
'says: "abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi ' +
|
||||
'abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi ' +
|
||||
'abcdefghi \u2026"',
|
||||
title : "TestTitle",
|
||||
iconClass : "authentication-icon question-icon",
|
||||
textHidden : false,
|
||||
passHidden : false,
|
||||
checkHidden : false,
|
||||
textValue : "",
|
||||
passValue : "",
|
||||
checkMsg : "Check me out!",
|
||||
checked : false,
|
||||
};
|
||||
checkExpectedState(doc, state);
|
||||
|
||||
textField.setAttribute("value", "username");
|
||||
passField.setAttribute("value", "password");
|
||||
// XXX dumb. old code driven by oncommand.
|
||||
checkbox.setChecked(true);
|
||||
checkbox.doCommand();
|
||||
break;
|
||||
|
||||
default:
|
||||
ok(false, "Uhh, unhandled switch for testNum #" + testNum);
|
||||
break;
|
||||
|
@ -973,7 +1024,50 @@ is(checkVal.value, true, "expected checkbox setting");
|
|||
ok(didDialog, "handleDialog was invoked");
|
||||
|
||||
|
||||
// promptAuth already tested via password manager
|
||||
// promptAuth already tested via password manager but do a few specific things here.
|
||||
|
||||
|
||||
var channel = ioService.newChannel("http://example.com", null, null);
|
||||
var level = Ci.nsIAuthPrompt2.LEVEL_NONE;
|
||||
var authinfo = {
|
||||
username : "",
|
||||
password : "",
|
||||
domain : "",
|
||||
|
||||
flags : Ci.nsIAuthInformation.AUTH_HOST,
|
||||
authenticationScheme : "basic",
|
||||
realm : ""
|
||||
};
|
||||
|
||||
// ===== test 100 =====
|
||||
// promptAuth with empty realm
|
||||
testNum = 100;
|
||||
startCallbackTimer();
|
||||
checkVal.value = false;
|
||||
isOK = prompter.promptAuth(window, channel, level, authinfo, "Check me out!", checkVal);
|
||||
is(isOK, true, "checked expected retval");
|
||||
is(authinfo.username, "username", "checking filled username");
|
||||
is(authinfo.password, "password", "checking filled password");
|
||||
is(checkVal.value, true, "expected checkbox setting");
|
||||
ok(didDialog, "handleDialog was invoked");
|
||||
|
||||
// ===== test 101 =====
|
||||
// promptAuth with long realm
|
||||
testNum++;
|
||||
startCallbackTimer();
|
||||
checkVal.value = false;
|
||||
var longString = "";
|
||||
for (var i = 0; i < 20; i++)
|
||||
longString += "abcdefghi "; // 200 chars long
|
||||
authinfo.realm = longString;
|
||||
authinfo.username = "";
|
||||
authinfo.password = "";
|
||||
isOK = prompter.promptAuth(window, channel, level, authinfo, "Check me out!", checkVal);
|
||||
is(isOK, true, "checked expected retval");
|
||||
is(authinfo.username, "username", "checking filled username");
|
||||
is(authinfo.password, "password", "checking filled password");
|
||||
is(checkVal.value, true, "expected checkbox setting");
|
||||
ok(didDialog, "handleDialog was invoked");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
Загрузка…
Ссылка в новой задаче