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
Родитель 249630e90b
Коммит 3159e835b7
1 изменённых файлов: 12 добавлений и 7 удалений

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

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