Bug 1477817 - Add test_has_rbab to guarantee we can skip index validation where available. - r=kvark,qdot a=ryanvm
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 23 Jul 2018 12:58:44 -0700
changeset 480979 5f8431f3c2e1
parent 480978 8d31f736050a
child 480980 6052afb29f1f
push id1757
push userffxbld-merge
push date2018-08-24 17:02 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark, qdot, ryanvm
bugs1477817
milestone62.0
Bug 1477817 - Add test_has_rbab to guarantee we can skip index validation where available. - r=kvark,qdot a=ryanvm MozReview-Commit-ID: JKVtfwwVGn9
dom/canvas/WebGLContext.h
dom/canvas/WebGLExtensionMOZDebug.cpp
dom/canvas/test/webgl-mochitest/mochitest.ini
dom/canvas/test/webgl-mochitest/test_has_rbab.html
dom/webidl/WebGLRenderingContext.webidl
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -308,16 +308,17 @@ class WebGLContext
     friend class WebGLExtensionCompressedTextureETC1;
     friend class WebGLExtensionCompressedTexturePVRTC;
     friend class WebGLExtensionCompressedTextureS3TC;
     friend class WebGLExtensionCompressedTextureS3TC_SRGB;
     friend class WebGLExtensionDepthTexture;
     friend class WebGLExtensionDisjointTimerQuery;
     friend class WebGLExtensionDrawBuffers;
     friend class WebGLExtensionLoseContext;
+    friend class WebGLExtensionMOZDebug;
     friend class WebGLExtensionVertexArray;
     friend class WebGLMemoryTracker;
     friend class webgl::AvailabilityRunnable;
     friend struct webgl::LinkedProgramInfo;
     friend struct webgl::UniformBlockInfo;
 
     enum {
         UNPACK_FLIP_Y_WEBGL = 0x9240,
--- a/dom/canvas/WebGLExtensionMOZDebug.cpp
+++ b/dom/canvas/WebGLExtensionMOZDebug.cpp
@@ -54,24 +54,28 @@ WebGLExtensionMOZDebug::GetParameter(JSC
     case LOCAL_GL_VENDOR:
     case LOCAL_GL_VERSION:
         {
             const auto raw = (const char*)gl->fGetString(pname);
             retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(raw), er));
             return;
         }
 
-    case 0x10000: // "WSI_INFO"
+    case dom::MOZ_debugBinding::WSI_INFO:
         {
             nsCString info;
             gl->GetWSIInfo(&info);
             retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(info), er));
             return;
         }
 
+    case dom::MOZ_debugBinding::DOES_INDEX_VALIDATION:
+        retval.set(JS::BooleanValue(mContext->mNeedsIndexValidation));
+        return;
+
     default:
         mContext->ErrorInvalidEnumArg("MOZ_debug.getParameter", "pname", pname);
         retval.set(JS::NullValue());
         return;
     }
 }
 
 IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionMOZDebug, MOZ_debug)
--- a/dom/canvas/test/webgl-mochitest/mochitest.ini
+++ b/dom/canvas/test/webgl-mochitest/mochitest.ini
@@ -61,16 +61,18 @@ skip-if = os == 'win' && debug # Bug 138
 support-files = ../captureStream_common.js
 # Even though we use ../ here, in the test HTML, we need to omit this. Sub-CWD relative
 # paths are fine, but they locate the file and dump it in the current directory.
 [test_cubemap_must_be_square.html]
 [test_depth_tex_lazy_clear.html]
 [test_draw.html]
 [test_fb_param.html]
 [test_fb_param_crash.html]
+[test_has_rbab.html]
+fail-if = (os == 'linux') || (os == 'mac')
 [test_hidden_alpha.html]
 [test_hidden_depth_stencil.html]
 [test_implicit_color_buffer_float.html]
 [test_highp_fs.html]
 [test_no_arr_points.html]
 skip-if = android_version == '18' #Android 4.3 aws only; bug 1030942
 [test_noprog_draw.html]
 [test_pixel_pack_buffer.html]
new file mode 100644
--- /dev/null
+++ b/dom/canvas/test/webgl-mochitest/test_has_rbab.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset='UTF-8'>
+  <title>Fail without robust_buffer_access_behavior</title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
+</head>
+<body>
+<script>
+
+function AssertRBAB() {
+  const c = document.createElement('canvas');
+  const g = c.getContext('webgl');
+  const e = g.getExtension('MOZ_debug');
+  ok(e, 'Should have MOZ_debug.');
+
+  const does_index_validation = e.getParameter(e.DOES_INDEX_VALIDATION);
+  ok(!does_index_validation,
+     "Should have RBAB. Mark this test as failing on platforms that can't support it.");
+
+  SimpleTest.finish();
+}
+
+// -
+
+SimpleTest.waitForExplicitFinish();
+
+const prefPairList = [
+  ['webgl.force-enabled', true],
+  ['webgl.enable-privileged-extensions', true],
+];
+const prefEnv = {'set': prefPairList};
+SpecialPowers.pushPrefEnv(prefEnv, AssertRBAB);
+
+</script>
+</body>
+</html>
--- a/dom/webidl/WebGLRenderingContext.webidl
+++ b/dom/webidl/WebGLRenderingContext.webidl
@@ -1091,14 +1091,16 @@ interface EXT_disjoint_timer_query {
     void queryCounterEXT(WebGLQuery query, GLenum target);
     any getQueryEXT(GLenum target, GLenum pname);
     any getQueryObjectEXT(WebGLQuery query, GLenum pname);
 };
 
 [NoInterfaceObject]
 interface MOZ_debug {
     const GLenum EXTENSIONS = 0x1F03;
+
     const GLenum WSI_INFO   = 0x10000;
     const GLenum UNPACK_REQUIRE_FASTPATH = 0x10001;
+    const GLenum DOES_INDEX_VALIDATION   = 0x10002;
 
     [Throws]
     any getParameter(GLenum pname);
 };