canvas-no-clear-on-readpixels.html (1249B)
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>Check that the canvas is NOT recomposited after calling readPixels</title> 12 <link rel="stylesheet" href="../../resources/js-test-style.css"/> 13 <script src="../../js/js-test-pre.js"></script> 14 <script src="../../js/webgl-test-utils.js"></script> 15 <style> 16 canvas { 17 border: 1px solid black; 18 } 19 .correct { 20 border: 1px solid black; 21 background-color: #00ff00; 22 } 23 </style> 24 </head> 25 <body> 26 <pre> 27 This test must be run manually. 28 29 This test tests that a canvas is NOT cleared 30 and recomposited after calling readPixels. 31 32 You should see a <span class="correct">green rectangle</span> 33 with black a outline on success. 34 </pre> 35 <canvas id='c'></canvas> 36 <div id="console"></div> 37 <script> 38 "use strict"; 39 var wtu = WebGLTestUtils; 40 var c = document.getElementById("c"); 41 var gl = wtu.create3DContext(c); 42 gl.clearColor(0,1,0,1); 43 gl.clear(gl.COLOR_BUFFER_BIT); 44 wtu.waitForComposite(function() { 45 gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4)); 46 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors"); 47 }); 48 </script> 49 </body> 50 </html>