tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

context-lost-restored-worker.js (1899B)


      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    if (!setupTest())
     10        self.postMessage("Test failed");
     11 
     12    canvas.addEventListener("webglcontextlost", function(e) {
     13        if (!testLostContext(e))
     14            self.postMessage("Test failed");
     15        // restore the context after this event has exited.
     16        setTimeout(function() {
     17            // we didn't call prevent default so we should not be able to restore the context
     18            if (!compareGLError(gl.INVALID_OPERATION, "WEBGL_lose_context.restoreContext()"))
     19                self.postMessage("Test failed");
     20            testLosingAndRestoringContext().then(function() {
     21                self.postMessage("Test passed");
     22            }, function() {
     23                self.postMessage("Test failed");
     24            });
     25        }, 0);
     26    });
     27    canvas.addEventListener("webglcontextrestored", function() {
     28        self.postMessage("Test failed");
     29    });
     30    allowRestore = false;
     31    contextLostEventFired = false;
     32    contextRestoredEventFired = false;
     33 
     34    if (!testOriginalContext())
     35        self.postMessage("Test failed");
     36    WEBGL_lose_context.loseContext();
     37    // The context should be lost immediately.
     38    if (!gl.isContextLost())
     39        self.postMessage("Test failed");
     40    if (gl.getError() != gl.CONTEXT_LOST_WEBGL)
     41        self.postMessage("Test failed");
     42    if (gl.getError() != gl.NO_ERROR)
     43        self.postMessage("Test failed");
     44    // gl methods should be no-ops
     45    if (!compareGLError(gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)"))
     46        self.postMessage("Test failed");
     47    // but the event should not have been fired.
     48    if (contextLostEventFired)
     49        self.postMessage("Test failed");
     50 }