summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-mochitest/ensure-exts/test_common.html
blob: 8620a66f833e54d729111da67c23f83e5ffd3dbe (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE HTML>
<html>
  <head>
    <meta charset='utf-8'/>
    <script src='/tests/SimpleTest/SimpleTest.js'></script>
    <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
    <script src='ensure-ext.js'></script>
  </head>
  <body>
    <script>

'use strict';

var ENSURE = 'ENSURE'; // Works on all test machines.
var FORBID = 'FORBID'; // Should not work on any test machine.
var MACHINE_SPECIFIC = 'MACHINE_SPECIFIC';

var defaultExts = [
    // Ratified
    ['ANGLE_instanced_arrays'        , [MACHINE_SPECIFIC, FORBID          ]],
    ['EXT_blend_minmax'              , [MACHINE_SPECIFIC, FORBID          ]],
    ['EXT_frag_depth'                , [MACHINE_SPECIFIC, FORBID          ]],
    ['EXT_shader_texture_lod'        , [MACHINE_SPECIFIC, FORBID          ]],
    ['EXT_texture_filter_anisotropic', [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['OES_element_index_uint'        , [ENSURE          , FORBID          ]],
    ['OES_fbo_render_mipmap'         , [MACHINE_SPECIFIC, FORBID          ]],
    ['OES_standard_derivatives'      , [MACHINE_SPECIFIC, FORBID          ]],
    ['OES_texture_float'             , [ENSURE          , FORBID          ]],
    ['OES_texture_float_linear'      , [ENSURE          , ENSURE          ]],
    ['OES_texture_half_float'        , [ENSURE          , FORBID          ]],
    ['OES_texture_half_float_linear' , [ENSURE          , FORBID          ]],
    ['OES_vertex_array_object'       , [ENSURE          , FORBID          ]],
    ['WEBGL_compressed_texture_s3tc' , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_debug_renderer_info'     , [ENSURE          , ENSURE          ]],
    ['WEBGL_debug_shaders'           , [ENSURE          , ENSURE          ]],
    ['WEBGL_depth_texture'           , [MACHINE_SPECIFIC, FORBID          ]],
    ['WEBGL_draw_buffers'            , [MACHINE_SPECIFIC, FORBID          ]],
    ['WEBGL_lose_context'            , [ENSURE          , ENSURE          ]],

    // Community Approved
    ['EXT_color_buffer_float'            , [FORBID          , ENSURE          ]],
    ['EXT_color_buffer_half_float'       , [MACHINE_SPECIFIC, FORBID          ]],
    ['EXT_disjoint_timer_query'          , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['EXT_float_blend'                   , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['EXT_sRGB'                          , [MACHINE_SPECIFIC, FORBID          ]],
    ['EXT_texture_compression_bptc'      , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['EXT_texture_compression_rgtc'      , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['OES_draw_buffers_indexed'          , [FORBID          , MACHINE_SPECIFIC]],
    ['OVR_multiview2'                    , [FORBID          , MACHINE_SPECIFIC]],
    ['WEBGL_color_buffer_float'          , [MACHINE_SPECIFIC, FORBID          ]],
    ['WEBGL_compressed_texture_astc'     , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_compressed_texture_atc'      , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_compressed_texture_etc'      , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_compressed_texture_etc1'     , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_compressed_texture_pvrtc'    , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_compressed_texture_s3tc_srgb', [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
    ['WEBGL_provoking_vertex'            , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
];

var draftExts = [
    ['EXT_texture_norm16'      , [FORBID          , MACHINE_SPECIFIC]],
    ['WEBGL_explicit_present'  , [ENSURE          , ENSURE          ]],
];

////////////////////
// Ensure that we never see any extensions that we haven't listed above!

(function() {
    const expectedExts = (defaultExts.concat(draftExts)).map(x => x[0]);

    ['webgl', 'webgl2'].forEach( contextType => {
        const c = document.createElement('canvas');
        const gl = c.getContext(contextType);
        if (!gl) return;

        const actualExts = gl.getSupportedExtensions();
        actualExts.forEach(actualExt => {
            ok(expectedExts.includes(actualExt), 'Unexpected ext: ' + actualExt);
        });
    });
})();

////////////////////

function TestExtFor(contextType, extName, status) {
    switch (status) {
    case ENSURE:
        EnsureExtFor(contextType, extName);
        break;

    case FORBID:
        EnsureExtFor(contextType, extName, false);
        break;

    case MACHINE_SPECIFIC:
        break;
    }
}

function TestExt(extName, statusArr) {
    TestExtFor('webgl', extName, statusArr[0]);
    TestExtFor('webgl2', extName, statusArr[1]);
}

////////////////////

defaultExts.forEach(function(x) {
    var extName = x[0];
    var statusArr = x[1];
    TestExt(extName, statusArr);
});

draftExts.forEach(function(x) {
    var extName = x[0];
    EnsureExt(extName, false);
});

Lastly_WithDraftExtsEnabled(function() {
    draftExts.forEach(function(x) {
        var extName = x[0];
        var statusArr = x[1];
        TestExt(extName, statusArr);
    });
});

    </script>
  </body>
</html>