Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-large-dimensions.html |
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-dimensions.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-dimensions.html |
index 08f38a5b4af7f7ec09b74544b9efba6827398978..51cd946775b48168746cfca4fcf720d2c57c788a 100644 |
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-dimensions.html |
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-large-dimensions.html |
@@ -1,66 +1,34 @@ |
-<!DOCTYPE html> |
-<title>Canvas test: test large width/height values</title> |
-<script src="../../resources/js-test.js"></script> |
-<body> |
-<p>Tests that using reasonably large values for canvas.height and canvas.height don't cause a crash"</p> |
-<pre id="console"></pre> |
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> |
+<script src='../../resources/testharness.js'></script> |
+<script src='../../resources/testharnessreport.js'></script> |
+<canvas id='c' width='100' height='50'></canvas> |
<script> |
-var canvas = document.getElementById("c"); |
-var x, y, w=1, h=1; |
+// Tests that using reasonably large values for canvas.height and canvas.height do not cause a crash |
+var canvas = document.getElementById('c'); |
+var x, y, w = 1, h = 1; |
-testHeight(canvas, 1000); |
-testHeight(canvas, 10000); |
-testHeight(canvas, 32000); |
+function testLargeDimension(size, isWidth) { |
+ canvas.width = (isWidth ? size : 50); |
+ canvas.height = (isWidth ? 50 : size); |
+ var ctx = canvas.getContext('2d'); |
+ ctx.fillStyle = 'rgba(255, 255, 255, 1)'; |
+ assert_equals((isWidth ? canvas.width : canvas.height), size); |
+ x = canvas.width - 2; |
+ y = canvas.height - 2; |
+ ctx.fillRect(x, y, w, h); |
+ var data = ctx.getImageData(x, y, w, h).data; |
+ for (var i = 0; i < 4; i++) |
+ assert_equals(data[i], 255); |
+} |
-testWidth(canvas, 1000); |
-testWidth(canvas, 10000); |
-testWidth(canvas, 32000); |
+testScenarios = [['Test Width = 1000', 1000, true], |
+ ['Test Width = 10000', 10000, true], |
+ ['Test Width = 32000', 32000, true], |
+ |
+ ['Test Height = 1000', 1000, false], |
+ ['Test Height = 10000', 10000, false], |
+ ['Test Height = 32000', 32000, false]]; |
-function testHeight(canvas, height) { |
- canvas.width = 50; |
- canvas.height = height; |
- var ctx = canvas.getContext("2d"); |
- ctx.fillStyle = "rgba(255, 255, 255, 1)"; |
- var msg = "height == "+height; |
- if (canvas.height == height) |
- testPassed(msg); |
- else |
- testFailed(msg); |
- x = canvas.width-2; |
- y = canvas.height-2; |
- ctx.fillRect(x,y,w,h); |
- var data = ctx.getImageData(x,y,w,h); |
- for (var x = 0; x < 4; x++) { |
- var msg = "Actual: " + data.data[x] + " Expected: 255"; |
- if (data.data[x] == 255) |
- testPassed(msg); |
- else |
- testFailed(msg); |
- } |
-} |
+generate_tests(testLargeDimension, testScenarios); |
-function testWidth(canvas, width) { |
- canvas.height = 50; |
- canvas.width = width; |
- var ctx = canvas.getContext("2d"); |
- ctx.fillStyle = "rgba(255, 255, 255, 1)"; |
- var msg = "width == "+width; |
- if (canvas.width == width) |
- testPassed(msg); |
- else |
- testFailed(msg); |
- x = canvas.width-2; |
- y = canvas.height-2; |
- ctx.fillRect(x,y,w,h); |
- var data = ctx.getImageData(x,y,w,h); |
- for (var x = 0; x < 4; x++) { |
- var msg = "Actual: " + data.data[x] + " Expected: 255"; |
- if (data.data[x] == 255) |
- testPassed(msg); |
- else |
- testFailed(msg); |
- } |
-} |
</script> |