Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/2d.fillText.gradient.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/2d.fillText.gradient.html b/third_party/WebKit/LayoutTests/fast/canvas/2d.fillText.gradient.html |
| index 8f6d0e92fe49e877da70e0adda7ca15ecbde10c8..89f7fb616f697d604f18d67359810defa88ab2dd 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/2d.fillText.gradient.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/2d.fillText.gradient.html |
| @@ -1,55 +1,36 @@ |
| <!DOCTYPE html> |
| -<body> |
| -<p>On success, the square should have the bottom left portion of the base of the green I and red otherwise.</p> |
| -<canvas id="c" class="output" width="100" height="100"><p class="fallback">FAIL (fallback content)</p></canvas> |
| -<div id="console"></div> |
| - |
| +<title>Test the color gradient is applied properly for the rect in 2d canvas.</title> |
|
fs
2016/08/25 13:57:36
s/the rect/fillText()/
sivag
2016/08/25 14:00:09
Done.
Justin Novosad
2016/08/25 14:05:30
the color gradient -> that color gradient
the rect
sivag
2016/08/25 14:28:52
Done.
|
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<canvas width="100" height="100"></canvas> |
| <script> |
| - |
| -function drawCanvas(ctx) { |
| - |
| - ctx.fillStyle = '#f00'; |
| - ctx.fillRect(0,0,100,100); |
| - |
| - var gradient = ctx.createLinearGradient(0, 0, 100, 100); |
| - gradient.addColorStop(0, '#0f0'); |
| - gradient.addColorStop(1, '#0f0'); |
| - |
| - ctx.fillStyle = gradient; |
| - ctx.font = "500px Times"; |
| - |
| - ctx.fillText("I", -5, 100); |
| -} |
| - |
| -if (window.testRunner) |
| - testRunner.dumpAsText(); |
| - |
| -var canvas = document.getElementById('c'); |
| -var ctx = canvas.getContext("2d"); |
| -drawCanvas(ctx); |
| - |
| -// Check that the letter rendered appropriately |
| -var renderedCorrectly = true; |
| - |
| -// Check for a green pixel from the text |
| -var imageData = ctx.getImageData(75,75,1,1); |
| -if (imageData.data[0] != 0) renderedCorrectly = false; |
| -if (imageData.data[1] != 255) renderedCorrectly = false; |
| -if (imageData.data[2] != 0) renderedCorrectly = false; |
| -if (imageData.data[3] != 255) renderedCorrectly = false; |
| - |
| -// Check the red pixel outside of text wasn't touched |
| -var imageData = ctx.getImageData(25,25,1,1); |
| -if (imageData.data[0] != 255) renderedCorrectly = false; |
| -if (imageData.data[1] != 0) renderedCorrectly = false; |
| -if (imageData.data[2] != 0) renderedCorrectly = false; |
| -if (imageData.data[3] != 255) renderedCorrectly = false; |
| - |
| -if (renderedCorrectly) |
| - document.getElementById("console").innerHTML = "TEST PASSED"; |
| -else |
| - document.getElementById("console").innerHTML = "TEST FAILED"; |
| - |
| +test(function() { |
| + function drawCanvas(ctx) { |
|
Justin Novosad
2016/08/25 14:05:30
I know it was like this before, but this function
sivag
2016/08/25 14:28:52
Done.
|
| + ctx.fillStyle = '#f00'; |
| + ctx.fillRect(0,0,100,100); |
| + var gradient = ctx.createLinearGradient(0, 0, 100, 100); |
| + gradient.addColorStop(0, '#0f0'); |
| + gradient.addColorStop(1, '#0f0'); |
| + ctx.fillStyle = gradient; |
| + ctx.font = "500px Times"; |
| + ctx.fillText("I", -5, 100); |
| + } |
| + var canvas = document.querySelector('canvas'); |
| + var ctx = canvas.getContext("2d"); |
| + drawCanvas(ctx); |
| + |
| + // Check for a green pixel from the text. |
| + var imageData = ctx.getImageData(75,75,1,1); |
| + assert_equals(imageData.data[0], 0, "red"); |
| + assert_equals(imageData.data[1], 255, "green"); |
| + assert_equals(imageData.data[2], 0, "blue"); |
| + assert_equals(imageData.data[3], 255, "alpha"); |
| + |
| + // Check the red pixel outside of text wasn't touched. |
| + var imageData = ctx.getImageData(25,25,1,1); |
| + assert_equals(imageData.data[0], 255, "red"); |
| + assert_equals(imageData.data[1], 0, "green"); |
| + assert_equals(imageData.data[2], 0, "blue"); |
| + assert_equals(imageData.data[3], 255, "alpha"); |
| +}); |
| </script> |
| -</body> |
| -</html> |