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 --- .../browser_rules_colorpicker-commit-on-ENTER.js | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js (limited to 'devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js') diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js new file mode 100644 index 0000000000..5649d050d2 --- /dev/null +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js @@ -0,0 +1,76 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that a color change in the color picker is committed when ENTER is +// pressed. + +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(); + + const swatch = getRuleViewProperty( + view, + "body", + "border" + ).valueSpan.querySelector(".ruleview-colorswatch"); + await testPressingEnterCommitsChanges(swatch, view); +}); + +async function testPressingEnterCommitsChanges(swatch, ruleView) { + const cPicker = ruleView.tooltips.getTooltip("colorPicker"); + + const onColorPickerReady = cPicker.once("ready"); + swatch.click(); + await onColorPickerReady; + + await simulateColorPickerChange(ruleView, cPicker, [0, 255, 0, 0.5], { + selector: "body", + name: "border-left-color", + value: "rgba(0, 255, 0, 0.5)", + }); + + is( + swatch.style.backgroundColor, + "rgba(0, 255, 0, 0.5)", + "The color swatch's background was updated" + ); + is( + getRuleViewProperty(ruleView, "body", "border").valueSpan.textContent, + "2em solid rgba(0, 255, 0, 0.5)", + "The text of the border css property was updated" + ); + + const onModified = ruleView.once("ruleview-changed"); + const spectrum = cPicker.spectrum; + const onHidden = cPicker.tooltip.once("hidden"); + focusAndSendKey(spectrum.element.ownerDocument.defaultView, "RETURN"); + await onHidden; + await onModified; + + is( + await getComputedStyleProperty("body", null, "border-left-color"), + "rgba(0, 255, 0, 0.5)", + "The element's border was kept after RETURN" + ); + is( + swatch.style.backgroundColor, + "rgba(0, 255, 0, 0.5)", + "The color swatch's background was kept after RETURN" + ); + is( + getRuleViewProperty(ruleView, "body", "border").valueSpan.textContent, + "2em solid rgba(0, 255, 0, 0.5)", + "The text of the border css property was kept after RETURN" + ); +} -- cgit v1.2.3