Skip to content

Commit c459325

Browse files
committed
update CanvasRenderingContext2D test
Adds the missing RGBA and long digit hex format tests.
1 parent 37ac465 commit c459325

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/browser/canvas/root.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Canvas API.
22
//! https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API
33

4+
const CanvasRenderingContext2D = @import("CanvasRenderingContext2D.zig");
45
const WebGLRenderingContext = @import("WebGLRenderingContext.zig");
5-
const ExtensionType = WebGLRenderingContext.Extension.Type;
6+
const Extension = WebGLRenderingContext.Extension;
67

78
pub const Interfaces = .{
8-
@import("CanvasRenderingContext2D.zig"),
9+
CanvasRenderingContext2D,
910
WebGLRenderingContext,
10-
ExtensionType.WEBGL_debug_renderer_info,
11+
Extension.Type.WEBGL_debug_renderer_info,
1112
};

src/tests/html/canvas.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<script src="../testing.js"></script>
33

4-
<script id=canvas>
4+
<script id=CanvasRenderingContext2D>
55
{
66
const element = document.createElement("canvas");
77
const ctx = element.getContext("2d");
@@ -11,7 +11,7 @@
1111
}
1212
</script>
1313

14-
<script id=canvas#fillStyle>
14+
<script id=CanvasRenderingContext2D#fillStyle>
1515
{
1616
const element = document.createElement("canvas");
1717
const ctx = element.getContext("2d");
@@ -25,6 +25,12 @@
2525
// No changes made if color is invalid.
2626
ctx.fillStyle = "invalid-color";
2727
testing.expectEqual(ctx.fillStyle, "#663399");
28+
ctx.fillStyle = "#fc0";
29+
testing.expectEqual(ctx.fillStyle, "#ffcc00");
30+
ctx.fillStyle = "#ff0000";
31+
testing.expectEqual(ctx.fillStyle, "#ff0000");
32+
ctx.fillStyle = "#fF00000F";
33+
testing.expectEqual(ctx.fillStyle, "rgba(255, 0, 0, 0.06)");
2834
}
2935
</script>
3036

0 commit comments

Comments
 (0)