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_shadowdom_show_nodes_button.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 'devtools/client/inspector/markup/test/browser_markup_shadowdom_show_nodes_button.js')
-rw-r--r-- | devtools/client/inspector/markup/test/browser_markup_shadowdom_show_nodes_button.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/browser_markup_shadowdom_show_nodes_button.js b/devtools/client/inspector/markup/test/browser_markup_shadowdom_show_nodes_button.js new file mode 100644 index 0000000000..76d542c526 --- /dev/null +++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_show_nodes_button.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that the "Show all 'N' nodes" button displays the proper value + +const NODE_COUNT = 101; +const TEST_URL = `data:text/html;charset=utf-8, + <test-component> + </test-component> + + <script> + 'use strict'; + for (let i = 0; i < ${NODE_COUNT}; i++) { + const div = document.createElement("div"); + div.innerHTML = i; + document.querySelector('test-component').appendChild(div); + } + customElements.define('test-component', class extends HTMLElement { + constructor() { + super(); + let shadowRoot = this.attachShadow({mode: 'open'}); + shadowRoot.innerHTML = '<slot></slot>'; + } + }); + </script>`; + +add_task(async function () { + const { inspector } = await openInspectorForURL(TEST_URL); + const { markup } = inspector; + + info("Find and expand the component shadow DOM host."); + const hostFront = await getNodeFront("test-component", inspector); + const hostContainer = markup.getContainer(hostFront); + await expandContainer(inspector, hostContainer); + const shadowRootContainer = hostContainer.getChildContainers()[0]; + await expandContainer(inspector, shadowRootContainer); + + info("Expand the slot"); + const slotContainer = shadowRootContainer.getChildContainers()[0]; + await expandContainer(inspector, slotContainer); + + info("Find the 'Show all nodes' button"); + const button = slotContainer.elt.querySelector( + "button:not(.inspector-badge)" + ); + ok( + button.innerText.includes(NODE_COUNT), + `'Show all nodes' button contains correct node count (expected "${button.innerText}" to include "${NODE_COUNT}")` + ); +}); |