File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments