OLD | NEW |
---|---|
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <script src="../../resources/testharness.js"></script> |
2 <html> | 2 <script src="../../resources/testharnessreport.js"></script> |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | 3 <body> |
7 <script src="script-tests/canvas-invalid-values.js"></script> | 4 <script> |
5 | |
6 ctx = document.createElement('canvas').getContext('2d'); | |
7 | |
8 function trySettingMiterLimit(value) { | |
9 ctx.miterLimit = 1.5; | |
10 ctx.miterLimit = value; | |
11 return ctx.miterLimit; | |
12 } | |
13 | |
14 function trySettingLineWidth(value) { | |
15 ctx.lineWidth = 1.5; | |
16 ctx.lineWidth = value; | |
17 return ctx.lineWidth; | |
18 } | |
19 | |
20 function trySettingShadowBlur(value) { | |
21 ctx.shadowBlur = 1.5; | |
22 ctx.shadowBlur = value; | |
23 return ctx.shadowBlur; | |
24 } | |
25 | |
26 function trySettingShadowOffsetX(value) { | |
27 ctx.shadowOffsetX = 1.5; | |
28 ctx.shadowOffsetX = value; | |
29 return ctx.shadowOffsetX; | |
30 } | |
31 | |
32 function trySettingShadowOffsetY(value) { | |
33 ctx.shadowOffsetY = 1.5; | |
34 ctx.shadowOffsetY = value; | |
35 return ctx.shadowOffsetY; | |
36 } | |
37 | |
38 test(function(t) { | |
39 generate_tests( | |
Justin Novosad
2017/02/16 15:34:30
Why generate_tests inside a test?
zakerinasab
2017/02/16 17:48:12
Huh. Strange mistake. Corrected.
| |
40 assert_equals, [ | |
41 [ "Invalid value has no effect", trySettingMiterLimit(1), 1], | |
42 [ "Invalid value has no effect", trySettingMiterLimit(0), 1.5], | |
43 [ "Invalid value has no effect", trySettingMiterLimit(-1), 1.5], | |
44 [ "Invalid value has no effect", trySettingMiterLimit(Infinity), 1.5 ], | |
45 [ "Invalid value has no effect", trySettingMiterLimit(-Infinity), 1. 5], | |
46 [ "Invalid value has no effect", trySettingMiterLimit(NaN), 1.5], | |
47 [ "Invalid value has no effect", trySettingMiterLimit('string'), 1.5 ], | |
48 [ "Invalid value has no effect", trySettingMiterLimit(true), 1], | |
49 [ "Invalid value has no effect", trySettingMiterLimit(false), 1.5], | |
50 | |
51 [ "Invalid value has no effect", trySettingLineWidth(1), 1], | |
52 [ "Invalid value has no effect", trySettingLineWidth(0), 1.5], | |
53 [ "Invalid value has no effect", trySettingLineWidth(-1), 1.5], | |
54 [ "Invalid value has no effect", trySettingLineWidth(Infinity), 1.5] , | |
55 [ "Invalid value has no effect", trySettingLineWidth(-Infinity), 1.5 ], | |
56 [ "Invalid value has no effect", trySettingLineWidth(NaN), 1.5], | |
57 [ "Invalid value has no effect", trySettingLineWidth('string'), 1.5] , | |
58 [ "Invalid value has no effect", trySettingLineWidth(true), 1], | |
59 [ "Invalid value has no effect", trySettingLineWidth(false), 1.5], | |
60 | |
61 [ "Invalid value has no effect", trySettingShadowBlur(1), 1], | |
62 [ "Invalid value has no effect", trySettingShadowBlur(0), 0], | |
63 [ "Invalid value has no effect", trySettingShadowBlur(-1), 1.5], | |
64 [ "Invalid value has no effect", trySettingShadowBlur(Infinity), 1.5 ], | |
65 [ "Invalid value has no effect", trySettingShadowBlur(-Infinity), 1. 5], | |
66 [ "Invalid value has no effect", trySettingShadowBlur(NaN), 1.5], | |
67 [ "Invalid value has no effect", trySettingShadowBlur('string'), 1.5 ], | |
68 [ "Invalid value has no effect", trySettingShadowBlur(true), 1], | |
69 [ "Invalid value has no effect", trySettingShadowBlur(false), 0], | |
70 | |
71 [ "Invalid value has no effect", trySettingShadowOffsetX(1), 1], | |
72 [ "Invalid value has no effect", trySettingShadowOffsetX(0), 0], | |
73 [ "Invalid value has no effect", trySettingShadowOffsetX(-1), -1], | |
74 [ "Invalid value has no effect", trySettingShadowOffsetX(Infinity), 1.5], | |
75 [ "Invalid value has no effect", trySettingShadowOffsetX(-Infinity), 1.5], | |
76 [ "Invalid value has no effect", trySettingShadowOffsetX(NaN), 1.5], | |
77 [ "Invalid value has no effect", trySettingShadowOffsetX('string'), 1.5], | |
78 [ "Invalid value has no effect", trySettingShadowOffsetX(true), 1], | |
79 [ "Invalid value has no effect", trySettingShadowOffsetX(false), 0], | |
80 | |
81 [ "Invalid value has no effect", trySettingShadowOffsetY(1), 1], | |
82 [ "Invalid value has no effect", trySettingShadowOffsetY(0), 0], | |
83 [ "Invalid value has no effect", trySettingShadowOffsetY(-1), -1], | |
84 [ "Invalid value has no effect", trySettingShadowOffsetY(Infinity), 1.5], | |
85 [ "Invalid value has no effect", trySettingShadowOffsetY(-Infinity), 1.5], | |
86 [ "Invalid value has no effect", trySettingShadowOffsetY(NaN), 1.5], | |
87 [ "Invalid value has no effect", trySettingShadowOffsetY('string'), 1.5], | |
88 [ "Invalid value has no effect", trySettingShadowOffsetY(true), 1], | |
89 [ "Invalid value has no effect", trySettingShadowOffsetY(false), 0], | |
90 ] | |
91 ); | |
92 }, "Test that setting various CanvasRenderingContext2D properties to invalid val ues has no effect."); | |
93 </script> | |
8 </body> | 94 </body> |
9 </html> | |
OLD | NEW |