|
34 | 34 | return null;
|
35 | 35 | }
|
36 | 36 |
|
37 |
| -function checkDeclaration(target, origin, props) { |
| 37 | +function checkDeclaration(doc, selector, origin, props) { |
| 38 | + info(`Checking ${origin} declarations for element "${selector}"`); |
38 | 39 | ok(!!props, "Should pass some properties to check");
|
| 40 | + |
| 41 | + const target = doc.querySelector(selector); |
39 | 42 | let decl = getDeclarationWithOrigin(target, origin);
|
40 |
| - ok(!!decl, "Should find a declaration for " + origin); |
41 |
| - info(decl.style.cssText); |
42 |
| - for (let [k, v] of Object.entries(props)) { |
43 |
| - is(decl.style[k], v, `Should see ${k}: ${v}`); |
| 43 | + ok(!!decl, `Should find a ${origin} declaration for "${selector}"`); |
| 44 | + |
| 45 | + const propsEntries = Object.entries(props); |
| 46 | + is(decl.style.length, propsEntries.length, `Got expected number of ${origin} declarations for "${selector}"`); |
| 47 | + for (let i = 0; i < decl.style.length; i++) { |
| 48 | + const [name, value] = propsEntries[i] || []; |
| 49 | + is(decl.style[i], name, `Should see "${name}" property on ${origin} declaration for "${selector}"`); |
| 50 | + is(decl.style[name], value, `"${name}" has expected "${value}" value on ${origin} declaration for "${selector}"`); |
44 | 51 | }
|
45 | 52 | let modificationThrew = false;
|
46 | 53 | try {
|
|
205 | 212 | {
|
206 | 213 | title: "Check pres hints",
|
207 | 214 | async run(doc, win) {
|
208 |
| - checkDeclaration(doc.querySelector("img"), "pres-hints", { width: "10px", height: "15px" }); |
209 |
| - checkDeclaration(doc.querySelector(".anim"), "animations", {zIndex: "1"}); |
210 |
| - checkDeclaration(doc.querySelector("[style]"), "style-attribute", {zIndex: "1"}); |
| 215 | + checkDeclaration(doc, "img", "pres-hints", { width: "10px", height: "15px", "aspect-ratio": "auto 10 / 15" }); |
| 216 | + checkDeclaration(doc, "table", "pres-hints", {color: "-moz-inherit-from-body-quirk"}); |
| 217 | + checkDeclaration(doc, ".anim", "animations", {"z-index": "1"}); |
| 218 | + checkDeclaration(doc, "[style]", "style-attribute", {"z-index": "1"}); |
211 | 219 | // TODO: transitions/SMIL are a bit more annoying to test.
|
212 | 220 | },
|
213 | 221 | }
|
|
0 commit comments