diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/inspector/rules/test/browser_rules_completion-on-empty.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/rules/test/browser_rules_completion-on-empty.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-on-empty.js b/devtools/client/inspector/rules/test/browser_rules_completion-on-empty.js new file mode 100644 index 0000000000..9a3348783f --- /dev/null +++ b/devtools/client/inspector/rules/test/browser_rules_completion-on-empty.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests the suggest completion popup behavior of CSS property field. + +const TEST_URI = "<h1 style='color: lime'>Header</h1>"; + +add_task(async function () { + await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + const { inspector, view } = await openRuleView(); + + info("Selecting the test node"); + await selectNode("h1", inspector); + + const prop = getTextProperty(view, 0, { color: "lime" }); + + info("Test with css property value field"); + await testCompletion(view, prop.editor.valueSpan, true); + + info("Test with css property name field"); + await testCompletion(view, prop.editor.nameSpan, false); +}); + +async function testCompletion(view, target, isExpectedOpenPopup) { + const editor = await focusEditableField(view, target); + + info( + "Check the suggest completion popup visibility after clearing the field" + ); + + const onChanged = view.once("ruleview-changed"); + const popupEvent = isExpectedOpenPopup ? "popup-opened" : "popup-closed"; + const onPopupEvent = + editor.popup.isOpen === isExpectedOpenPopup + ? Promise.resolve() + : once(view.popup, popupEvent); + EventUtils.synthesizeKey("VK_BACK_SPACE", {}, view.styleWindow); + + // Flush the debounce to update the preview text. + view.debounce.flush(); + + await Promise.all([onChanged, onPopupEvent]); + is( + editor.popup.isOpen, + isExpectedOpenPopup, + "The popup visibility is correct" + ); + + if (editor.popup.isOpen) { + info("Close the suggest completion popup"); + const closingEvents = [ + view.once("ruleview-changed"), + once(view.popup, "popup-closed"), + ]; + EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); + await Promise.all(closingEvents); + } +} |