webgl-resize-test.html (1034B)
1 <!DOCTYPE html> 2 <html class='reftest-wait'> 3 <head> 4 <meta charset='UTF-8'> 5 <script type='text/javascript' src='webgl-utils.js'></script> 6 </head> 7 8 <body> 9 <canvas id='e_canvas'></canvas> 10 <br> 11 <div id='e_log'></div> 12 <script> 13 /* Resize Test 14 * 15 * Create canvas of wrong size. 16 * Clear the canvas to red. 17 * Resize to correct size. 18 * Clear to green. 19 */ 20 21 'use strict'; 22 23 async function awaitComposite() { 24 await new Promise((res, rej) => { 25 waitForComposite(res); 26 }); 27 } 28 29 function testComplete() { 30 document.documentElement.removeAttribute('class'); 31 } 32 33 (async function() { 34 const gl = initGL(e_canvas); 35 if (!gl) { 36 e_log.textContent = 'WebGL failed.'; 37 } else { 38 gl.clearColor(1.0, 0.0, 0.0, 1.0); // red 39 gl.clear(gl.COLOR_BUFFER_BIT); 40 await awaitComposite(); 41 42 gl.canvas.width = 256; 43 gl.canvas.height = 256; 44 gl.clearColor(0.0, 1.0, 0.0, 1.0); // green 45 gl.clear(gl.COLOR_BUFFER_BIT); 46 } 47 48 await awaitComposite(); 49 testComplete(); 50 })(); 51 </script> 52 </body> 53 </html>