Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / script-tests / canvas-lineDash-invalid.js
blob35f73df6fd14e2150422c31bd55f7362f610df6f
1 description("Test for invalid input of setLineDash, getLineDash and lineDashOffset");
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;
11 function resetLineDash() {
12 ctx.setLineDash(initialLineDash);
13 ctx.lineDashOffset = initialLineDashOffset;
16 function trySettingLineDash(value) {
17 resetLineDash();
18 ctx.setLineDash(value);
19 return ctx.getLineDash();
22 function trySettingLineDashWithNoArgs() {
23 resetLineDash();
24 ctx.setLineDash();
25 return ctx.getLineDash();
28 function trySettingLineDashOffset(value) {
29 resetLineDash();
30 ctx.lineDashOffset = value;
31 return ctx.lineDashOffset;
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 \'setLineDash\' on \'CanvasRenderingContext2D\': 1 argument required, but only 0 present."');
41 shouldBe("trySettingLineDashOffset(Infinity)", "initialLineDashOffset");
42 shouldBe("trySettingLineDashOffset(-Infinity)", "initialLineDashOffset");
43 shouldBe("trySettingLineDashOffset(NaN)", "initialLineDashOffset");
44 shouldBe("trySettingLineDashOffset('string')", "initialLineDashOffset");