Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / context / context-mode.html
blobd896604c5095ee7d5da5a5418cc1df29b43dc501
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 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
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>
15 </head>
16 <body>
17 <div id="description"></div>
18 <div id="console"></div>
19 <script>
20 "use strict";
21 description("This test ensures WebGL 2.0 implementations respect the canvas's context mode.");
23 debug("");
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');
34 c.width = 2;
35 c.height = 2;
36 let gl = c.getContext(mode);
37 assertMsg(c.getContext(mode) == gl,
38 "Canvas.getContext('" + mode + "') should return the same value every time");
39 try {
40 assertMsg(c.getContext(altMode) == null,
41 "Canvas.getContext('" + altMode + "') after getContext('" + mode + "') should return null");
42 } catch (e) {
43 testFailed("Canvas.getContext('" + altMode + "') after getContext('" + mode + "') should not throw an exception");
47 testContextMode('webgl2', 'webgl');
48 testContextMode('webgl', 'webgl2');
50 debug("");
51 var successfullyParsed = true;
52 </script>
53 <script src="../../js/js-test-post.js"></script>
55 </body>
56 </html>