1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-mochitest/test_depth_readpixels.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 +<title>WebGL test: Check for error on ReadPixels from a depth-only FB.</title> 1.8 +<script src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> 1.10 +<script src="webgl-util.js"></script> 1.11 +<script src="driver-info.js"></script> 1.12 +</head> 1.13 +<body> 1.14 +<canvas id="c"></canvas> 1.15 +<script> 1.16 +"use strict"; 1.17 + 1.18 +(function() { 1.19 + var gl = WebGLUtil.getWebGL('c'); 1.20 + if (!gl) { 1.21 + todo(gl, 'Get GL working here first.'); 1.22 + return; 1.23 + } 1.24 + 1.25 + var rb = gl.createRenderbuffer(); 1.26 + gl.bindRenderbuffer(gl.RENDERBUFFER, rb); 1.27 + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 4, 4); 1.28 + 1.29 + var fb = gl.createFramebuffer(); 1.30 + gl.bindFramebuffer(gl.FRAMEBUFFER, fb); 1.31 + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, 1.32 + gl.RENDERBUFFER, rb); 1.33 + 1.34 + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { 1.35 + todo(false, 'Depth-only FB incomplete. This is valid.'); 1.36 + return; 1.37 + } 1.38 + 1.39 + ok(!gl.getError(), 'Should have no errors after constructing FB.'); 1.40 + 1.41 + var pixels = new Uint8Array([1, 2, 3, 4]); 1.42 + gl.readPixels(0, 0, // x,y 1.43 + 1, 1, // w,h 1.44 + gl.RGBA, gl.UNSIGNED_BYTE, pixels); 1.45 + 1.46 + ok(gl.getError() == gl.INVALID_OPERATION, 1.47 + '1x1 color read from a depth FB should generated INVALID_OP.'); 1.48 + console.log('Data after 1x1 color-from-depth readpixels:'); 1.49 + console.log(pixels); 1.50 + 1.51 + gl.readPixels(0, 0, // x,y 1.52 + 0, 0, // w,h 1.53 + gl.RGBA, gl.UNSIGNED_BYTE, pixels); 1.54 + 1.55 + ok(gl.getError() == gl.INVALID_OPERATION, 1.56 + '0x0 color read from a depth FB should generated INVALID_OP.'); 1.57 +})(); 1.58 + 1.59 +ok(true, 'Test complete.'); 1.60 + 1.61 +</script> 1.62 +</body> 1.63 +</html>