summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js
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 /devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js')
-rw-r--r--devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js b/devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js
new file mode 100644
index 0000000000..c565c2b575
--- /dev/null
+++ b/devtools/client/webconsole/test/browser/browser_jsterm_autocomplete_escape_key.js
@@ -0,0 +1,50 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// See Bug 585991.
+
+const TEST_URI = `data:text/html;charset=utf-8,<!DOCTYPE html>
+<head>
+ <script>
+ /* Create a prototype-less object so popup does not contain native
+ * Object prototype properties.
+ */
+ window.foo = Object.create(null);
+ Object.assign(window.foo, {
+ item0: "value0",
+ item1: "value1",
+ });
+ </script>
+</head>
+<body>bug 585991 - autocomplete popup escape key usage test</body>`;
+
+add_task(async function () {
+ const hud = await openNewTabAndConsole(TEST_URI);
+ const { jsterm } = hud;
+ info("web console opened");
+
+ const { autocompletePopup: popup } = jsterm;
+
+ const onPopUpOpen = popup.once("popup-opened");
+
+ info("wait for completion: window.foo.");
+ setInputValue(hud, "window.foo");
+ EventUtils.sendString(".");
+
+ await onPopUpOpen;
+
+ ok(popup.isOpen, "popup is open");
+ ok(popup.itemCount, "popup has items");
+
+ info("press Escape to close the popup");
+ const onPopupClose = popup.once("popup-closed");
+ EventUtils.synthesizeKey("KEY_Escape");
+
+ await onPopupClose;
+
+ ok(!popup.isOpen, "popup is not open after VK_ESCAPE");
+ is(getInputValue(hud), "window.foo.", "completion was cancelled");
+ ok(!getInputCompletionValue(hud), "completeNode is empty");
+});