1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<!DOCTYPE HTML>
<html>
<head>
<script src="pc.js"></script>
<script src="/tests/dom/canvas/test/captureStream_common.js"></script>
</head>
<body>
<pre id="test">
<script>
createHTML({
bug: "1576771",
title: "Replace a disabled video track with an enabled one",
visible: true,
});
runNetworkTest(() => {
const helper = new CaptureStreamTestHelper2D(240, 160);
const emitter = new VideoFrameEmitter(helper.green, helper.green, 240, 160);
const test = new PeerConnectionTest();
test.setMediaConstraints([{video: true}], []);
test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW", [
function PC_LOCAL_DISABLE_SENDTRACK(test) {
test.pcLocal._pc.getSenders()[0].track.enabled = false;
},
function PC_REMOTE_WAIT_FOR_BLACK(test) {
return helper.pixelMustBecome(
test.pcRemote.remoteMediaElements[0], helper.black, {
threshold: 128,
infoString: "Remote disabled track becomes black",
cancel: wait(10000).then(
() => new Error("Timeout waiting for black"))});
},
function PC_LOCAL_REPLACETRACK_WITH_ENABLED_TRACK(test) {
emitter.start();
test.pcLocal._pc.getSenders()[0].replaceTrack(
emitter.stream().getTracks()[0]);
},
]);
test.chain.append([
function PC_REMOTE_WAIT_FOR_GREEN(test) {
return helper.pixelMustBecome(
test.pcRemote.remoteMediaElements[0], helper.green, {
threshold: 128,
infoString: "Remote disabled track becomes green",
cancel: wait(10000).then(
() => new Error("Timeout waiting for green"))});
},
function CLEANUP(test) {
emitter.stop();
for (const track of emitter.stream().getTracks()) {
track.stop();
}
},
]);
return test.run();
});
</script>
</pre>
</body>
</html>
|