diff options
author | Shannon Booth <shannon.ml.booth@gmail.com> | 2023-06-05 12:40:54 +1200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-06-05 06:54:33 +0200 |
commit | a9e37be7a0c51091d9a4b072a771f9790a53fc2e (patch) | |
tree | 6c8e1856aedbb001f159f72005007e560ac35bf3 | |
parent | 59cab85002f0ae950c1325b093971945be73fae7 (diff) | |
download | serenity-a9e37be7a0c51091d9a4b072a771f9790a53fc2e.zip |
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
bc54560e5942c9ff4b9049c034ad09a9f8446fb6. Add in some basic tests for
this now that we are compliant with the specification.
-rw-r--r-- | Tests/LibWeb/Text/expected/css/legacy-color-value.txt | 8 | ||||
-rw-r--r-- | Tests/LibWeb/Text/input/css/legacy-color-value.html | 24 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Tests/LibWeb/Text/expected/css/legacy-color-value.txt b/Tests/LibWeb/Text/expected/css/legacy-color-value.txt new file mode 100644 index 0000000000..62f1aaec5f --- /dev/null +++ b/Tests/LibWeb/Text/expected/css/legacy-color-value.txt @@ -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) diff --git a/Tests/LibWeb/Text/input/css/legacy-color-value.html b/Tests/LibWeb/Text/input/css/legacy-color-value.html new file mode 100644 index 0000000000..9e14ff69ce --- /dev/null +++ b/Tests/LibWeb/Text/input/css/legacy-color-value.html @@ -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> |