diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_webgl.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_webgl.html')
-rw-r--r-- | dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_webgl.html | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_webgl.html b/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_webgl.html new file mode 100644 index 000000000..d0ebee6ad --- /dev/null +++ b/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_webgl.html @@ -0,0 +1,114 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="pc.js"></script> + <script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script> + <script type="application/javascript" src="/tests/dom/canvas/test/webgl-mochitest/webgl-util.js"></script> +</head> +<body> +<pre id="test"> +<script id="v-shader" type="x-shader/x-vertex"> + attribute vec2 aPosition; + void main() { + gl_Position = vec4(aPosition, 0, 1); +} +</script> +<script id="f-shader" type="x-shader/x-fragment"> + precision mediump float; + uniform vec4 uColor; + void main() { gl_FragColor = uColor; } +</script> +<script type="application/javascript;version=1.8"> +createHTML({ + bug: "1032848", + title: "Canvas(WebGL)::CaptureStream as video-only input to peerconnection" +}); + +runNetworkTest(() => { + var test = new PeerConnectionTest(); + var vremote; + var h = new CaptureStreamTestHelperWebGL(); + var canvas = document.createElement('canvas'); + canvas.id = 'source_canvas'; + canvas.width = canvas.height = 10; + canvas.style.display = 'none'; + document.getElementById('content').appendChild(canvas); + + var gl = WebGLUtil.getWebGL(canvas.id, false); + if (!gl) { + todo(false, "WebGL unavailable."); + networkTestFinished(); + return; + } + + var errorFunc = str => ok(false, 'Error: ' + str); + WebGLUtil.setErrorFunc(errorFunc); + WebGLUtil.setWarningFunc(errorFunc); + + test.setMediaConstraints([{video: true}], []); + test.chain.replace("PC_LOCAL_GUM", [ + function WEBGL_SETUP(test) { + var program = WebGLUtil.createProgramByIds(gl, 'v-shader', 'f-shader'); + + if (!program) { + ok(false, "Program should link"); + return Promise.reject(); + } + gl.useProgram(program); + + var uColorLocation = gl.getUniformLocation(program, "uColor"); + h.setFragmentColorLocation(uColorLocation); + + var squareBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, squareBuffer); + + var vertices = [ 0, 0, + -1, 0, + 0, 1, + -1, 1 ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + squareBuffer.itemSize = 2; + squareBuffer.numItems = 4; + + program.aPosition = gl.getAttribLocation(program, "aPosition"); + gl.enableVertexAttribArray(program.aPosition); + gl.vertexAttribPointer(program.aPosition, squareBuffer.itemSize, gl.FLOAT, false, 0, 0); + }, + function DRAW_LOCAL_GREEN(test) { + h.drawColor(canvas, h.green); + }, + function PC_LOCAL_CANVAS_CAPTURESTREAM(test) { + test.pcLocal.canvasStream = canvas.captureStream(0.0); + is(test.pcLocal.canvasStream.canvas, canvas, "Canvas attribute is correct"); + test.pcLocal.attachLocalStream(test.pcLocal.canvasStream); + } + ]); + test.chain.append([ + function FIND_REMOTE_VIDEO() { + vremote = test.pcRemote.remoteMediaElements[0]; + ok(!!vremote, "Should have remote video element for pcRemote"); + }, + function WAIT_FOR_REMOTE_GREEN() { + return h.waitForPixelColor(vremote, h.green, 128, + "pcRemote's remote should become green"); + }, + function REQUEST_FRAME(test) { + // After requesting a frame it will be captured at the time of next render. + // Next render will happen at next stable state, at the earliest, + // i.e., this order of `requestFrame(); draw();` should work. + test.pcLocal.canvasStream.requestFrame(); + }, + function DRAW_LOCAL_RED() { + h.drawColor(canvas, h.red); + }, + function WAIT_FOR_REMOTE_RED() { + return h.waitForPixelColor(vremote, h.red, 128, + "pcRemote's remote should become red"); + } + ]); + test.run(); +}); +</script> +</pre> +</body> +</html> |