summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/drawImageFromRect_withToDataURLAsSource.html
blob: 04512ef7af777d4e88effefc0d785a676f0e396d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<html>
<head>
<script>

function init()
{
	if (window.testRunner)
		window.testRunner.dumpAsText();

    var imgCanvas = document.getElementById("c1");
    var imgCanvas2 = document.getElementById("c2");

    var imgCtx = imgCanvas.getContext("2d");
    var imgCtx2 = imgCanvas2.getContext("2d");
	imgCtx.fillStyle = '#0f0';
    imgCtx.fillRect(0,0,32,32);

    var newImage =  new Image();
    newImage.src = imgCanvas.toDataURL();

	imgCtx2.fillStyle = '#0f0';
	imgCtx2.fillRect(0,0,32,32);
	imgCtx2.drawImageFromRect(newImage, 
		0, 1, 1, 1,
		0, 0, 32, 32, 'source-over');

	var result = document.getElementById("result");
	var data = imgCtx2.getImageData(0,0,1,1).data;
	var red = data[0];
	var green = data[1];
	var blue = data[2];
	var alpha = data[3];
	if (red != 0 || green != 255 || blue != 0 || alpha != 255)
		result.innerHTML = "FAILED";
	else
		result.innerHTML = "PASSED";
}

</script>
</head>
<body onload="init()">
<canvas id="c1" width="32px" height="32px"></canvas>
<canvas id="c2" width="32px" height="32px"></canvas>
<a>This test exercises a webkit specific canvas routine drawImageFromRect. This test should pass and never crash. <rdar://problem/9125032> </a>
<a id="result"></a>
</body>
</html>