1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
5 <title>Odd stretching of pixel-wide drawImage call
</title>
6 <script type=
"text/javascript" charset=
"utf-8">
7 window.addEventListener('DOMContentLoaded', init, true);
12 if (window.testRunner) {
13 testRunner.dumpAsText();
14 testRunner.waitUntilDone();
17 var canvas = document.getElementById(
"c");
20 ctx = canvas.getContext('
2d');
23 image.addEventListener('load', draw, false);
24 image.src = 'resources/orangePixels.gif';
28 var w = ctx.canvas.width;
29 var h = ctx.canvas.height;
30 // part between left corner and arrow
31 ctx.drawImage(image,
3,
2,
1,
1,
33 setTimeout(checkPixels,
0);
36 function checkPixels() {
37 var passed = areAllRowsUniform(ctx);
39 var result = document.getElementById('result');
41 result.innerHTML =
"PASSED";
43 result.innerHTML =
"FAILED";
45 if (window.testRunner)
46 testRunner.notifyDone();
49 function areAllRowsUniform(ctx) {
50 for (var y =
0; y < ctx.canvas.height; y++) {
51 if (!isRowUniform(ctx,y))
58 function isRowUniform(ctx, y) {
59 var start = getPixel(ctx,
0, y);
61 for (var i =
0; i < ctx.canvas.width; i++) {
62 if (!areEqual(start, getPixel(ctx, i, y)))
69 function areEqual(a, b) {
70 return a[
0] == b[
0] && a[
1] == b[
1] && a[
2] == b[
2] && a[
3] == b[
3];
73 function getPixel(ctx, x, y) {
74 var idata = ctx.getImageData(x,y,
1,
1);
82 <p>DrawImage with a source of a single pixel should draw one uniform color throughout. Neighboring pixels in the source image shouldn't affect the destination rect's output pixels
</p>
83 <p>(Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=
58267) (Radar: rdar://problem/
9148473)
</p>
85 <p> This canvas should be uniformly one color
</p>
87 <canvas id=
"c"</canvas>