--- a/toolkit/components/prompts/test/test_modal_prompts.html
+++ b/toolkit/components/prompts/test/test_modal_prompts.html
@@ -163,695 +163,17 @@ function checkExpectedState(ui, state, a
* Invoked a short period of time after calling startCallbackTimer(), and
* allows testing the actual prompt dialog while it's being displayed. Tests
* should call startCallbackTimer() each time the auth dialog is expected (the
* timer is a one-shot).
*/
function handleDialog(ui, testNum) {
ok(true, "--- handleDialog for test " + testNum +
" --- (isTabModal=" + isTabModal + ", usePromptService=" + usePromptService + ")");
-
- let state, action;
-
- switch(testNum) {
- case 1:
- // Alert
- state = {
- msg : "This is the alert text.",
- title : "TestTitle",
- iconClass : "alert-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 2:
- // AlertCheck (null checkbox label, so it's hidden)
- state = {
- msg : "This is the alertCheck text.",
- title : "TestTitle",
- iconClass : "alert-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 3:
- // AlertCheck
- state = {
- msg : "This is the alertCheck text.",
- title : "TestTitle",
- iconClass : "alert-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : false,
- textValue : "",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- setCheckbox: true,
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 4:
- // Confirm (ok)
- state = {
- msg : "This is the confirm text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 5:
- // Confirm (cancel)
- state = {
- msg : "This is the confirm text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "cancel",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 6:
- // ConfirmCheck (no checkbox, ok)
- state = {
- msg : "This is the confirmCheck text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 7:
- // ConfirmCheck (no checkbox, cancel)
- state = {
- msg : "This is the confirmCheck text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "cancel",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 8:
- // ConfirmCheck (ok)
- state = {
- msg : "This is the confirmCheck text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : false,
- textValue : "",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- setCheckbox: true,
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 9:
- // ConfirmCheck (cancel)
- state = {
- msg : "This is the confirmCheck text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : false,
- textValue : "",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "cancel",
- setCheckbox: true,
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 10:
- // Prompt (ok, no default text)
- state = {
- msg : "This is the prompt text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : false,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick : "ok",
- textField : "bacon",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 11:
- // Prompt (ok, default text)
- state = {
- msg : "This is the prompt text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : false,
- passHidden : true,
- checkHidden : true,
- textValue : "kittens",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 12:
- // Prompt (cancel, default text)
- state = {
- msg : "This is the prompt text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : false,
- passHidden : true,
- checkHidden : true,
- textValue : "puppies",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick: "cancel",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 13:
- // Prompt (cancel, default text modified)
- state = {
- msg : "This is the prompt text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : false,
- passHidden : true,
- checkHidden : true,
- textValue : "puppies",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick : "cancel",
- textField : "bacon",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 14:
- // Prompt (ok, with checkbox)
- state = {
- msg : "This is the prompt text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : false,
- passHidden : true,
- checkHidden : false,
- textValue : "tribbles",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- setCheckbox: true,
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 15:
- // Prompt (cancel, with checkbox)
- state = {
- msg : "This is the prompt text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : false,
- passHidden : true,
- checkHidden : false,
- textValue : "tribbles",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick: "cancel",
- setCheckbox: true,
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 16:
- // PromptUsernameAndPassword (ok, with checkbox)
- state = {
- msg : "This is the pUAP text.",
- title : "TestTitle",
- iconClass : "authentication-icon question-icon",
- textHidden : false,
- passHidden : false,
- checkHidden : false,
- textValue : "usr",
- passValue : "ssh",
- checkMsg : "Check me out!",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- setCheckbox: true,
- textField: "newusr",
- passField: "newssh",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 17:
- // PromptUsernameAndPassword (cancel, with checkbox)
- state = {
- msg : "This is the pUAP text.",
- title : "TestTitle",
- iconClass : "authentication-icon question-icon",
- textHidden : false,
- passHidden : false,
- checkHidden : false,
- textValue : "usr",
- passValue : "ssh",
- checkMsg : "Check me out!",
- checked : false,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick : "cancel",
- setCheckbox : true,
- textField : "newusr",
- passField : "newssh",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 18:
- // PromptPassword (ok, with checkbox)
- state = {
- msg : "This is the promptPassword text.",
- title : "TestTitle",
- iconClass : "authentication-icon question-icon",
- textHidden : true,
- passHidden : false,
- checkHidden : false,
- textValue : "",
- passValue : "ssh",
- checkMsg : "Check me out!",
- checked : false,
- focused : "passField",
- defButton : "button0",
- };
- action = {
- buttonClick : "ok",
- setCheckbox : true,
- passField : "newssh",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 19:
- // PromptPassword (cancel, with checkbox)
- state = {
- msg : "This is the promptPassword text.",
- title : "TestTitle",
- iconClass : "authentication-icon question-icon",
- textHidden : true,
- passHidden : false,
- checkHidden : false,
- textValue : "",
- passValue : "ssh",
- checkMsg : "Check me out!",
- checked : false,
- focused : "passField",
- defButton : "button0",
- };
- action = {
- buttonClick : "cancel",
- setCheckbox : true,
- passField : "newssh",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 20:
- // ConfirmEx (ok/cancel, ok)
- state = {
- msg : "This is the confirmEx text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- butt0Label : "OK",
- butt1Label : "Cancel",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 21:
- // ConfirmEx (yes/no, cancel)
- state = {
- msg : "This is the confirmEx text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- butt0Label : "Yes",
- butt1Label : "No",
- };
- action = {
- buttonClick: "cancel",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 22:
- // ConfirmEx (buttons from args, checkbox, ok)
- state = {
- msg : "This is the confirmEx text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : false,
- textValue : "",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "button0",
- defButton : "button0",
- butt0Label : "butt0",
- butt1Label : "butt1",
- butt2Label : "butt2",
- };
- action = {
- buttonClick: "ok",
- setCheckbox: true,
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 23:
- // ConfirmEx (buttons from args, checkbox, cancel)
- state = {
- msg : "This is the confirmEx text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : false,
- textValue : "",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "button1", // Default changed!
- defButton : "button1",
- butt0Label : "butt0",
- butt1Label : "butt1",
- butt2Label : "butt2",
- };
- action = {
- buttonClick: "cancel",
- setCheckbox: true,
- };
- // XXX check button1 is default
- checkExpectedState(ui, state, action);
- break;
-
- case 24:
- // ConfirmEx (buttons from args, checkbox, button3)
- state = {
- msg : "This is the confirmEx text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : false,
- textValue : "",
- passValue : "",
- checkMsg : "Check me out!",
- checked : false,
- focused : "button2", // Default changed!
- defButton : "button2",
- butt0Label : "butt0",
- butt1Label : "butt1",
- butt2Label : "butt2",
- };
- action = {
- buttonClick: 2,
- setCheckbox: true,
- };
- // XXX check button2 is default
- checkExpectedState(ui, state, action);
- break;
-
- case 25:
- // Alert, null window
- state = {
- msg : "This is the alert text.",
- title : "TestTitle",
- iconClass : "alert-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : "button0",
- defButton : "button0",
- };
- action = {
- buttonClick: "ok",
- };
- checkExpectedState(ui, state, action);
- break;
-
- case 26:
- // ConfirmEx (with delay, ok)
- state = {
- msg : "This is the confirmEx delay text.",
- title : "TestTitle",
- iconClass : "question-icon",
- textHidden : true,
- passHidden : true,
- checkHidden : true,
- textValue : "",
- passValue : "",
- checkMsg : "",
- checked : false,
- focused : null, // nothing focused until after delay fires
- defButton : "button0",
- butt0Label : "OK",
- butt1Label : "Cancel",
- };
-
- // OS X doesn't initially focus the button, but rather the infoBody.
- // The focus stays there even after the button-enable delay has fired.
- if (isOSX)
- state.focused = "infoBody";
-
- action = {
- buttonClick: "pollOK",
- };
- checkExpectedState(ui, state, action);
- 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,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick : "ok",
- setCheckbox : true,
- textField : "username",
- passField : "password",
- };
- checkExpectedState(ui, state, action);
- 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,
- focused : "textField",
- defButton : "button0",
- };
- action = {
- buttonClick : "ok",
- setCheckbox : true,
- textField : "username",
- passField : "password",
- };
- checkExpectedState(ui, state, action);
- break;
-
- default:
- ok(false, "Uhh, unhandled switch for testNum #" + testNum);
- break;
- }
-
- ok(true, "handleDialog done");
+ checkExpectedState(ui, state, action);
}
function* runTests() {
let ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
ok(true, "Running tests (isTabModal=" + isTabModal + ", usePromptService=" + usePromptService + ")");
@@ -875,197 +197,441 @@ function* runTests() {
let flags;
let isOK, clickedButton;
testNum = 0;
// ===== test 1 =====
// Alert
testNum++;
+ state = {
+ msg : "This is the alert text.",
+ title : "TestTitle",
+ iconClass : "alert-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ };
startCallbackTimer();
promptArgs = ["TestTitle", "This is the alert text."];
if (usePromptService)
promptArgs.unshift(window);
prompter.alert.apply(null, promptArgs);
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 2 =====
- // AlertCheck (null checkbox label)
+ // AlertCheck (null checkbox label, so it's hidden)
testNum++;
+ state = {
+ msg : "This is the alertCheck text.",
+ title : "TestTitle",
+ iconClass : "alert-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ };
startCallbackTimer();
promptArgs = ["TestTitle", "This is the alertCheck text.", null, {}];
if (usePromptService)
promptArgs.unshift(window);
prompter.alertCheck.apply(null, promptArgs);
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 3 =====
// AlertCheck
testNum++;
+ state = {
+ msg : "This is the alertCheck text.",
+ title : "TestTitle",
+ iconClass : "alert-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ setCheckbox: true,
+ };
startCallbackTimer();
checkVal.value = false;
promptArgs = ["TestTitle", "This is the alertCheck text.", "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
prompter.alertCheck.apply(null, promptArgs);
ok(didDialog, "handleDialog was invoked");
is(checkVal.value, true, "checkbox was checked");
yield Promise.resolve();
// ===== test 4 =====
// Confirm (ok)
testNum++;
+ state = {
+ msg : "This is the confirm text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ };
startCallbackTimer();
promptArgs = ["TestTitle", "This is the confirm text."];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.confirm.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 5 =====
// Confirm (cancel)
testNum++;
+ state = {
+ msg : "This is the confirm text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "cancel",
+ };
startCallbackTimer();
promptArgs = ["TestTitle", "This is the confirm text."];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.confirm.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 6 =====
// ConfirmCheck (ok, null checkbox label)
testNum++;
+ state = {
+ msg : "This is the confirmCheck text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ };
startCallbackTimer();
promptArgs = ["TestTitle", "This is the confirmCheck text.", null, {}];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.confirmCheck.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 7 =====
// ConfirmCheck (cancel, null checkbox label)
testNum++;
+ state = {
+ msg : "This is the confirmCheck text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "cancel",
+ };
startCallbackTimer();
promptArgs = ["TestTitle", "This is the confirmCheck text.", null, {}];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.confirmCheck.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 8 =====
// ConfirmCheck (ok)
testNum++;
+ state = {
+ msg : "This is the confirmCheck text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ setCheckbox: true,
+ };
startCallbackTimer();
checkVal.value = false;
promptArgs = ["TestTitle", "This is the confirmCheck text.", "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.confirmCheck.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 9 =====
// ConfirmCheck (cancel)
testNum++;
+ state = {
+ msg : "This is the confirmCheck text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "cancel",
+ setCheckbox: true,
+ };
startCallbackTimer();
checkVal.value = false;
promptArgs = ["TestTitle", "This is the confirmCheck text.", "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.confirmCheck.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 10 =====
// Prompt (ok, no default text)
testNum++;
+ state = {
+ msg : "This is the prompt text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : false,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "ok",
+ textField : "bacon",
+ };
startCallbackTimer();
textVal.value = "";
promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.prompt.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
is(textVal.value, "bacon", "checking expected text value");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 11 =====
// Prompt (ok, default text)
testNum++;
+ state = {
+ msg : "This is the prompt text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : false,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "kittens",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ };
startCallbackTimer();
textVal.value = "kittens";
promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.prompt.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
is(textVal.value, "kittens", "checking expected text value");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 12 =====
// Prompt (cancel, default text)
testNum++;
+ state = {
+ msg : "This is the prompt text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : false,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "puppies",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "cancel",
+ };
startCallbackTimer();
textVal.value = "puppies";
promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.prompt.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
is(textVal.value, "puppies", "checking expected text value");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 13 =====
// Prompt (cancel, default text modified)
testNum++;
+ state = {
+ msg : "This is the prompt text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : false,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "puppies",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "cancel",
+ textField : "bacon",
+ };
startCallbackTimer();
textVal.value = "puppies";
promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.prompt.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
is(textVal.value, "puppies", "checking expected text value");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 14 =====
// Prompt (ok, with checkbox)
testNum++;
+ state = {
+ msg : "This is the prompt text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : false,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "tribbles",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ setCheckbox: true,
+ };
startCallbackTimer();
textVal.value = "tribbles";
checkVal.value = false;
promptArgs = ["TestTitle", "This is the prompt text.", textVal, "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.prompt.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
@@ -1073,16 +639,34 @@ function* runTests() {
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 15 =====
// Prompt (cancel, with checkbox)
testNum++;
+ state = {
+ msg : "This is the prompt text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : false,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "tribbles",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "cancel",
+ setCheckbox: true,
+ };
startCallbackTimer();
textVal.value = "tribbles";
checkVal.value = false;
promptArgs = ["TestTitle", "This is the prompt text.", textVal, "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.prompt.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
@@ -1091,16 +675,36 @@ function* runTests() {
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 16 =====
// PromptUsernameAndPassword (ok)
// Just two tests for this, since password manager already tests this extensively.
testNum++;
+ state = {
+ msg : "This is the pUAP text.",
+ title : "TestTitle",
+ iconClass : "authentication-icon question-icon",
+ textHidden : false,
+ passHidden : false,
+ checkHidden : false,
+ textValue : "usr",
+ passValue : "ssh",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ setCheckbox: true,
+ textField: "newusr",
+ passField: "newssh",
+ };
startCallbackTimer();
textVal.value = "usr";
passVal.value = "ssh";
checkVal.value = false;
promptArgs = ["TestTitle", "This is the pUAP text.", textVal, passVal, "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.promptUsernameAndPassword.apply(null, promptArgs);
@@ -1110,16 +714,36 @@ function* runTests() {
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 17 =====
// PromptUsernameAndPassword (cancel)
testNum++;
+ state = {
+ msg : "This is the pUAP text.",
+ title : "TestTitle",
+ iconClass : "authentication-icon question-icon",
+ textHidden : false,
+ passHidden : false,
+ checkHidden : false,
+ textValue : "usr",
+ passValue : "ssh",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "cancel",
+ setCheckbox : true,
+ textField : "newusr",
+ passField : "newssh",
+ };
startCallbackTimer();
textVal.value = "usr";
passVal.value = "ssh";
checkVal.value = false;
promptArgs = ["TestTitle", "This is the pUAP text.", textVal, passVal, "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.promptUsernameAndPassword.apply(null, promptArgs);
@@ -1129,16 +753,35 @@ function* runTests() {
is(checkVal.value, false, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 18 =====
// PromptPassword (ok)
testNum++;
+ state = {
+ msg : "This is the promptPassword text.",
+ title : "TestTitle",
+ iconClass : "authentication-icon question-icon",
+ textHidden : true,
+ passHidden : false,
+ checkHidden : false,
+ textValue : "",
+ passValue : "ssh",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "passField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "ok",
+ setCheckbox : true,
+ passField : "newssh",
+ };
startCallbackTimer();
passVal.value = "ssh";
checkVal.value = false;
promptArgs = ["TestTitle", "This is the promptPassword text.", passVal, "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.promptPassword.apply(null, promptArgs);
is(isOK, true, "checked expected retval");
@@ -1146,16 +789,35 @@ function* runTests() {
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 19 =====
// PromptPassword (cancel)
testNum++;
+ state = {
+ msg : "This is the promptPassword text.",
+ title : "TestTitle",
+ iconClass : "authentication-icon question-icon",
+ textHidden : true,
+ passHidden : false,
+ checkHidden : false,
+ textValue : "",
+ passValue : "ssh",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "passField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "cancel",
+ setCheckbox : true,
+ passField : "newssh",
+ };
startCallbackTimer();
passVal.value = "ssh";
checkVal.value = false;
promptArgs = ["TestTitle", "This is the promptPassword text.", passVal, "Check me out!", checkVal];
if (usePromptService)
promptArgs.unshift(window);
isOK = prompter.promptPassword.apply(null, promptArgs);
is(isOK, false, "checked expected retval");
@@ -1163,44 +825,103 @@ function* runTests() {
is(checkVal.value, false, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 20 =====
// ConfirmEx (ok/cancel, ok)
testNum++;
+ state = {
+ msg : "This is the confirmEx text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ butt0Label : "OK",
+ butt1Label : "Cancel",
+ };
+ action = {
+ buttonClick: "ok",
+ };
startCallbackTimer();
flags = Ci.nsIPromptService.STD_OK_CANCEL_BUTTONS;
promptArgs = ["TestTitle", "This is the confirmEx text.", flags, null, null, null, null, {}];
if (usePromptService)
promptArgs.unshift(window);
clickedButton = prompter.confirmEx.apply(null, promptArgs);
is(clickedButton, 0, "checked expected button num click");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 21 =====
// ConfirmEx (yes/no, cancel)
testNum++;
+ state = {
+ msg : "This is the confirmEx text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ butt0Label : "Yes",
+ butt1Label : "No",
+ };
+ action = {
+ buttonClick: "cancel",
+ };
startCallbackTimer();
flags = Ci.nsIPromptService.STD_YES_NO_BUTTONS;
promptArgs = ["TestTitle", "This is the confirmEx text.", flags, null, null, null, null, {}];
if (usePromptService)
promptArgs.unshift(window);
clickedButton = prompter.confirmEx.apply(null, promptArgs);
is(clickedButton, 1, "checked expected button num click");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 22 =====
// ConfirmEx (buttons from args, checkbox, ok)
testNum++;
+ state = {
+ msg : "This is the confirmEx text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ butt0Label : "butt0",
+ butt1Label : "butt1",
+ butt2Label : "butt2",
+ };
+ action = {
+ buttonClick: "ok",
+ setCheckbox: true,
+ };
startCallbackTimer();
let b = Ci.nsIPromptService.BUTTON_TITLE_IS_STRING;
flags = b * Ci.nsIPromptService.BUTTON_POS_2 +
b * Ci.nsIPromptService.BUTTON_POS_1 +
b * Ci.nsIPromptService.BUTTON_POS_0;
checkVal.value = false;
promptArgs = ["TestTitle", "This is the confirmEx text.", flags,
"butt0", "butt1", "butt2", "Check me out!", checkVal];
@@ -1211,16 +932,37 @@ function* runTests() {
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 23 =====
// ConfirmEx (buttons from args, checkbox, cancel)
testNum++;
+ state = {
+ msg : "This is the confirmEx text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "button1", // Default changed!
+ defButton : "button1",
+ butt0Label : "butt0",
+ butt1Label : "butt1",
+ butt2Label : "butt2",
+ };
+ action = {
+ buttonClick: "cancel",
+ setCheckbox: true,
+ };
startCallbackTimer();
b = Ci.nsIPromptService.BUTTON_TITLE_IS_STRING;
flags = b * Ci.nsIPromptService.BUTTON_POS_2 +
b * Ci.nsIPromptService.BUTTON_POS_1 +
b * Ci.nsIPromptService.BUTTON_POS_0;
flags ^= Ci.nsIPromptService.BUTTON_POS_1_DEFAULT;
checkVal.value = false;
promptArgs = ["TestTitle", "This is the confirmEx text.", flags,
@@ -1232,16 +974,37 @@ function* runTests() {
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 24 =====
// ConfirmEx (buttons from args, checkbox, button3)
testNum++;
+ state = {
+ msg : "This is the confirmEx text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : false,
+ textValue : "",
+ passValue : "",
+ checkMsg : "Check me out!",
+ checked : false,
+ focused : "button2", // Default changed!
+ defButton : "button2",
+ butt0Label : "butt0",
+ butt1Label : "butt1",
+ butt2Label : "butt2",
+ };
+ action = {
+ buttonClick: 2,
+ setCheckbox: true,
+ };
startCallbackTimer();
b = Ci.nsIPromptService.BUTTON_TITLE_IS_STRING;
flags = b * Ci.nsIPromptService.BUTTON_POS_2 +
b * Ci.nsIPromptService.BUTTON_POS_1 +
b * Ci.nsIPromptService.BUTTON_POS_0;
flags ^= Ci.nsIPromptService.BUTTON_POS_2_DEFAULT;
checkVal.value = false;
promptArgs = ["TestTitle", "This is the confirmEx text.", flags,
@@ -1254,31 +1017,73 @@ function* runTests() {
ok(didDialog, "handleDialog was invoked");
yield Promise.resolve();
// ===== test 25 =====
// Alert, no window
// (skipped for tabmodal tests: window is required)
testNum++;
+ state = {
+ msg : "This is the alert text.",
+ title : "TestTitle",
+ iconClass : "alert-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : "button0",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick: "ok",
+ };
if (!isTabModal) {
startCallbackTimer();
promptArgs = ["TestTitle", "This is the alert text."];
if (usePromptService)
promptArgs.unshift(null);
prompter.alert.apply(null, promptArgs);
ok(didDialog, "handleDialog was invoked");
}
yield Promise.resolve();
// ===== test 26 =====
// ConfirmEx (delay, ok)
// (skipped for tabmodal tests: delay not supported)
testNum++;
+ state = {
+ msg : "This is the confirmEx delay text.",
+ title : "TestTitle",
+ iconClass : "question-icon",
+ textHidden : true,
+ passHidden : true,
+ checkHidden : true,
+ textValue : "",
+ passValue : "",
+ checkMsg : "",
+ checked : false,
+ focused : null, // nothing focused until after delay fires
+ defButton : "button0",
+ butt0Label : "OK",
+ butt1Label : "Cancel",
+ };
+
+ // OS X doesn't initially focus the button, but rather the infoBody.
+ // The focus stays there even after the button-enable delay has fired.
+ if (isOSX)
+ state.focused = "infoBody";
+
+ action = {
+ buttonClick: "pollOK",
+ };
if (!isTabModal) {
startCallbackTimer();
flags = (Ci.nsIPromptService.STD_OK_CANCEL_BUTTONS | Ci.nsIPromptService.BUTTON_DELAY_ENABLE);
promptArgs = ["TestTitle", "This is the confirmEx delay text.", flags, null, null, null, null, {}];
if (usePromptService)
promptArgs.unshift(window);
clickedButton = prompter.confirmEx.apply(null, promptArgs);
is(clickedButton, 0, "checked expected button num click");
@@ -1307,16 +1112,36 @@ function* runTests() {
};
yield Promise.resolve();
// ===== test 100 =====
// promptAuth with empty realm
// (promptAuth is only accessible from the prompt service)
testNum = 100;
+ 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,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "ok",
+ setCheckbox : true,
+ textField : "username",
+ passField : "password",
+ };
if (usePromptService) {
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");
@@ -1324,16 +1149,39 @@ function* runTests() {
}
yield Promise.resolve();
// ===== test 101 =====
// promptAuth with long realm
// (promptAuth is only accessible from the prompt service)
testNum++;
+ 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,
+ focused : "textField",
+ defButton : "button0",
+ };
+ action = {
+ buttonClick : "ok",
+ setCheckbox : true,
+ textField : "username",
+ passField : "password",
+ };
if (usePromptService) {
startCallbackTimer();
checkVal.value = false;
var longString = "";
for (var i = 0; i < 20; i++)
longString += "abcdefghi "; // 200 chars long
authinfo.realm = longString;
authinfo.username = "";
@@ -1344,16 +1192,17 @@ function* runTests() {
is(authinfo.password, "password", "checking filled password");
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
}
}
let testNum;
let pollTimer;
+let state, action;
/*
* Run the body of the 3 times:
* - 1st pass: with window-modal prompts, using nsIPromptService
* - 2nd pass: still window-modal, using nsIPrompt directly (via nsIPromptFactory)
* - 3rd pass: with tab-modal prompts. Can't opt into these via * nsIPromptService.
*/