diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/markup/test/browser_markup_keybindings_03.js | |
parent | Initial commit. (diff) | |
download | firefox-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 '')
-rw-r--r-- | devtools/client/inspector/markup/test/browser_markup_keybindings_03.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js new file mode 100644 index 0000000000..db918defd6 --- /dev/null +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_03.js @@ -0,0 +1,64 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that selecting a node with the mouse (by clicking on the line) focuses +// the first focusable element in the corresponding MarkupContainer so that the +// keyboard can be used immediately. + +const TEST_URL = `data:text/html;charset=utf8, + <div class='test-class'></div>Text node`; + +add_task(async function () { + const { inspector } = await openInspectorForURL(TEST_URL); + const { walker } = inspector; + + info("Select the test node to have the 2 test containers visible"); + await selectNode("div", inspector); + + const divFront = await walker.querySelector(walker.rootNode, "div"); + const textFront = await walker.nextSibling(divFront); + + info("Click on the MarkupContainer element for the text node"); + await clickContainer(textFront, inspector); + is( + inspector.markup.doc.activeElement, + getContainerForNodeFront(textFront, inspector).editor.textNode.valuePreRef + .current, + "The currently focused element is the node's text content" + ); + + info("Click on the MarkupContainer element for the <div> node"); + await clickContainer(divFront, inspector); + is( + inspector.markup.doc.activeElement, + getContainerForNodeFront(divFront, inspector).editor.tag, + "The currently focused element is the div's tagname" + ); + + info("Click on the test-class attribute, to make sure it gets focused"); + const editor = getContainerForNodeFront(divFront, inspector).editor; + const attributeEditor = editor.attrElements + .get("class") + .querySelector(".editable"); + + const onFocus = once(attributeEditor, "focus"); + EventUtils.synthesizeMouseAtCenter( + attributeEditor, + { type: "mousedown" }, + inspector.markup.doc.defaultView + ); + EventUtils.synthesizeMouseAtCenter( + attributeEditor, + { type: "mouseup" }, + inspector.markup.doc.defaultView + ); + await onFocus; + + is( + inspector.markup.doc.activeElement, + attributeEditor, + "The currently focused element is the div's class attribute" + ); +}); |