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 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
15 <div id=
"description"></div>
16 <div id=
"console"></div>
20 function getWebGL(attribs
) {
21 var canvas
= document
.createElement("canvas");
25 // We can't use wtu.create3DContext because it defaults to antialias=false.
26 var names
= ["webgl2"];
28 for (var i
= 0; i
< names
.length
; ++i
) {
30 gl
= canvas
.getContext(names
[i
], attribs
);
42 function testAttribs(attribs
) {
43 var antialias
, depth
, stencil
;
48 debug("Testing default attributes: { antialias: true, depth: true, stencil:false }");
50 antialias
= attribs
.antialias
;
51 depth
= attribs
.depth
;
52 stencil
= attribs
.stencil
;
53 debug("Testing specified attributes: { antialias: " + antialias
+ ", depth: " + depth
+ ", stencil: " + stencil
+ " }");
55 var gl
= getWebGL(attribs
);
57 testFailed("Fail to create a context");
60 var actual_attribs
= gl
.getContextAttributes();
61 if (antialias
!= actual_attribs
.antialias
)
62 testFailed("antialias = " + antialias
+ " is not obeyed")
63 if (depth
!= actual_attribs
.depth
)
64 testFailed("depth = " + depth
+ " is not obeyed")
65 if (stencil
!= actual_attribs
.stencil
)
66 testFailed("stencil = " + stencil
+ " is not obeyed")
67 if (antialias
== actual_attribs
.antialias
&&
68 depth
== actual_attribs
.depth
&&
69 stencil
== actual_attribs
.stencil
) {
70 testPassed("Context created with the correct antialias, depth, and stencil.");
74 description('Verify WebGLContextAttributes are working as specified, including depth, stencil, antialias');
75 testAttribs(null); // Default attribs
76 testAttribs({antialias
: true, depth
: true, stencil
: true});
77 testAttribs({antialias
: false, depth
: true, stencil
: true});
78 testAttribs({antialias
: true, depth
: false, stencil
: true});
79 testAttribs({antialias
: false, depth
: false, stencil
: true});
80 testAttribs({antialias
: true, depth
: true, stencil
: false});
81 testAttribs({antialias
: false, depth
: true, stencil
: false});
82 testAttribs({antialias
: true, depth
: false, stencil
: false});
83 testAttribs({antialias
: false, depth
: false, stencil
: false});
85 var successfullyParsed
= true;
87 <script src=
"../../js/js-test-post.js"></script>