-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1908136 [wpt PR 47148] - 2D canvas color parsing and serializatio…
…n, a=testonly Automatic update from web-platform-tests 2D canvas color parsing and serialization For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481. -- wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d wpt-pr: 47148 UltraBlame original commit: ba0041c24e1332e588896b9fb72ed44e32f1a385
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const canvas = document.body.appendChild(document.createElement("canvas")); | ||
const context = canvas.getContext("2d"); | ||
|
||
[ | ||
{ | ||
"input": "rgb(255, 0, 255)", | ||
"output": "#ff00ff" | ||
}, | ||
{ | ||
"input": "rgba(255, 0, 255, 1)", | ||
"output": "#ff00ff" | ||
}, | ||
{ | ||
"input": "#ff00ffff", | ||
"output": "#ff00ff" | ||
}, | ||
{ | ||
"input": "#ff00ff00", | ||
"output": "rgba(255, 0, 255, 0)" | ||
}, | ||
{ | ||
"input": "rgba(255, 0, 255, 0)", | ||
"output": "rgba(255, 0, 255, 0)" | ||
}, | ||
{ | ||
"input": "color(srgb 1 0 1)", | ||
"output": "color(srgb 1 0 1)" | ||
}, | ||
{ | ||
"input": "color(srgb 1 0 1 / 1)", | ||
"output": "color(srgb 1 0 1)" | ||
}, | ||
{ | ||
"input": "color(srgb 1 0 1/0)", | ||
"output": "color(srgb 1 0 1 / 0)" | ||
}, | ||
{ | ||
"input": "color(srgb 1 none 1)", | ||
"output": "color(srgb 1 none 1)" | ||
}, | ||
{ | ||
"input": "color(srgb none -1 2 / 3)", | ||
"output": "color(srgb none -1 2)" | ||
}, | ||
{ | ||
"input": "color(display-p3 0.96 0.76 \t 0.79)", | ||
"output": "color(display-p3 0.96 0.76 0.79)" | ||
}, | ||
{ | ||
"input": "lab(29% 39 20)", | ||
"output": "lab(29 39 20)" | ||
}, | ||
{ | ||
"input": "transparent", | ||
"output": "rgba(0, 0, 0, 0)" | ||
}, | ||
{ | ||
"input": "rgb(none none none)", | ||
"output": "#000000" | ||
}, | ||
{ | ||
"input": "rgb(300 none 400)", | ||
"output": "#ff00ff" | ||
} | ||
].forEach(({ input, output }) => { | ||
test(() => { | ||
["fillStyle", "strokeStyle", "shadowColor"].forEach(colorGetterSetter => { | ||
context[colorGetterSetter] = input; | ||
assert_equals(context[colorGetterSetter], output, colorGetterSetter); | ||
}); | ||
}, `'${input}' should serialize as '${output}'`); | ||
}); |