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>
18 description("Tests behavior under a restored context for OffscreenCanvas.");
20 if (!window
.OffscreenCanvas
) {
21 testPassed("No OffscreenCanvas support");
27 testFailed("Cannot initialize test");
32 canvas
.addEventListener("webglcontextlost", function(e
) {
33 if (!testLostContext(e
)) {
34 testFailed("Some test failed");
38 // restore the context after this event has exited.
39 setTimeout(function() {
40 // we didn't call prevent default so we should not be able to restore the context
41 if (!compareGLError(gl
.INVALID_OPERATION
, "WEBGL_lose_context.restoreContext()")) {
42 testFailed("Some test failed");
46 testLosingAndRestoringContext().then(function(s
) {
47 testPassed("Test passed");
51 testFailed("Test failed: " + s
);
57 canvas
.addEventListener("webglcontextrestored", function() {
58 testFailed("Some test failed");
63 contextLostEventFired
= false;
64 contextRestoredEventFired
= false;
66 if (!testOriginalContext()) {
67 testFailed("Some test failed");
71 WEBGL_lose_context
.loseContext();
72 // The context should be lost immediately.
73 shouldBeTrue("gl.isContextLost()");
74 shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
75 shouldBe("gl.getError()", "gl.NO_ERROR");
76 // gl methods should be no-ops
77 shouldBeTrue(compareGLError(gl
.NO_ERROR
, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)"));
78 // but the event should not have been fired.
79 shouldBeFalse("contextLostEventFired");
84 <body onload=
"init()">
85 <div id=
"description"></div>
86 <div id=
"console"></div>