mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
The output format for this was confusing. When "FAIL" becomes "PASS" the
natural assumption is that's good. So, make it always output pass for
correct results, and fail for incorrect. Also, replace the
supposed-to-fail pseudo-element name with one that will never be
supported, instead of a webkit one that we did end up adding support
for! 😅
Added a couple of env() cases which will pass with the following commit.
51 lines
1.9 KiB
HTML
51 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<style>div { background-color: red; }</style>
|
|
<style id="style"></style>
|
|
<script src="../include.js"></script>
|
|
<div id="target"></div>
|
|
<script>
|
|
test(() => {
|
|
let style = document.getElementById("style");
|
|
let target = document.getElementById("target");
|
|
|
|
function testSupports(input, shouldPass) {
|
|
style.innerText = `${input} {
|
|
div { background-color: green; }
|
|
}`;
|
|
let result = getComputedStyle(target).backgroundColor;
|
|
println(`${input}: ${(result === 'rgb(0, 128, 0)') === shouldPass ? 'PASS' : 'FAIL'}`);
|
|
}
|
|
|
|
let validCases = [
|
|
"@supports (color: green)",
|
|
"@supports (color: green) and (width: 50px)",
|
|
"@supports (color: green) or (flogwizzle: purple)",
|
|
"@supports (not (flogwizzle: purple))",
|
|
"@supports selector(.simple)",
|
|
"@supports selector(a#more > .complicated.case:nth-child(42))",
|
|
"@supports selector(.easy) or selector(.....nope)",
|
|
"@supports env(preferred-text-scale)",
|
|
];
|
|
println("These should all be valid:");
|
|
for (let testCase of validCases) {
|
|
testSupports(testCase, true);
|
|
}
|
|
|
|
let invalidCases = [
|
|
"@supports (not (color: green))",
|
|
"@supports (color: green) and (width: 50px) or (color: green)",
|
|
"@supports (width: yellow) or (height: green)",
|
|
"@supports (flogwizzle: purple)",
|
|
"@supports selector(.....nope)",
|
|
"@supports selector(::-thing-we-dont-support)",
|
|
"@supports selector(32) or selector(thing[foo??????bar])",
|
|
"@supports env(florb)",
|
|
"@supports env(123)",
|
|
];
|
|
println("\nThese should all be invalid:");
|
|
for (let testCase of invalidCases) {
|
|
testSupports(testCase, false);
|
|
}
|
|
});
|
|
</script>
|