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.
10 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
11 <script src=
"../../js/js-test-pre.js"></script>
12 <script src=
"../../js/webgl-test-utils.js"></script>
13 <script src=
"../../js/tests/canvas-tests-utils.js"></script>
17 description("Tests behavior under a lost context for OffscreenCanvas");
19 if (!window
.OffscreenCanvas
) {
20 testPassed("No OffscreenCanvas support");
25 canvas
= new OffscreenCanvas(10, 10);
26 gl
= canvas
.getContext('webgl');
28 // call testValidContext() before checking for the extension, because this is where we check
29 // for the isContextLost() method, which we want to do regardless of the extension's presence.
30 if (!testValidContext()) {
31 testFailed("Some tests failed");
36 WEBGL_lose_context
= gl
.getExtension("WEBGL_lose_context");
37 // need an extension that exposes new API methods.
38 OES_vertex_array_object
= gl
.getExtension("OES_vertex_array_object");
39 if (WEBGL_lose_context
== null || OES_vertex_array_object
== null) {
40 testFailed("extension && OES_vertex_array_object failed");
45 // We need to initialize |uniformLocation| before losing context.
46 // Otherwise gl.getUniform() when context is lost will throw.
47 uniformLocation
= gl
.getUniformLocation(program
, "tex");
48 WEBGL_lose_context
.loseContext();
50 canvas
.addEventListener("webglcontextlost", function() {
51 if (testLostContextWithoutRestore()) {
52 testPassed("All tests passed");
56 testFailed("testLostContextWithoutRestore failed");
65 <body onload=
"init()">
66 <div id=
"description"></div>
67 <div id=
"console"></div>