summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_bug569988.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /editor/libeditor/tests/test_bug569988.html
parentInitial commit. (diff)
downloadfirefox-upstream/124.0.1.tar.xz
firefox-upstream/124.0.1.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'editor/libeditor/tests/test_bug569988.html')
-rw-r--r--editor/libeditor/tests/test_bug569988.html103
1 files changed, 103 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug569988.html b/editor/libeditor/tests/test_bug569988.html
new file mode 100644
index 0000000000..c4d4b040ba
--- /dev/null
+++ b/editor/libeditor/tests/test_bug569988.html
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=569988
+-->
+<head>
+ <title>Test for Bug 569988</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" href="/tests/SimpleTest/test.css">
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 569988 **/
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(runTest);
+
+
+function runTest() {
+ var script = SpecialPowers.loadChromeScript(function() {
+ /* eslint-env mozilla/chrome-script */
+ var gPromptInput = null;
+ var os = Services.obs;
+
+ os.addObserver(onPromptLoad, "common-dialog-loaded");
+ os.addObserver(onPromptLoad, "tabmodal-dialog-loaded");
+
+ function onPromptLoad(subject, topic, data) {
+ let ui = subject.Dialog ? subject.Dialog.ui : undefined;
+ if (!ui) {
+ // subject is an tab prompt, find the elements ourselves
+ ui = {
+ loginTextbox: subject.querySelector(".tabmodalprompt-loginTextbox"),
+ button0: subject.querySelector(".tabmodalprompt-button0"),
+ };
+ }
+ sendAsyncMessage("ok", [true, "onPromptLoad is called"]);
+ gPromptInput = ui.loginTextbox;
+ gPromptInput.addEventListener("focus", onPromptFocus);
+ // shift focus to ensure it fires.
+ ui.button0.focus();
+ gPromptInput.focus();
+ }
+
+ function onPromptFocus() {
+ sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
+ gPromptInput.removeEventListener("focus", onPromptFocus);
+
+ var listenerService = Services.els;
+
+ var listener = {
+ handleEvent: function _hv(aEvent) {
+ var isPrevented = aEvent.defaultPrevented;
+ sendAsyncMessage("ok", [!isPrevented,
+ "ESC key event is prevented by editor"]);
+ listenerService.removeSystemEventListener(gPromptInput, "keypress",
+ listener, false);
+ },
+ };
+ listenerService.addSystemEventListener(gPromptInput, "keypress",
+ listener, false);
+
+ sendAsyncMessage("info", "sending key");
+ var EventUtils = {};
+ EventUtils.window = {};
+ EventUtils._EU_Ci = Ci;
+ EventUtils._EU_Cc = Cc;
+ Services.scriptloader
+ .loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
+ EventUtils);
+ EventUtils.synthesizeKey("VK_ESCAPE", {},
+ gPromptInput.ownerGlobal);
+ }
+
+ addMessageListener("destroy", function() {
+ os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded");
+ os.removeObserver(onPromptLoad, "common-dialog-loaded");
+ });
+ });
+ script.addMessageListener("ok", ([val, msg]) => ok(val, msg));
+ script.addMessageListener("info", msg => info(msg));
+
+ info("opening prompt...");
+ prompt("summary", "text");
+ info("prompt is closed");
+
+ script.sendAsyncMessage("destroy");
+
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>