commit 5b66be067d5c6aa2bfa2adbf50b8fe763e826291
parent db5606dc9f6c06ff908aafdf3055c781667af375
Author: Nicolas Chevobbe <nchevobbe@mozilla.com>
Date: Fri, 14 Nov 2025 10:29:13 +0000
Bug 1947747 - [devtools] Add `inactiveCSS` boolean expected data in `checkRuleViewContent`. r=devtools-reviewers,bomsy.
This will allow to check if a given declaration is considered as inactive (this
is used by the next patch in the queue).
The helper function is refactored a bit so we don't trigger the eslint complexity warning
Differential Revision: https://phabricator.services.mozilla.com/D271548
Diffstat:
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/devtools/client/inspector/rules/test/head.js b/devtools/client/inspector/rules/test/head.js
@@ -1393,6 +1393,8 @@ function getSmallIncrementKey() {
* Defaults to false
* @param {boolean|undefined} expectedElements[].declarations[].highlighted - Is the declaration
* highlighted by a search.
+ * @param {boolean|undefined} expectedElements[].declarations[].inactiveCSS - Is the declaration
+ * inactive.
* @param {string} expectedElements[].header - If we're expecting a header (Inherited from,
* Pseudo-elements, …), the text of said header.
*/
@@ -1404,8 +1406,7 @@ function checkRuleViewContent(view, expectedElements) {
"All expected elements are displayed"
);
- for (let i = 0; i < expectedElements.length; i++) {
- const expectedElement = expectedElements[i];
+ expectedElements.forEach((expectedElement, i) => {
info(`Checking element #${i}: ${expectedElement.selector}`);
const elementInView = elementsInView[i];
@@ -1421,7 +1422,7 @@ function checkRuleViewContent(view, expectedElements) {
expectedElement.header,
`Expected header text for element #${i}`
);
- continue;
+ return;
}
const selector = elementInView.querySelector(
@@ -1453,20 +1454,21 @@ function checkRuleViewContent(view, expectedElements) {
`Element #${i} ("${selector}") is ${expectedElement.inherited ? "inherited" : "not inherited"}`
);
- const declarations = elementInView.querySelectorAll(".ruleview-property");
+ const ruleViewPropertyElements =
+ elementInView.querySelectorAll(".ruleview-property");
is(
- declarations.length,
+ ruleViewPropertyElements.length,
expectedElement.declarations.length,
`Got the expected number of declarations for expected element #${i} (${selector})`
);
- for (let j = 0; j < declarations.length; j++) {
- const expectedDeclaration = expectedElement.declarations[j];
- const ruleViewPropertyElement = declarations[j];
+ ruleViewPropertyElements.forEach((ruleViewPropertyElement, j) => {
const [propName, propValue] = Array.from(
ruleViewPropertyElement.querySelectorAll(
".ruleview-propertyname, .ruleview-propertyvalue"
)
);
+
+ const expectedDeclaration = expectedElement.declarations[j];
is(
propName.innerText,
expectedDeclaration?.name,
@@ -1475,7 +1477,7 @@ function checkRuleViewContent(view, expectedElements) {
if (propName.innerText !== expectedDeclaration?.name) {
// We don't have the expected property name, don't run the other assertions to
// avoid spamming the output
- continue;
+ return;
}
is(
@@ -1489,6 +1491,11 @@ function checkRuleViewContent(view, expectedElements) {
`Element #${i} ("${selector}") declaration #${j} ("${propName.innerText}: ${propValue.innerText}") is ${expectedDeclaration?.overridden ? "overridden" : "not overridden"} `
);
is(
+ ruleViewPropertyElement.classList.contains("inactive-css"),
+ !!expectedDeclaration?.inactiveCSS,
+ `Element #${i} ("${selector}") declaration #${j} ("${propName.innerText}: ${propValue.innerText}") is ${expectedDeclaration?.inactiveCSS ? "inactive" : "not inactive"} `
+ );
+ is(
!!ruleViewPropertyElement.querySelector(
".ruleview-warning:not([hidden])"
),
@@ -1505,8 +1512,8 @@ function checkRuleViewContent(view, expectedElements) {
!!expectedDeclaration?.highlighted,
`Element #${i} ("${selector}") declaration #${j} ("${propName.innerText}: ${propValue.innerText}") is ${expectedDeclaration?.highlighted ? "highlighted" : "not highlighted"} `
);
- }
- }
+ });
+ });
}
/**