Bug 1271830 - Remove non-webgl2 exts from webgl2 and update tests to check webgl2 exts. - r=jrmuizel
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 26 May 2016 16:34:49 -0700
changeset 325499 4715ad5e6035eae5e5bd90bfcd7421127e4ccb92
parent 325498 d9659c22b3c57496b2f79e2b99cb530df7375b5a
child 325500 4a2403a44cd376eaf97b66abb4a630063e4b97c1
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-esr52@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1271830
milestone49.0a1
Bug 1271830 - Remove non-webgl2 exts from webgl2 and update tests to check webgl2 exts. - r=jrmuizel
dom/canvas/WebGLContextExtensions.cpp
dom/canvas/test/webgl-mochitest/ensure-exts/ensure-ext.js
dom/canvas/test/webgl-mochitest/ensure-exts/test_ANGLE_instanced_arrays.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_blend_minmax.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_color_buffer_half_float.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_disjoint_timer_query.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_frag_depth.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_sRGB.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_shader_texture_lod.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_OES_standard_derivatives.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_color_buffer_float.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_compressed_texture_es3.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_depth_texture.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_draw_buffers.html
dom/canvas/test/webgl-mochitest/ensure-exts/test_common.html
--- a/dom/canvas/WebGLContextExtensions.cpp
+++ b/dom/canvas/WebGLContextExtensions.cpp
@@ -107,28 +107,24 @@ WebGLContext::IsExtensionSupported(WebGL
 {
     if (mDisableExtensions)
         return false;
 
     // Extensions for both WebGL 1 and 2.
     switch (ext) {
     // In alphabetical order
     // EXT_
-    case WebGLExtensionID::EXT_color_buffer_half_float:
-        return WebGLExtensionColorBufferHalfFloat::IsSupported(this);
     case WebGLExtensionID::EXT_texture_filter_anisotropic:
         return gl->IsExtensionSupported(gl::GLContext::EXT_texture_filter_anisotropic);
 
     // OES_
     case WebGLExtensionID::OES_texture_float_linear:
         return gl->IsSupported(gl::GLFeature::texture_float_linear);
 
     // WEBGL_
-    case WebGLExtensionID::WEBGL_color_buffer_float:
-        return WebGLExtensionColorBufferFloat::IsSupported(this);
     case WebGLExtensionID::WEBGL_compressed_texture_atc:
         return gl->IsExtensionSupported(gl::GLContext::AMD_compressed_ATC_texture);
     case WebGLExtensionID::WEBGL_compressed_texture_etc1:
         return gl->IsExtensionSupported(gl::GLContext::OES_compressed_ETC1_RGB8_texture);
     case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
         return gl->IsExtensionSupported(gl::GLContext::IMG_texture_compression_pvrtc);
     case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
         if (gl->IsExtensionSupported(gl::GLContext::EXT_texture_compression_s3tc))
@@ -166,16 +162,18 @@ WebGLContext::IsExtensionSupported(WebGL
         switch (ext) {
         // ANGLE_
         case WebGLExtensionID::ANGLE_instanced_arrays:
             return WebGLExtensionInstancedArrays::IsSupported(this);
 
         // EXT_
         case WebGLExtensionID::EXT_blend_minmax:
             return WebGLExtensionBlendMinMax::IsSupported(this);
+        case WebGLExtensionID::EXT_color_buffer_half_float:
+            return WebGLExtensionColorBufferHalfFloat::IsSupported(this);
         case WebGLExtensionID::EXT_frag_depth:
             return WebGLExtensionFragDepth::IsSupported(this);
         case WebGLExtensionID::EXT_shader_texture_lod:
             return gl->IsExtensionSupported(gl::GLContext::EXT_shader_texture_lod);
         case WebGLExtensionID::EXT_sRGB:
             return WebGLExtensionSRGB::IsSupported(this);
 
         // OES_
@@ -189,16 +187,18 @@ WebGLContext::IsExtensionSupported(WebGL
             return WebGLExtensionTextureHalfFloat::IsSupported(this);
         case WebGLExtensionID::OES_texture_half_float_linear:
             return gl->IsSupported(gl::GLFeature::texture_half_float_linear);
 
         case WebGLExtensionID::OES_vertex_array_object:
             return true;
 
         // WEBGL_
+        case WebGLExtensionID::WEBGL_color_buffer_float:
+            return WebGLExtensionColorBufferFloat::IsSupported(this);
         case WebGLExtensionID::WEBGL_depth_texture:
             // WEBGL_depth_texture supports DEPTH_STENCIL textures
             if (!gl->IsSupported(gl::GLFeature::packed_depth_stencil))
                 return false;
 
             return gl->IsSupported(gl::GLFeature::depth_texture) ||
                    gl->IsExtensionSupported(gl::GLContext::ANGLE_depth_texture);
         case WebGLExtensionID::WEBGL_draw_buffers:
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/ensure-ext.js
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/ensure-ext.js
@@ -1,26 +1,38 @@
 'use strict';
 
-function EnsureExt(name, shouldBe = true) {
+function EnsureExt(extName, shouldHave=true) {
+    EnsureExtFor('webgl', extName, shouldHave);
+    EnsureExtFor('webgl2', extName, shouldHave);
+}
+
+function EnsureExtFor(contextType, extName, shouldHave=true) {
     var c = document.createElement('canvas');
-    var gl = c.getContext('experimental-webgl');
+    var gl = c.getContext(contextType);
 
-    if (shouldBe) {
-        ok(gl.getExtension(name), 'Should have extension ' + name + '.');
+    if (!gl) {
+        todo(false, 'Failed to create context: ' + contextType);
+        return;
+    }
+
+    var ext = gl.getExtension(extName);
+    var haveText = ' have ' + contextType + ' extension ' + extName + '.';
+    if (shouldHave) {
+        ok(ext, 'Should' + haveText);
     } else {
-        ok(!gl.getExtension(name), 'Should not have extension ' + name + '.');
+        ok(!ext, 'Should not' + haveText);
     }
 }
 
-function EnsureDraftExt(name, shouldBe = true) {
+function Lastly_WithDraftExtsEnabled(func) {
     SimpleTest.waitForExplicitFinish();
 
     var fnEnsure = function() {
-        EnsureExt(name, shouldBe);
+        func();
         SimpleTest.finish();
     };
 
     if ('SpecialPowers' in window) {
         var prefStateList = [
             ['webgl.enable-draft-extensions', true],
         ];
         var prefEnv = {'set': prefStateList};
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_ANGLE_instanced_arrays.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_ANGLE_instanced_arrays.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('ANGLE_instanced_arrays');
+EnsureExtFor('webgl', 'ANGLE_instanced_arrays');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_blend_minmax.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_blend_minmax.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('EXT_blend_minmax');
+EnsureExtFor('webgl', 'EXT_blend_minmax');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_color_buffer_half_float.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_color_buffer_half_float.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('EXT_color_buffer_half_float');
+EnsureExtFor('webgl', 'EXT_color_buffer_half_float');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_disjoint_timer_query.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_disjoint_timer_query.html
@@ -5,13 +5,15 @@
     <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';
-EnsureDraftExt('EXT_disjoint_timer_query');
+Lastly_WithDraftExtsEnabled(function() {
+    EnsureExt('EXT_disjoint_timer_query');
+});
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_frag_depth.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_frag_depth.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('EXT_frag_depth');
+EnsureExtFor('webgl', 'EXT_frag_depth');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_sRGB.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_sRGB.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('EXT_sRGB');
+EnsureExtFor('webgl', 'EXT_sRGB');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_shader_texture_lod.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_EXT_shader_texture_lod.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('EXT_shader_texture_lod');
+EnsureExtFor('webgl', 'EXT_shader_texture_lod');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_OES_standard_derivatives.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_OES_standard_derivatives.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('OES_standard_derivatives');
+EnsureExtFor('webgl', 'OES_standard_derivatives');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_color_buffer_float.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_color_buffer_float.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('WEBGL_color_buffer_float');
+EnsureExtFor('webgl', 'WEBGL_color_buffer_float');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_compressed_texture_es3.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_compressed_texture_es3.html
@@ -5,13 +5,15 @@
     <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';
-EnsureDraftExt('WEBGL_compressed_texture_es3');
+Lastly_WithDraftExtsEnabled(function() {
+    EnsureExt('WEBGL_compressed_texture_es3');
+});
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_depth_texture.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_depth_texture.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('WEBGL_depth_texture');
+EnsureExtFor('webgl', 'WEBGL_depth_texture');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_draw_buffers.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_WEBGL_draw_buffers.html
@@ -5,13 +5,13 @@
     <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';
-EnsureExt('WEBGL_draw_buffers');
+EnsureExtFor('webgl', 'WEBGL_draw_buffers');
 
     </script>
   </body>
 </html>
--- a/dom/canvas/test/webgl-mochitest/ensure-exts/test_common.html
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_common.html
@@ -1,75 +1,110 @@
 <!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 c = document.createElement('canvas');
-var gl = c.getContext('experimental-webgl');
+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_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'     , [FORBID          , FORBID          ]], // Complicated!
+    ['WEBGL_debug_shaders'           , [FORBID          , FORBID          ]],
+    ['WEBGL_depth_texture'           , [MACHINE_SPECIFIC, FORBID          ]],
+    ['WEBGL_draw_buffers'            , [MACHINE_SPECIFIC, FORBID          ]],
+    ['WEBGL_lose_context'            , [ENSURE          , ENSURE          ]],
 
-function ensureExt(name) {
-  ok(gl.getExtension(name), 'Should have extension ' + name + '.');
-}
+    // Community Approved
+    ['EXT_color_buffer_float'        , [FORBID          , ENSURE          ]],
+    ['EXT_color_buffer_half_float'   , [MACHINE_SPECIFIC, FORBID          ]],
+    ['EXT_sRGB'                      , [MACHINE_SPECIFIC, FORBID          ]],
+    ['WEBGL_color_buffer_float'      , [MACHINE_SPECIFIC, FORBID          ]],
+    ['WEBGL_compressed_texture_atc'  , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
+    ['WEBGL_compressed_texture_etc1' , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
+    ['WEBGL_compressed_texture_pvrtc', [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
+];
+
+var draftExts = [
+    ['EXT_disjoint_timer_query'    , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]], // TODO: Actually Community Approved now.
+    ['WEBGL_compressed_texture_es3', [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
+];
 
-function ensureNoExt(name) {
-  ok(!gl.getExtension(name), 'Should not have extension ' + name + '.');
+var nonImplementedExts = [
+    'OES_fbo_render_mipmap',
+    'WEBGL_compressed_texture_astc',
+    'WEBGL_security_sensitive_resources',
+    'WEBGL_shared_resources',
+];
+
+////////////////////
+
+function TestExtFor(contextType, extName, status) {
+    switch (status) {
+    case ENSURE:
+        EnsureExtFor(contextType, extName);
+        break;
+
+    case FORBID:
+        EnsureExtFor(contextType, extName, false);
+        break;
+
+    case MACHINE_SPECIFIC:
+        break;
+    }
 }
 
-do {
-  if (!gl)
-    break;
+function TestExt(extName, statusArr) {
+    TestExtFor('webgl', extName, statusArr[0]);
+    TestExtFor('webgl2', extName, statusArr[1]);
+}
 
-  // These aren't all guaranteed, but they're common to all our test slaves.
-  // If you're adding a slave config that is missing one of these, comment the line out
-  // and split it into its own test.
+////////////////////
+
+defaultExts.forEach(function(x) {
+    var extName = x[0];
+    var statusArr = x[1];
+    TestExt(extName, statusArr);
+});
 
-  // Implemented. (commented out if not test-slave-universal)
-  //ensureExt('ANGLE_instanced_arrays');
-  //ensureExt('EXT_blend_minmax');
-  //ensureExt('EXT_color_buffer_half_float');
-  //ensureExt('EXT_frag_depth');
-  //ensureExt('EXT_shader_texture_lod');
-  //ensureExt('EXT_sRGB');
-  //ensureExt('EXT_texture_filter_anisotropic');
-  ensureExt('OES_element_index_uint');
-  //ensureExt('OES_standard_derivatives');
-  ensureExt('OES_texture_float');
-  ensureExt('OES_texture_float_linear');
-  ensureExt('OES_texture_half_float');
-  ensureExt('OES_texture_half_float_linear');
-  ensureExt('OES_vertex_array_object');
-  //ensureExt('WEBGL_color_buffer_float');
-  //ensureExt('WEBGL_compressed_texture_atc');
-  //ensureExt('WEBGL_compressed_texture_es3');
-  //ensureExt('WEBGL_compressed_texture_etc1');
-  //ensureExt('WEBGL_compressed_texture_pvrtc');
-  //ensureExt('WEBGL_compressed_texture_s3tc');
-  //ensureExt('WEBGL_depth_texture');
-  //ensureExt('WEBGL_draw_buffers');
-  ensureExt('WEBGL_lose_context');
+nonImplementedExts.forEach(function(extName) {
+    EnsureExt(extName, false);
+});
 
-  // Draft extensions, which should not be exposed by default.
-  ensureNoExt('EXT_disjoint_timer_query');
-  ensureNoExt('WEBGL_compressed_texture_es3');
+draftExts.forEach(function(x) {
+    var extName = x[0];
+    EnsureExt(extName, false);
+});
 
-  // Not implemented.
-  ensureNoExt('EXT_color_buffer_float');
-  ensureNoExt('OES_fbo_render_mipmap');
-  ensureNoExt('WEBGL_compressed_texture_astc');
-  ensureNoExt('WEBGL_security_sensitive_resources');
-  ensureNoExt('WEBGL_shared_resources');
-
-  // Privileged
-  //ensureExt('WEBGL_debug_renderer_info');
-  //ensureExt('WEBGL_debug_shaders');
-} while (false);
+Lastly_WithDraftExtsEnabled(function() {
+    draftExts.forEach(function(x) {
+        var extName = x[0];
+        var statusArr = x[1];
+        TestExt(extName, statusArr);
+    });
+});
 
     </script>
   </body>
 </html>