context-release-with-workers.html (1829B)
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 Context Release Test</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 </head> 16 <body> 17 <iframe id="host" style="width: 256px; height: 256px; border: 0;"></iframe> 18 <div id="description"></div> 19 <div id="console"></div> 20 <script> 21 "use strict"; 22 description("This test ensures that WebGL contexts are released properly when a worker is used"); 23 24 var wtu = WebGLTestUtils; 25 26 var host = document.getElementById("host"); 27 var testIterations = 25; 28 var currentIteration = 0; 29 30 function refreshFrame() { 31 if(currentIteration < testIterations) { 32 currentIteration++; 33 debug(""); 34 debug("Test " + currentIteration + " of " + testIterations); 35 host.src = "resources/context-release-child-with-worker.html"; 36 } else { 37 finishTest(); 38 } 39 } 40 41 function testContext() { 42 var gl = host.contentWindow.glContext; 43 assertMsg(gl != null, "context was created properly"); 44 45 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors"); 46 47 if(gl.canvas.width != gl.drawingBufferWidth || 48 gl.canvas.height != gl.drawingBufferHeight) { 49 testFailed("Buffer was the wrong size: " + 50 gl.drawingBufferWidth + "x" + gl.drawingBufferHeight); 51 } else { 52 testPassed("Buffer was the correct size: " + 53 gl.drawingBufferWidth + "x" + gl.drawingBufferHeight); 54 refreshFrame(); 55 } 56 57 gl = null; 58 } 59 60 window.addEventListener("message", function(event) { 61 if(event.data == "Ready") { 62 testContext(); 63 } 64 }); 65 66 refreshFrame(); 67 68 var successfullyParsed = true; 69 </script> 70 71 </body> 72 </html>