Skip to content

Commit dd079f0

Browse files
committed
update canvas test
1 parent d193ab6 commit dd079f0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/tests/html/canvas.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22
<script src="../testing.js"></script>
33

44
<script id=canvas>
5+
{
56
const element = document.createElement("canvas");
67
const ctx = element.getContext("2d");
78
testing.expectEqual(true, ctx instanceof CanvasRenderingContext2D);
8-
// We can't really test this but let's try to call it.
9+
// We can't really test this but let's try to call it at least.
910
ctx.fillRect(0, 0, 0, 0);
10-
testing.expectEqual("", ctx.fillStyle);
11+
}
12+
</script>
13+
14+
<script id=canvas#fillStyle>
15+
{
16+
const element = document.createElement("canvas");
17+
const ctx = element.getContext("2d");
18+
19+
// Black by default.
20+
testing.expectEqual(ctx.fillStyle, "#000000");
21+
ctx.fillStyle = "red";
22+
testing.expectEqual(ctx.fillStyle, "#ff0000");
23+
ctx.fillStyle = "rebeccapurple";
24+
testing.expectEqual(ctx.fillStyle, "#663399");
25+
// No changes made if color is invalid.
26+
ctx.fillStyle = "invalid-color";
27+
testing.expectEqual(ctx.fillStyle, "#663399");
28+
}
1129
</script>

0 commit comments

Comments
 (0)