readpixels-after-alert.html (1808B)
1 <!-- 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. 5 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 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> 16 </head> 17 <body> 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> 21 <script> 22 "use strict"; 23 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"); 32 return false; 33 } 34 } 35 } 36 testPassed("Checking pixels"); 37 return true; 38 } 39 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"); 45 46 wtu.checkCanvas(gl, [255, 0, 0, 255], undefined, 3); 47 48 alert("Click me to continue"); 49 50 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "setup should succeed"); 51 wtu.checkCanvas(gl, [255, 0, 0, 255], undefined, 3); 52 53 alert("Click me to continue"); 54 55 gl.clearColor(1, 0, 0, 1); 56 gl.clear(gl.COLOR_BUFFER_BIT); 57 wtu.checkCanvas(gl, [255, 0, 0, 255], undefined, 3); 58 59 debug(""); 60 var successfullyParsed = true; 61 </script> 62 <script src="../js/js-test-post.js"></script> 63 64 </body> 65 </html>