diff options
author | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2013-02-13 17:01:31 +0000 |
---|---|---|
committer | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2013-02-13 17:01:31 +0000 |
commit | 5f91b4f314012fb0293ba5e9fc04674920e0797f (patch) | |
tree | 82e8be9ca242c63289f1744139e9a0e62cff98aa /third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js | |
parent | 2dfcb0a85fbcc8e9864f7082717cdbea944061eb (diff) | |
download | chromium_src-5f91b4f314012fb0293ba5e9fc04674920e0797f.zip chromium_src-5f91b4f314012fb0293ba5e9fc04674920e0797f.tar.gz chromium_src-5f91b4f314012fb0293ba5e9fc04674920e0797f.tar.bz2 |
The 2D Canvas functions fillText()/strokeText() should display nothing when maxWidth is less then or equal to zero
https://bugs.webkit.org/show_bug.cgi?id=102656
Patch by Rashmi Shyamasundar <rashmi.s2@samsung.com> on 2013-02-13
Reviewed by Dirk Schulze.
The functions fillText()/strokeText() should not display anything when
maxWidth is less than or equal to zero, according to spec :
http://www.w3.org/TR/2dcontext/#text-preparation-algorithm
Source/WebCore:
Test: fast/canvas/canvas-fillText-maxWidth-zero.html
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawTextInternal):
LayoutTests:
* fast/canvas/canvas-fillText-invalid-maxWidth-expected.txt: Added.
* fast/canvas/canvas-fillText-invalid-maxWidth.html: Added.
* fast/canvas/canvas-strokeText-invalid-maxWidth-expected.txt: Added.
* fast/canvas/canvas-strokeText-invalid-maxWidth.html: Added.
* fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js: Added.
* fast/canvas/script-tests/canvas-strokeText-invalid-maxWidth.js: Added.
git-svn-id: svn://svn.chromium.org/blink/trunk@142754 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js')
-rw-r--r-- | third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js b/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js new file mode 100644 index 0000000..69bf7dd --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-fillText-invalid-maxWidth.js @@ -0,0 +1,46 @@ +descriptionQuiet("Series of tests to ensure that fillText() does not display any text when maxWidth is invalid.");
+
+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';
+
+debug("Test canvas.fillText() with maxWidth zero");
+ctx.fillStyle = '#f00';
+ctx.fillText("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;
+for (var i = 0; i < h; ++i) {
+ for (var j = 0; j < w; ++j) {
+ if (d[4 * (w * i + j) + 0] != 0) shouldBe("d[4 * (w * i + j) + 0]", "0");
+ if (d[4 * (w * i + j) + 1] != 255) shouldBe("d[4 * (w * i + j) + 1]", "255");
+ if (d[4 * (w * i + j) + 2] != 0) shouldBe("d[4 * (w * i + j) + 2]", "0");
+ if (d[4 * (w * i + j) + 3] != 255) shouldBe("d[4 * (w * i + j) + 3]", "255");
+ }
+}
+
+ctx.fillStyle = '#0f0';
+ctx.fillRect(0, 0, canvasWidth, canvasHeight);
+debug("Test canvas.fillText() with maxWidth -1");
+ctx.fillStyle = '#f00';
+ctx.fillText("fail fail fail fail fail", 5, 35, -1);
+
+var imageData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
+var w = imageData.width, h = imageData.height, d = imageData.data;
+for (var i = 0; i < h; ++i) {
+ for (var j = 0; j < w; ++j) {
+ if (d[4 * (w * i + j) + 0] != 0) shouldBe("d[4 * (w * i + j) + 0]", "0");
+ if (d[4 * (w * i + j) + 1] != 255) shouldBe("d[4 * (w * i + j) + 1]", "255");
+ if (d[4 * (w * i + j) + 2] != 0) shouldBe("d[4 * (w * i + j) + 2]", "0");
+ if (d[4 * (w * i + j) + 3] != 255) shouldBe("d[4 * (w * i + j) + 3]", "255");
+ }
+}
+
|