gecko/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_2d.html
Andreas Pehrson 57b146b3a4 Bug 1161913 - Part 3 - Relax requestFrame ordering guarantee in tests. r=mt
We used to fully guarantee the order of requestFrame() and draw calls.
For instance:
```
ctx.draw(red);
stream.requestFrame();
ctx.draw(green);
```
would guarantee that a red frame ended up in the stream, and not the
green unless another frame was requested.

Now with frames being requested and pushed out on next refresh, we can
only guarantee that everything up to the requestFrame() call is included
in the next frame. Everything after the requestFrame() and before the
next refresh (stable state in most cases) will now also be inevitably
included.
2015-09-17 11:37:05 +08:00

61 lines
1.9 KiB
HTML

<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript;version=1.8">
createHTML({
bug: "1032848",
title: "Canvas(2D)::CaptureStream as video-only input to peerconnection",
visible: true
});
runNetworkTest(() => {
var test = new PeerConnectionTest();
var vremote;
var h = new CaptureStreamTestHelper2D();
var canvas = document.createElement('canvas');
var stream;
canvas.id = 'source_canvas';
canvas.width = canvas.height = 10;
document.getElementById('content').appendChild(canvas);
test.setMediaConstraints([{video: true}], []);
test.chain.replace("PC_LOCAL_GUM", [
function DRAW_INITIAL_LOCAL_GREEN(test) {
h.drawColor(canvas, h.green);
},
function PC_LOCAL_CANVAS_CAPTURESTREAM(test) {
stream = canvas.captureStream(0);
test.pcLocal.attachMedia(stream, 'video', 'local');
}
]);
test.chain.append([
function FIND_REMOTE_VIDEO() {
vremote = document.getElementById('pcRemote_remote1_video');
ok(!!vremote, "Should have remote video element for pcRemote");
},
function WAIT_FOR_REMOTE_GREEN() {
return h.waitForPixel(vremote, h.green, 128, "pcRemote's remote should become green");
},
function DRAW_LOCAL_RED() {
// 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.
stream.requestFrame();
h.drawColor(canvas, h.red);
},
function WAIT_FOR_REMOTE_RED() {
return h.waitForPixel(vremote, h.red, 128, "pcRemote's remote should become red");
}
]);
test.run();
});
</script>
</pre>
</body>
</html>