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..c4f46960c216b100c09785ed35f3dd367b7c3102 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,31 @@ |
<!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 that color gradient is applied properly for fillText() in 2d canvas.</title> |
+<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() { |
+ var canvas = document.querySelector('canvas'); |
+ var ctx = canvas.getContext("2d"); |
+ 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); |
+ // 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> |