From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- ...owser_rules_colorpicker-and-image-tooltip_02.js | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js (limited to 'devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js') diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js new file mode 100644 index 0000000000..3262349274 --- /dev/null +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-and-image-tooltip_02.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that after a color change, opening another tooltip, like the image +// preview doesn't revert the color change in the rule view. +// This used to happen when the activeSwatch wasn't reset when the colorpicker +// would hide. +// See bug 979292 + +const TEST_URI = ` + + Testing the color picker tooltip! +`; + +add_task(async function () { + await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + const { view } = await openRuleView(); + await testColorChangeIsntRevertedWhenOtherTooltipIsShown(view); +}); + +async function testColorChangeIsntRevertedWhenOtherTooltipIsShown(ruleView) { + let swatch = getRuleViewProperty( + ruleView, + "body", + "background" + ).valueSpan.querySelector(".ruleview-colorswatch"); + + info("Open the color picker tooltip and change the color"); + const picker = ruleView.tooltips.getTooltip("colorPicker"); + const onColorPickerReady = picker.once("ready"); + swatch.click(); + await onColorPickerReady; + + await simulateColorPickerChange(ruleView, picker, [0, 0, 0, 1], { + selector: "body", + name: "background-color", + value: "rgb(0, 0, 0)", + }); + + const spectrum = picker.spectrum; + + const onModifications = waitForNEvents(ruleView, "ruleview-changed", 2); + const onHidden = picker.tooltip.once("hidden"); + focusAndSendKey(spectrum.element.ownerDocument.defaultView, "RETURN"); + await onHidden; + await onModifications; + + info("Open the image preview tooltip"); + const value = getRuleViewProperty(ruleView, "body", "background").valueSpan; + const url = value.querySelector(".theme-link"); + const previewTooltip = await assertShowPreviewTooltip(ruleView, url); + + info("Image tooltip is shown, verify that the swatch is still correct"); + swatch = value.querySelector(".ruleview-colorswatch"); + is(swatch.style.backgroundColor, "black", "The swatch's color is correct"); + is(swatch.nextSibling.textContent, "black", "The color name is correct"); + + await assertTooltipHiddenOnMouseOut(previewTooltip, url); +} -- cgit v1.2.3