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 <meta charset=
"utf-8">
11 <title>WebGL2 Canvas Context Mode Conformance Tests
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"></script>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
21 description("This test ensures WebGL 2.0 implementations respect the canvas's context mode.");
25 assertMsg(window
.WebGLRenderingContext
,
26 "WebGL2RenderingContext should be a member of window");
27 assertMsg('WebGL2RenderingContext' in window
,
28 "WebGL2RenderingContext should be 'in' window");
30 function testContextMode(mode
, altMode
) {
31 debug("Testing " + mode
+ " context type");
33 let c
= document
.createElement('canvas');
36 let gl
= c
.getContext(mode
);
37 assertMsg(c
.getContext(mode
) == gl
,
38 "Canvas.getContext('" + mode
+ "') should return the same value every time");
40 assertMsg(c
.getContext(altMode
) == null,
41 "Canvas.getContext('" + altMode
+ "') after getContext('" + mode
+ "') should return null");
43 testFailed("Canvas.getContext('" + altMode
+ "') after getContext('" + mode
+ "') should not throw an exception");
47 testContextMode('webgl2', 'webgl');
48 testContextMode('webgl', 'webgl2');
51 var successfullyParsed
= true;
53 <script src=
"../../js/js-test-post.js"></script>