user-defined-properties-on-context.html (1364B)
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 <!DOCTYPE html> 7 <html> 8 <head> 9 <meta charset="utf-8"> 10 <title>WebGL User-Defined Properties Test</title> 11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> 12 <script src="../../js/js-test-pre.js"></script> 13 <script src="../../js/webgl-test-utils.js"></script> 14 </head> 15 <body onload="initialize()"> 16 <div id="description"></div> 17 <div id="console"></div> 18 <canvas id="canvas" style="width: 50px; height: 50px;"> </canvas> 19 <script> 20 "use strict"; 21 description("This test ensures that if user-defined properties are set on the WebGL context object, that they don't disappear after garbage collection."); 22 23 var gl2 = null; 24 25 function initialize() { 26 var wtu = WebGLTestUtils; 27 var canvas = document.getElementById("canvas"); 28 var gl1 = wtu.create3DContext(canvas); 29 if (!gl1) { 30 testFailed("WebGL context does not exist"); 31 finishTest(); 32 } else { 33 testPassed("WebGL context exists"); 34 gl1.myProperty = 2; 35 wtu.requestAnimFrame(runTest); 36 } 37 } 38 39 function runTest() { 40 webglHarnessCollectGarbage(); 41 var wtu = WebGLTestUtils; 42 var canvas = document.getElementById("canvas"); 43 gl2 = wtu.create3DContext(canvas); 44 shouldBe('gl2.myProperty', '2'); 45 finishTest(); 46 } 47 </script> 48 </body> 49 </html>