Bug 728790 test_prompt_async.html doesn't track its dialogs correctly r=mayhemer

This commit is contained in:
Neil Rashbrook 2012-03-16 21:57:13 +00:00
Родитель 3a6c76df6e
Коммит 3cc24bfd69
1 изменённых файлов: 12 добавлений и 7 удалений

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

@ -31,11 +31,13 @@
login2 = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(Ci.nsILoginInfo);
login2.init("http://mochi.test:8888", null, "mochirealm", "user1name", "user1pass", "", "");
pwmgr.addLogin(login2);
startCallbackTimer();
}
function cleanup() {
var pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
pwmgr.removeLogin(login);
pwmgr.removeLogin(login2);
timer.cancel();
}
function makeXHR(expectedStatus, expectedText, extra) {
@ -59,7 +61,6 @@
function testNonAnonymousCredentials() {
var xhr = makeXHR(200, "OK");
xhr.send();
startCallbackTimer();
}
function testAnonymousCredentials() {
@ -77,10 +78,14 @@
xhr.send();
}
var gExpectedDialogs = 0;
var gCurrentTest;
function runNextTest() {
is(gExpectedDialogs, 0, "received expected number of auth dialogs");
Cc["@mozilla.org/network/http-auth-manager;1"].getService(Components.interfaces.nsIHttpAuthManager).clearAll();
if (pendingTests.length > 0) {
gCurrentTest = pendingTests.shift();
({expectedDialogs: gExpectedDialogs,
test: gCurrentTest}) = pendingTests.shift();
gCurrentTest.call(this);
} else {
cleanup();
@ -88,8 +93,9 @@
}
}
var pendingTests = [testNonAnonymousCredentials, testAnonymousCredentials,
testAnonymousNoAuth];
var pendingTests = [{expectedDialogs: 2, test: testNonAnonymousCredentials},
{expectedDialogs: 1, test: testAnonymousCredentials},
{expectedDialogs: 0, test: testAnonymousNoAuth}];
init();
runNextTest();
@ -97,9 +103,8 @@
{
var dialog = doc.getElementById("commonDialog");
dialog.acceptDialog();
if (gCurrentTest == testNonAnonymousCredentials) {
startCallbackTimer();
}
gExpectedDialogs--;
startCallbackTimer();
}
</script>
</body>