1 <!-- This is a test for crbug.com/392765, in which Copy image for
2 WebGL elements were crashing. Must be run with the threaded
3 compositor enabled. -->
5 <script src=
"../../resources/js-test.js"></script>
10 if (!window
.testRunner
) {
11 testFailed("Requires window.testRunner");
13 testRunner
.waitUntilDone();
14 testRunner
.dumpAsText();
15 window
.requestAnimationFrame(initTest
);
22 var canvas
= document
.getElementById("c");
23 var gl
= canvas
.getContext("webgl");
25 testFailed("Test requires WebGL");
26 testRunner
.notifyDone();
30 gl
.clearColor(1, 0, 0, 1);
31 gl
.clear(gl
.COLOR_BUFFER_BIT
| gl
.DEPTH_BUFFER_BIT
);
33 window
.requestAnimationFrame(runTest
);
38 testRunner
.copyImageAtAndCapturePixelsAsyncThen(50, 50, completionCallback
);
40 debug('error in runTest');
42 testRunner
.notifyDone();
47 function fetchPixelAt(x
, y
, width
, height
, snapshot
) {
48 var data
= new Uint8Array(snapshot
);
50 data
[4 * (width
* y
+ x
) + 0],
51 data
[4 * (width
* y
+ x
) + 1],
52 data
[4 * (width
* y
+ x
) + 2],
53 data
[4 * (width
* y
+ x
) + 3]
57 function completionCallback(width
, height
, snapshot
) {
59 fetchPixelAt(50, 50, width
, height
, snapshot
);
60 shouldBeCloseTo('pixel[0]', 255, tolerance
);
61 shouldBeCloseTo('pixel[1]', 0, tolerance
);
62 shouldBeCloseTo('pixel[2]', 0, tolerance
);
64 debug('error in completionCallback');
66 testRunner
.notifyDone();
69 testRunner
.notifyDone();
76 <canvas id=
"c" width=
"200" height=
"200" class=
"nomargin"></canvas>
77 <div id=
"console"></div>