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 // Test that setting various CanvasRenderingContext2D properties to invalid valu
es has no effect. |
| 7 ctx = document.createElement('canvas').getContext('2d'); |
| 8 |
| 9 function trySettingMiterLimit(value) { |
| 10 ctx.miterLimit = 1.5; |
| 11 ctx.miterLimit = value; |
| 12 return ctx.miterLimit; |
| 13 } |
| 14 |
| 15 function trySettingLineWidth(value) { |
| 16 ctx.lineWidth = 1.5; |
| 17 ctx.lineWidth = value; |
| 18 return ctx.lineWidth; |
| 19 } |
| 20 |
| 21 function trySettingShadowBlur(value) { |
| 22 ctx.shadowBlur = 1.5; |
| 23 ctx.shadowBlur = value; |
| 24 return ctx.shadowBlur; |
| 25 } |
| 26 |
| 27 function trySettingShadowOffsetX(value) { |
| 28 ctx.shadowOffsetX = 1.5; |
| 29 ctx.shadowOffsetX = value; |
| 30 return ctx.shadowOffsetX; |
| 31 } |
| 32 |
| 33 function trySettingShadowOffsetY(value) { |
| 34 ctx.shadowOffsetY = 1.5; |
| 35 ctx.shadowOffsetY = value; |
| 36 return ctx.shadowOffsetY; |
| 37 } |
| 38 |
| 39 var testScenarios = [ |
| 40 [ "Invalid value has no effect", trySettingMiterLimit(1), 1], |
| 41 [ "Invalid value has no effect", trySettingMiterLimit(0), 1.5], |
| 42 [ "Invalid value has no effect", trySettingMiterLimit(-1), 1.5], |
| 43 [ "Invalid value has no effect", trySettingMiterLimit(Infinity), 1.5], |
| 44 [ "Invalid value has no effect", trySettingMiterLimit(-Infinity), 1.5], |
| 45 [ "Invalid value has no effect", trySettingMiterLimit(NaN), 1.5], |
| 46 [ "Invalid value has no effect", trySettingMiterLimit('string'), 1.5], |
| 47 [ "Invalid value has no effect", trySettingMiterLimit(true), 1], |
| 48 [ "Invalid value has no effect", trySettingMiterLimit(false), 1.5], |
| 49 |
| 50 [ "Invalid value has no effect", trySettingLineWidth(1), 1], |
| 51 [ "Invalid value has no effect", trySettingLineWidth(0), 1.5], |
| 52 [ "Invalid value has no effect", trySettingLineWidth(-1), 1.5], |
| 53 [ "Invalid value has no effect", trySettingLineWidth(Infinity), 1.5], |
| 54 [ "Invalid value has no effect", trySettingLineWidth(-Infinity), 1.5], |
| 55 [ "Invalid value has no effect", trySettingLineWidth(NaN), 1.5], |
| 56 [ "Invalid value has no effect", trySettingLineWidth('string'), 1.5], |
| 57 [ "Invalid value has no effect", trySettingLineWidth(true), 1], |
| 58 [ "Invalid value has no effect", trySettingLineWidth(false), 1.5], |
| 59 |
| 60 [ "Invalid value has no effect", trySettingShadowBlur(1), 1], |
| 61 [ "Invalid value has no effect", trySettingShadowBlur(0), 0], |
| 62 [ "Invalid value has no effect", trySettingShadowBlur(-1), 1.5], |
| 63 [ "Invalid value has no effect", trySettingShadowBlur(Infinity), 1.5], |
| 64 [ "Invalid value has no effect", trySettingShadowBlur(-Infinity), 1.5], |
| 65 [ "Invalid value has no effect", trySettingShadowBlur(NaN), 1.5], |
| 66 [ "Invalid value has no effect", trySettingShadowBlur('string'), 1.5], |
| 67 [ "Invalid value has no effect", trySettingShadowBlur(true), 1], |
| 68 [ "Invalid value has no effect", trySettingShadowBlur(false), 0], |
| 69 |
| 70 [ "Invalid value has no effect", trySettingShadowOffsetX(1), 1], |
| 71 [ "Invalid value has no effect", trySettingShadowOffsetX(0), 0], |
| 72 [ "Invalid value has no effect", trySettingShadowOffsetX(-1), -1], |
| 73 [ "Invalid value has no effect", trySettingShadowOffsetX(Infinity), 1.5], |
| 74 [ "Invalid value has no effect", trySettingShadowOffsetX(-Infinity), 1.5], |
| 75 [ "Invalid value has no effect", trySettingShadowOffsetX(NaN), 1.5], |
| 76 [ "Invalid value has no effect", trySettingShadowOffsetX('string'), 1.5], |
| 77 [ "Invalid value has no effect", trySettingShadowOffsetX(true), 1], |
| 78 [ "Invalid value has no effect", trySettingShadowOffsetX(false), 0], |
| 79 |
| 80 [ "Invalid value has no effect", trySettingShadowOffsetY(1), 1], |
| 81 [ "Invalid value has no effect", trySettingShadowOffsetY(0), 0], |
| 82 [ "Invalid value has no effect", trySettingShadowOffsetY(-1), -1], |
| 83 [ "Invalid value has no effect", trySettingShadowOffsetY(Infinity), 1.5], |
| 84 [ "Invalid value has no effect", trySettingShadowOffsetY(-Infinity), 1.5], |
| 85 [ "Invalid value has no effect", trySettingShadowOffsetY(NaN), 1.5], |
| 86 [ "Invalid value has no effect", trySettingShadowOffsetY('string'), 1.5], |
| 87 [ "Invalid value has no effect", trySettingShadowOffsetY(true), 1], |
| 88 [ "Invalid value has no effect", trySettingShadowOffsetY(false), 0], |
| 89 ]; |
| 90 |
| 91 generate_tests(assert_equals, testScenarios); |
| 92 |
| 93 </script> |
8 </body> | 94 </body> |
9 </html> | |
OLD | NEW |