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/shared/test/browser_styleinspector_tooltip-closes-on-new-selection.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/shared/test/browser_styleinspector_tooltip-closes-on-new-selection.js')
-rw-r--r-- | devtools/client/inspector/shared/test/browser_styleinspector_tooltip-closes-on-new-selection.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/devtools/client/inspector/shared/test/browser_styleinspector_tooltip-closes-on-new-selection.js b/devtools/client/inspector/shared/test/browser_styleinspector_tooltip-closes-on-new-selection.js new file mode 100644 index 0000000000..3fe58aa63d --- /dev/null +++ b/devtools/client/inspector/shared/test/browser_styleinspector_tooltip-closes-on-new-selection.js @@ -0,0 +1,80 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that if a tooltip is visible when a new selection is made, it closes + +const TEST_URI = "<div class='one'>el 1</div><div class='two'>el 2</div>"; +const XHTML_NS = "http://www.w3.org/1999/xhtml"; + +add_task(async function () { + await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + let { inspector, view } = await openRuleView(); + await selectNode(".one", inspector); + + info("Testing rule view tooltip closes on new selection"); + await testRuleView(view, inspector); + + info("Testing computed view tooltip closes on new selection"); + view = selectComputedView(inspector); + await testComputedView(view, inspector); +}); + +async function testRuleView(ruleView, inspector) { + info("Showing the tooltip"); + + const tooltip = ruleView.tooltips.getTooltip("previewTooltip"); + const tooltipContent = ruleView.styleDocument.createElementNS( + XHTML_NS, + "div" + ); + tooltip.panel.appendChild(tooltipContent); + tooltip.setContentSize({ width: 100, height: 30 }); + + // Stop listening for mouse movements because it's not needed for this test, + // and causes intermittent failures on Linux. When this test runs in the suite + // sometimes a mouseleave event is dispatched at the start, which causes the + // tooltip to hide in the middle of being shown, which causes timeouts later. + tooltip.stopTogglingOnHover(); + + const onShown = tooltip.once("shown"); + tooltip.show(ruleView.styleDocument.firstElementChild); + await onShown; + + info("Selecting a new node"); + const onHidden = tooltip.once("hidden"); + await selectNode(".two", inspector); + await onHidden; + + ok(true, "Rule view tooltip closed after a new node got selected"); +} + +async function testComputedView(computedView, inspector) { + info("Showing the tooltip"); + + const tooltip = computedView.tooltips.getTooltip("previewTooltip"); + const tooltipContent = computedView.styleDocument.createElementNS( + XHTML_NS, + "div" + ); + tooltip.panel.appendChild(tooltipContent); + await tooltip.setContentSize({ width: 100, height: 30 }); + + // Stop listening for mouse movements because it's not needed for this test, + // and causes intermittent failures on Linux. When this test runs in the suite + // sometimes a mouseleave event is dispatched at the start, which causes the + // tooltip to hide in the middle of being shown, which causes timeouts later. + tooltip.stopTogglingOnHover(); + + const onShown = tooltip.once("shown"); + tooltip.show(computedView.styleDocument.firstElementChild); + await onShown; + + info("Selecting a new node"); + const onHidden = tooltip.once("hidden"); + await selectNode(".one", inspector); + await onHidden; + + ok(true, "Computed view tooltip closed after a new node got selected"); +} |