Bug 1838262, part 1: Changed expected WPT results for getComputedStyle() in custom highlight API tests. r=emilio

As per [0], [1] and [2], `getComputedStyle()` should not return the
default style when the pseudo is invalid.
Instead, an empty style should be returned.

[0] https://drafts.csswg.org/cssom/#extensions-to-the-window-interface
[1] https://github.com/w3c/csswg-drafts/issues/6501
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1726396

Differential Revision: https://phabricator.services.mozilla.com/D184810
This commit is contained in:
Jan-Niklas Jaeschke 2023-07-31 13:47:54 +00:00
parent 741f8538d5
commit 39eee0a002

View File

@ -9,6 +9,7 @@
background-color: green;
color: lime;
}
#target::highlight(bar) {
background-color: cyan;
color: fuchsia;
@ -30,12 +31,10 @@
assert_equals(style.color, "rgb(255, 0, 255)", "Color is fuchsia.");
}, `Different getComputedStyle() for ${highlightPseudo} and same element`);
for (const illHighlightPseudo of ["::highlight(foo):", "::highlight(foo))", "::highlight(foo)(", "::highlight", "::highlight(foo)(foo)", "::highlight(foo)()", ":::highlight(foo)", "::highlight(foo).", "::highlight(foo,bar)"]) {
for (const illHighlightPseudo of ["::highlight(foo):", "::highlight(foo))", "::highlight(foo)(", "::highlight", "::highlight(foo)(foo)", "::highlight(foo)()", ":::highlight(foo)", "::highlight(foo).", "::highlight(foo,bar)", "::highlight(foo bar)"]) {
test(() => {
let style = getComputedStyle(target, illHighlightPseudo);
let defaultStyle = getComputedStyle(target);
assert_equals(style.backgroundColor, defaultStyle.backgroundColor, "Background color is element's default.");
assert_equals(style.color, defaultStyle.color, "Color is element's default.");
}, `getComputedStyle() for ${illHighlightPseudo} should be element's default`);
assert_equals(style.length, 0, "Invalid pseudo identifiers should not return a style.");
}, `getComputedStyle() for ${illHighlightPseudo} should not return a style.`);
}
</script>