From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../browser_rules_colorpicker-swatch-displayed.js | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js (limited to 'devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js') diff --git a/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js b/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js new file mode 100644 index 0000000000..56e15ba8cf --- /dev/null +++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-swatch-displayed.js @@ -0,0 +1,99 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that color swatches are displayed next to colors in the rule-view. + +const TEST_URI = ` + + Testing the color picker tooltip! +`; + +// Tests that properties in the rule-view contain color swatches. +// Each entry in the test array should contain: +// { +// selector: the rule-view selector to look for the property in +// propertyName: the property to test +// nb: the number of color swatches this property should have +// } +const TESTS = [ + { selector: "body", propertyName: "color", nb: 1 }, + { selector: "body", propertyName: "background-color", nb: 1 }, + { selector: "body", propertyName: "border", nb: 1 }, + { selector: "*", propertyName: "color", nb: 1 }, + { selector: "*", propertyName: "background", nb: 26 }, + { selector: "*", propertyName: "box-shadow", nb: 2 }, + { selector: "*", propertyName: "filter", nb: 1 }, + { selector: "*", propertyName: "text-shadow", nb: 3 }, +]; + +add_task(async function () { + await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); + const { view } = await openRuleView(); + + for (const { selector, propertyName, nb } of TESTS) { + info( + "Looking for color swatches in property " + + propertyName + + " in selector " + + selector + ); + + const prop = ( + await getRuleViewProperty(view, selector, propertyName, { wait: true }) + ).valueSpan; + const swatches = prop.querySelectorAll(".ruleview-colorswatch"); + + ok(swatches.length, "Swatches found in the property"); + is(swatches.length, nb, "Correct number of swatches found in the property"); + } +}); -- cgit v1.2.3