context-lost-worker.js (1406B)
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 importScripts("../../js/tests/canvas-tests-utils.js"); 8 self.onmessage = function(e) { 9 canvas = new OffscreenCanvas(10, 10); 10 gl = canvas.getContext('webgl'); 11 12 // call testValidContext() before checking for the extension, because this is where we check 13 // for the isContextLost() method, which we want to do regardless of the extension's presence. 14 self.postMessage({fail: !testValidContext(), msg: "testValidContext()"}); 15 16 WEBGL_lose_context = gl.getExtension("WEBGL_lose_context"); 17 self.postMessage({fail: !WEBGL_lose_context, msg: "WEBGL_lose_context"}); 18 19 // need an extension that exposes new API methods. 20 OES_vertex_array_object = gl.getExtension("OES_vertex_array_object"); 21 self.postMessage({fail: !OES_vertex_array_object, msg: "OES_vertex_array_object"}); 22 23 // We need to initialize |uniformLocation| before losing context. 24 // Otherwise gl.getUniform() when context is lost will throw. 25 uniformLocation = gl.getUniformLocation(program, "tex"); 26 WEBGL_lose_context.loseContext(); 27 28 canvas.addEventListener("webglcontextlost", function() { 29 self.postMessage({fail: !testLostContextWithoutRestore(), msg: "testLostContextWithoutRestore()", 30 finishTest:true}); 31 }, false); 32 }