Bug 1159034 - Test uninitialized buffer data. - r=dvander
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 05 May 2015 13:42:29 -0700
changeset 273841 1952e37ea41541c962b7ed49acba6add708ab37b
parent 273840 83193481f697235ae8a6cb9668f42ab3412f5994
child 273842 2a4e56526e674d5ea81faf0c94e917fed954174d
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1159034
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1159034 - Test uninitialized buffer data. - r=dvander
dom/canvas/test/webgl-mochitest.ini
dom/canvas/test/webgl-mochitest/test_uninit_data.html
--- a/dom/canvas/test/webgl-mochitest.ini
+++ b/dom/canvas/test/webgl-mochitest.ini
@@ -16,16 +16,17 @@ fail-if = (os == 'b2g')
 skip-if = (os == 'b2g') || buildapp == 'mulet' # Mulet - bug 1093639 (crashes in libLLVM-3.0.so)
 [webgl-mochitest/test_implicit_color_buffer_float.html]
 [webgl-mochitest/test_highp_fs.html]
 [webgl-mochitest/test_no_arr_points.html]
 skip-if = android_version == '10' || android_version == '18' #Android 2.3 and 4.3 aws only; bug 1030942
 [webgl-mochitest/test_noprog_draw.html]
 [webgl-mochitest/test_privileged_exts.html]
 [webgl-mochitest/test_texsubimage_float.html]
+[webgl-mochitest/test_uninit_data.html]
 [webgl-mochitest/test_webgl_available.html]
 skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
 #[webgl-mochitest/test_webgl_color_buffer_float.html]
 # We haven't cleaned up the Try results yet, but let's get this on the books first.
 [webgl-mochitest/test_webgl_conformance.html]
 skip-if = buildapp == 'mulet' || toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
 [webgl-mochitest/test_webgl_request_context.html]
 skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
new file mode 100644
--- /dev/null
+++ b/dom/canvas/test/webgl-mochitest/test_uninit_data.html
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta http-equiv='content-type' content='text/html; charset=utf-8'/>
+
+  <title>Test contents of uninitialized buffers</title>
+
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
+  <script src='webgl-util.js'></script>
+</head>
+
+<body>
+<script>
+'use strict';
+
+function TestFB(gl) {
+  var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
+  ok(status == gl.FRAMEBUFFER_COMPLETE, 'FB should be complete.');
+
+  var pixel = new Uint8Array(4);
+  gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
+
+  ok(!pixel[0], 'R channel should be 0, was ' + pixel[0] + '.');
+  ok(!pixel[1], 'G channel should be 0, was ' + pixel[1] + '.');
+  ok(!pixel[2], 'B channel should be 0, was ' + pixel[2] + '.');
+  ok(!pixel[3], 'A channel should be 0, was ' + pixel[3] + '.');
+}
+
+function Test(contextAttribs) {
+  ok(true, '===============================');
+  ok(true, 'Testing ' + JSON.stringify(contextAttribs));
+
+  var c = document.createElement('canvas');
+  var gl = c.getContext('webgl', contextAttribs);
+  if (!gl) {
+    todo(false, 'WebGL is unavailable.');
+    return;
+  }
+
+  var rb = gl.createRenderbuffer();
+  gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
+
+  var tex = gl.createTexture();
+  gl.bindTexture(gl.TEXTURE_2D, tex);
+
+  var err = gl.getError();
+  ok(!err, 'Error should be 0x0, was 0x' + err.toString(16));
+  if (err)
+    return;
+
+  var fb = gl.createFramebuffer();
+  gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
+
+  ok(true, 'Backed with RB');
+  gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rb);
+  gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 1, 1);
+  TestFB(gl);
+
+  ok(true, 'Backed with texture');
+  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
+  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+  TestFB(gl);
+
+  err = gl.getError();
+  ok(!err, 'Error should be 0x0, was 0x' + err.toString(16));
+}
+
+// Give ourselves a scope to return early from:
+(function() {
+  // We test multiple configurations because we've had bugs regarding faking RGBX on
+  // ANGLE: With alpha:false, uninitialized buffers were being filled with (0,0,0,1)
+  // instead of (0,0,0,0).
+  Test({alpha: false, antialias: false});
+  Test({alpha: true, antialias: false});
+  Test({alpha: false, antialias: true});
+  Test({alpha: true, antialias: true});
+
+  ok(true, 'Test complete.');
+})();
+
+</script>
+</body>
+</html>