OLD | NEW |
| (Empty) |
1 description("Test for invalid input of setLineDash, getLineDash and lineDashOffs
et"); | |
2 | |
3 var canvas = document.createElement('canvas'); | |
4 document.body.appendChild(canvas); | |
5 canvas.setAttribute('width', '700'); | |
6 canvas.setAttribute('height', '700'); | |
7 var ctx = canvas.getContext('2d'); | |
8 var initialLineDash = [1.5, 2.5]; | |
9 var initialLineDashOffset = 1.5; | |
10 | |
11 function resetLineDash() { | |
12 ctx.setLineDash(initialLineDash); | |
13 ctx.lineDashOffset = initialLineDashOffset; | |
14 } | |
15 | |
16 function trySettingLineDash(value) { | |
17 resetLineDash(); | |
18 ctx.setLineDash(value); | |
19 return ctx.getLineDash(); | |
20 } | |
21 | |
22 function trySettingLineDashWithNoArgs() { | |
23 resetLineDash(); | |
24 ctx.setLineDash(); | |
25 return ctx.getLineDash(); | |
26 } | |
27 | |
28 function trySettingLineDashOffset(value) { | |
29 resetLineDash(); | |
30 ctx.lineDashOffset = value; | |
31 return ctx.lineDashOffset; | |
32 } | |
33 | |
34 shouldBe("trySettingLineDash([1, -1])", "initialLineDash"); | |
35 shouldBe("trySettingLineDash([1, Infinity])", "initialLineDash"); | |
36 shouldBe("trySettingLineDash([1, -Infinity])", "initialLineDash"); | |
37 shouldBe("trySettingLineDash([1, NaN])", "initialLineDash"); | |
38 shouldBe("trySettingLineDash([1, 'string'])", "initialLineDash"); | |
39 shouldThrow("trySettingLineDashWithNoArgs()", '"TypeError: Failed to execute \'s
etLineDash\' on \'CanvasRenderingContext2D\': 1 argument required, but only 0 pr
esent."'); | |
40 | |
41 shouldBe("trySettingLineDashOffset(Infinity)", "initialLineDashOffset"); | |
42 shouldBe("trySettingLineDashOffset(-Infinity)", "initialLineDashOffset"); | |
43 shouldBe("trySettingLineDashOffset(NaN)", "initialLineDashOffset"); | |
44 shouldBe("trySettingLineDashOffset('string')", "initialLineDashOffset"); | |
OLD | NEW |