| <script> |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| function runTest() { |
| |
| var canvas = document.querySelector("canvas"); |
| var context = canvas.getContext('2d'); |
| |
| context.shadowOffsetX = 0; |
| context.shadowOffsetY = 10; |
| context.shadowBlur = 0; |
| context.shadowColor = "rgb(255, 0, 0)"; |
| |
| context.font = "80px sans-serif"; |
| |
| var gradient = context.createLinearGradient(0, 0, 0, 100); |
| gradient.addColorStop(0, "blue"); |
| gradient.addColorStop(1, "blue"); |
| |
| context.fillStyle = gradient; |
| context.fillText("hello", 10, 95); |
| |
| // If we correctly drew the shadow, there will be some |
| // red pixels along the bottom line of the canvas. |
| |
| var buffer = context.getImageData(0, canvas.height - 1, canvas.width, 1); |
| var passed = false; |
| for (var i = 0; i < canvas.width; ++i) { |
| if (buffer.data[i * 4] > 0) { |
| passed = true; |
| break; |
| } |
| } |
| document.querySelector("p").textContent = passed ? "PASSED" : "FAILED"; |
| } |
| |
| window.addEventListener("load", runTest, false); |
| |
| </script> |
| <canvas width="200" height="100"></canvas> |
| <p></p> |