Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeText-invalid-maxWidth.html

Issue 2690183006: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeText-invalid-maxWidth.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeText-invalid-maxWidth.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeText-invalid-maxWidth.html
index 91d9640a748daa61c3b943a0e69337a8df9f1eb1..30fe35f01110e4e0c6909b8c0ee96e676a6d7f44 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeText-invalid-maxWidth.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeText-invalid-maxWidth.html
@@ -1,10 +1,62 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<body>
-<script src="script-tests/canvas-strokeText-invalid-maxWidth.js"></script>
+<script>
+test(function(t) {
+
+ var canvas = document.createElement('canvas');
+ var ctx = canvas.getContext('2d');
+ var canvasWidth = 100;
+ var canvasHeight = 50;
+ canvas.setWidth = canvasWidth;
+ canvas.setHeight = canvasHeight;
+
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, canvasWidth, canvasHeight);
+ ctx.font = '35px Arial, sans-serif';
+
+ ctx.strokeStyle = '#f00';
+ ctx.strokeText("fail fail fail fail fail", 5, 35, 0);
+
+ var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
+ var w = imageData.width, h = imageData.height, d = imageData.data;
+ var testPassed = true;
+ var expectedColor = [0, 255, 0, 255];
+ mainLoop1:
+ for (var i = 0; i < h; ++i) {
+ for (var k = 0; k < 4; ++k) {
+ var j = w;
+ while (--j > 0 && d[4 * (w * i + j) + k] == expectedColor[k]);
+ testPassed = testPassed && j == 0;
+ if(!testPassed)
+ break mainLoop1;
+
+ }
+ }
+ assert_true(testPassed);
+
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, canvasWidth, canvasHeight);
+
+ ctx.strokeStyle = '#f00';
+ ctx.strokeText("fail fail fail fail fail", 5, 35, -1);
+
+ imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
+ d = imageData.data;
+ testPassed = true;
+ mainLoop2:
+ for (var i = 0; i < h; ++i) {
+ for (var k = 0; k < 4; ++k) {
+ var j = w;
+ while (--j > 0 && d[4 * (w * i + j) + k] == expectedColor[k]);
+ testPassed = testPassed && j == 0;
+ if(!testPassed)
+ break mainLoop2;
+ }
+ }
+ assert_true(testPassed);
+
+}, 'Series of tests to ensure that strokeText() does not display any text when maxWidth is invalid.');
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698