diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/prompts/test/test_dom_prompts.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/prompts/test/test_dom_prompts.html')
-rw-r--r-- | toolkit/components/prompts/test/test_dom_prompts.html | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/toolkit/components/prompts/test/test_dom_prompts.html b/toolkit/components/prompts/test/test_dom_prompts.html new file mode 100644 index 0000000000..95595b8df2 --- /dev/null +++ b/toolkit/components/prompts/test/test_dom_prompts.html @@ -0,0 +1,207 @@ +<html> +<head> + <title>Test for DOM prompts</title> + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script type="text/javascript" src="prompt_common.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +</pre> + +<script class="testbody" type="text/javascript"> +var rv; +var state, action; +modalType = Ci.nsIPrompt.MODAL_TYPE_CONTENT; + +add_task(async function test_alert_ok() { + info("Starting test: Alert"); + state = { + msg: "This is the alert text.", + iconClass: "alert-icon", + titleHidden: true, + textHidden: true, + passHidden: true, + checkHidden: true, + textValue: "", + passValue: "", + checkMsg: "", + checked: false, + focused: "button0", + defButton: "button0", + }; + action = { + buttonClick: "ok", + }; + + let promptDone = handlePrompt(state, action); + + alert("This is the alert text."); + + await promptDone; +}); + +// bug 861605 made the arguments to alert/confirm optional (prompt already was). +add_task(async function test_alert_noargs() { + info("Starting test: Alert with no args"); + state = { + msg: "", + iconClass: "alert-icon", + titleHidden: true, + textHidden: true, + passHidden: true, + checkHidden: true, + textValue: "", + passValue: "", + checkMsg: "", + checked: false, + focused: "button0", + defButton: "button0", + }; + action = { + buttonClick: "ok", + }; + + let promptDone = handlePrompt(state, action); + + try { + alert(); + ok(true, "alert() without arguments should not throw!"); + } catch (e) { + ok(false, "alert() without arguments should not throw!"); + } + + await promptDone; +}); + +add_task(async function test_confirm_ok() { + info("Starting test: Confirm"); + state = { + msg: "This is the confirm text.", + iconClass: "question-icon", + titleHidden: true, + textHidden: true, + passHidden: true, + checkHidden: true, + textValue: "", + passValue: "", + checkMsg: "", + checked: false, + focused: "button0", + defButton: "button0", + }; + action = { + buttonClick: "ok", + }; + + let promptDone = handlePrompt(state, action); + + rv = confirm("This is the confirm text."); + is(rv, true, "check prompt return value"); + + await promptDone; +}); + +// bug 861605 made the arguments to alert/confirm optional (prompt already was). +add_task(async function test_confirm_noargs() { + info("Starting test: Confirm with no args"); + state = { + msg: "", + iconClass: "question-icon", + titleHidden: true, + textHidden: true, + passHidden: true, + checkHidden: true, + textValue: "", + passValue: "", + checkMsg: "", + checked: false, + focused: "button0", + defButton: "button0", + }; + action = { + buttonClick: "ok", + }; + + let promptDone = handlePrompt(state, action); + + try { + rv = confirm(); + ok(true, "confirm() without arguments should not throw!"); + } catch (e) { + ok(false, "confirm() without arguments should not throw!"); + } + is(rv, true, "check prompt return value"); + + await promptDone; +}); + + +add_task(async function test_prompt_ok() { + info("Starting test: Prompt"); + state = { + msg: "This is the Prompt text.", + iconClass: "question-icon", + titleHidden: true, + textHidden: false, + passHidden: true, + checkHidden: true, + textValue: "", + passValue: "", + checkMsg: "", + checked: false, + focused: "textField", + defButton: "button0", + }; + action = { + buttonClick: "ok", + }; + + let promptDone = handlePrompt(state, action); + + rv = prompt("This is the Prompt text."); + is(rv, "", "check prompt return value"); + + await promptDone; +}); + +// bug 861605 made the arguments to alert/confirm optional (prompt already was). +add_task(async function test_prompt_noargs() { + info("Starting test: Prompt with no args"); + state = { + msg: "", + iconClass: "question-icon", + titleHidden: true, + textHidden: false, + passHidden: true, + checkHidden: true, + textValue: "", + passValue: "", + checkMsg: "", + checked: false, + focused: "textField", + defButton: "button0", + }; + action = { + buttonClick: "ok", + }; + + let promptDone = handlePrompt(state, action); + + try { + rv = prompt(); + ok(true, "prompt() without arguments should not throw!"); + } catch (e) { + ok(false, "prompt() without arguments should not throw!"); + } + is(rv, "", "check prompt return value"); + + await promptDone; +}); + +</script> + +</body> +</html> |