2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
10 <meta charset=
"utf-8">
11 <title>WebGL Behavior After Alert and Read Pixels Test
</title>
12 <link rel=
"stylesheet" href=
"../resources/js-test-style.css"/>
13 <script src=
"../../devtools/src/debug/webgl-debug.js"></script>
14 <script src=
"../js/js-test-pre.js"></script>
15 <script src=
"../js/webgl-test-utils.js"></script>
18 <canvas id=
"canvas" width=
"100" height=
"100"> </canvas>
19 <div id=
"description">Verify WebGL behavior after an alert and then a readPixels()
</div>
20 <div id=
"console"></div>
24 function checkPixels(buf
, width
, height
, thresh
) {
25 for (var yy
= 0; yy
< height
; ++yy
) {
26 for (var xx
= 0; xx
< width
; ++xx
) {
27 var offset
= (yy
* width
+ xx
) * 4;
28 if (Math
.abs(buf
[offset
] - 255) > thresh
||
29 Math
.abs(buf
[offset
+ 1] - 0) > thresh
||
30 Math
.abs(buf
[offset
+ 2] - 0) > thresh
) {
31 testFailed("Checking pixels");
36 testPassed("Checking pixels");
40 var wtu
= WebGLTestUtils
;
41 var gl
= wtu
.create3DContext("canvas");
42 gl
.clearColor(1, 0, 0, 1);
43 gl
.clear(gl
.COLOR_BUFFER_BIT
);
44 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "setup should succeed");
46 wtu
.checkCanvas(gl
, [255, 0, 0, 255], undefined, 3);
48 alert("Click me to continue");
50 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "setup should succeed");
51 wtu
.checkCanvas(gl
, [255, 0, 0, 255], undefined, 3);
53 alert("Click me to continue");
55 gl
.clearColor(1, 0, 0, 1);
56 gl
.clear(gl
.COLOR_BUFFER_BIT
);
57 wtu
.checkCanvas(gl
, [255, 0, 0, 255], undefined, 3);
60 var successfullyParsed
= true;
62 <script src=
"../js/js-test-post.js"></script>