aboutsummaryrefslogtreecommitdiffstats
path: root/tests/html/test_webgl_context_attributes.html
blob: d25ce6a6f2d33cb77cfdb29a8d63f4531c493244 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<meta charset="utf-8">
<title>WebGL Context Attributes test</title>
<script>
(function () {
    var canvas = document.createElement('canvas'),
        closure = function() {},
        gl, attributes;

    closure.alpha = false;
    closure.antialias = "";

    gl = canvas.getContext("webgl", closure);

    if ( ! gl ) {
        console.log("Passing a closure to `getContext` didn't generate a context");
        gl = canvas.getContext("webgl", { alpha: false, antialias: "" });
    }

    if ( ! gl ) {
        console.error("Unable to generate a WebGL context");
        return;
    }

    attributes = gl.getContextAttributes();
    console.log("Got context attributes: ", JSON.stringify(attributes));

    if ( attributes.alpha )
        console.error("Alpha not expected");

    if ( attributes.antialias )
        console.error("Antialias not expected, should be casted to false");

    gl = canvas.getContext("webgl", { alpha: true });
    attributes = gl.getContextAttributes();

    if ( attributes.alpha )
        console.error("Should have returned the previous context attributes");
})();
</script>