| OLD | NEW |
| 1 <!doctype html> | 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 <canvas id="canvas" width="200" height="200"></canvas> | 4 <canvas id="canvas" width="200" height="200"></canvas> |
| 8 <script src="script-tests/canvas-path-context-stroke.js"></script> | 5 <script> |
| 6 |
| 7 var ctx = document.getElementById('canvas').getContext('2d'); |
| 8 |
| 9 function checkResult(expectedColors, sigma) { |
| 10 data = ctx.getImageData(75, 75, 1, 1).data; |
| 11 for (var i = 0; i < 4; i++) |
| 12 assert_approx_equals(data[i], expectedColors[i], sigma); |
| 13 } |
| 14 |
| 15 function drawRectangleOn(contextOrPath) { |
| 16 contextOrPath.rect(25, 25, 50, 50); |
| 17 } |
| 18 |
| 19 function testStrokeWith(path) { |
| 20 ctx.fillStyle = 'rgb(255,0,0)'; |
| 21 ctx.beginPath(); |
| 22 ctx.fillRect(0, 0, 100, 100); |
| 23 ctx.strokeStyle = 'rgb(0,255,0)'; |
| 24 ctx.lineWidth = 5; |
| 25 if (path) { |
| 26 ctx.stroke(path); |
| 27 } else { |
| 28 ctx.beginPath(); |
| 29 drawRectangleOn(ctx); |
| 30 ctx.stroke(); |
| 31 } |
| 32 checkResult([0, 255, 0, 255], 5); |
| 33 } |
| 34 |
| 35 test(function(t) { |
| 36 var path = new Path2D(); |
| 37 drawRectangleOn(path); |
| 38 |
| 39 testStrokeWith(); |
| 40 testStrokeWith(path); |
| 41 |
| 42 // Test exception cases. |
| 43 assert_throws(null, function() {ctx.stroke(null);}); |
| 44 assert_throws(null, function() {ctx.stroke(undefined);}); |
| 45 assert_throws(null, function() {ctx.stroke([]);}); |
| 46 assert_throws(null, function() {ctx.stroke({});}); |
| 47 }, "Series of tests to ensure stroke() works with optional path parameter."); |
| 48 </script> |
| 9 </body> | 49 </body> |
| OLD | NEW |