1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:07:34 +00:00

Tests/LibWeb: Add some text tests for 'parsing a legacy color value'

I was not aware of this framework back when implementing this back in
bc54560e59. Add in some basic tests for
this now that we are compliant with the specification.
This commit is contained in:
Shannon Booth 2023-06-05 12:40:54 +12:00 committed by Andreas Kling
parent 59cab85002
commit a9e37be7a0
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,8 @@
'red' => rgb(255, 0, 0)
'#408080' => rgb(64, 128, 128)
'transparent' => rgba(0, 0, 0, 0)
' GreeN ' => rgb(0, 128, 0)
'cafe' => rgb(202, 254, 0)
'' => rgba(0, 0, 0, 0)
'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => rgb(219, 239, 234)
'#emoji above U+FFFF 🙃' => rgb(224, 176, 255)

View file

@ -0,0 +1,24 @@
<script src="../include.js"></script>
<script>
test(() => {
function checkColor(color) {
document.body.bgColor = color;
const computedStyle = getComputedStyle(document.body);
const bgcolor = computedStyle.backgroundColor;
println(`'${color}' => ${bgcolor}`);
}
for (color of [
"red",
"#408080",
"transparent",
" GreeN ",
"cafe",
"",
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", // longer than 128 chars of hex
"#emoji above U+FFFF 🙃",
]) {
checkColor(color);
}
});
</script>