summaryrefslogtreecommitdiffstats
path: root/dom/media/tests/mochitest/test_peerConnection_trackDisabling_clones.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/tests/mochitest/test_peerConnection_trackDisabling_clones.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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_trackDisabling_clones.html')
-rw-r--r--dom/media/tests/mochitest/test_peerConnection_trackDisabling_clones.html149
1 files changed, 149 insertions, 0 deletions
diff --git a/dom/media/tests/mochitest/test_peerConnection_trackDisabling_clones.html b/dom/media/tests/mochitest/test_peerConnection_trackDisabling_clones.html
new file mode 100644
index 000000000..98548b215
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_trackDisabling_clones.html
@@ -0,0 +1,149 @@
+<!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: "1219711",
+ title: "Disabling locally should be reflected remotely, individually for clones"
+});
+
+runNetworkTest(() => {
+ var test = new PeerConnectionTest();
+
+ var originalStream;
+ var localVideoOriginal;
+
+ // Always use fake tracks since we depend on audio to have a large 1000Hz
+ // component.
+ test.setMediaConstraints([{audio: true, video: true, fake: true}], []);
+ test.chain.replace("PC_LOCAL_GUM", [
+ function PC_LOCAL_GUM_CLONE() {
+ return getUserMedia(test.pcLocal.constraints[0]).then(stream => {
+ originalStream = stream;
+ localVideoOriginal =
+ createMediaElement("video", "local-original");
+ localVideoOriginal.srcObject = stream;
+ test.pcLocal.attachLocalStream(originalStream.clone());
+ });
+ }
+ ]);
+ test.chain.append([
+ function CHECK_ASSUMPTIONS() {
+ is(test.pcLocal.localMediaElements.length, 2,
+ "pcLocal should have one media element");
+ is(test.pcRemote.remoteMediaElements.length, 2,
+ "pcRemote should have one media element");
+ is(test.pcLocal._pc.getLocalStreams().length, 1,
+ "pcLocal should have one stream");
+ is(test.pcRemote._pc.getRemoteStreams().length, 1,
+ "pcRemote should have one stream");
+ },
+ function CHECK_VIDEO() {
+ info("Checking video");
+ var h = new CaptureStreamTestHelper2D();
+ var localVideoClone = test.pcLocal.localMediaElements
+ .find(e => e instanceof HTMLVideoElement);
+ var remoteVideoClone = test.pcRemote.remoteMediaElements
+ .find(e => e instanceof HTMLVideoElement);
+
+ // We check a pixel somewhere away from the top left corner since
+ // MediaEngineDefault puts semi-transparent time indicators there.
+ const offsetX = 50;
+ const offsetY = 50;
+ const threshold = 128;
+ const remoteDisabledColor = h.black;
+
+ // We're regarding black as disabled here, and we're setting the alpha
+ // channel of the pixel to 255 to disregard alpha when testing.
+ var checkVideoEnabled = video =>
+ h.waitForPixel(video, offsetX, offsetY,
+ px => (px[3] = 255, h.isPixelNot(px, h.black, threshold)));
+ var checkVideoDisabled = video =>
+ h.waitForPixel(video, offsetX, offsetY,
+ px => (px[3] = 255, h.isPixel(px, h.black, threshold)));
+
+ return Promise.resolve()
+ .then(() => info("Checking local original enabled"))
+ .then(() => checkVideoEnabled(localVideoOriginal))
+ .then(() => info("Checking local clone enabled"))
+ .then(() => checkVideoEnabled(localVideoClone))
+ .then(() => info("Checking remote clone enabled"))
+ .then(() => checkVideoEnabled(remoteVideoClone))
+
+ .then(() => info("Disabling original"))
+ .then(() => originalStream.getVideoTracks()[0].enabled = false)
+
+ .then(() => info("Checking local original disabled"))
+ .then(() => checkVideoDisabled(localVideoOriginal))
+ .then(() => info("Checking local clone enabled"))
+ .then(() => checkVideoEnabled(localVideoClone))
+ .then(() => info("Checking remote clone enabled"))
+ .then(() => checkVideoEnabled(remoteVideoClone))
+
+ .then(() => info("Re-enabling original; disabling clone"))
+ .then(() => originalStream.getVideoTracks()[0].enabled = true)
+ .then(() => test.pcLocal._pc.getLocalStreams()[0].getVideoTracks()[0].enabled = false)
+
+ .then(() => info("Checking local original enabled"))
+ .then(() => checkVideoEnabled(localVideoOriginal))
+ .then(() => info("Checking local clone disabled"))
+ .then(() => checkVideoDisabled(localVideoClone))
+ .then(() => info("Checking remote clone disabled"))
+ .then(() => checkVideoDisabled(remoteVideoClone))
+ },
+ function CHECK_AUDIO() {
+ info("Checking audio");
+ var ac = new AudioContext();
+ var localAnalyserOriginal = new AudioStreamAnalyser(ac, originalStream);
+ var localAnalyserClone =
+ new AudioStreamAnalyser(ac, test.pcLocal._pc.getLocalStreams()[0]);
+ var remoteAnalyserClone =
+ new AudioStreamAnalyser(ac, test.pcRemote._pc.getRemoteStreams()[0]);
+
+ var freq1k = localAnalyserOriginal.binIndexForFrequency(1000);
+ var checkAudioEnabled = analyser =>
+ analyser.waitForAnalysisSuccess(array => array[freq1k] > 200);
+ var checkAudioDisabled = analyser =>
+ analyser.waitForAnalysisSuccess(array => array[freq1k] < 50);
+
+ return Promise.resolve()
+ .then(() => info("Checking local original enabled"))
+ .then(() => checkAudioEnabled(localAnalyserOriginal))
+ .then(() => info("Checking local clone enabled"))
+ .then(() => checkAudioEnabled(localAnalyserClone))
+ .then(() => info("Checking remote clone enabled"))
+ .then(() => checkAudioEnabled(remoteAnalyserClone))
+
+ .then(() => info("Disabling original"))
+ .then(() => originalStream.getAudioTracks()[0].enabled = false)
+
+ .then(() => info("Checking local original disabled"))
+ .then(() => checkAudioDisabled(localAnalyserOriginal))
+ .then(() => info("Checking local clone enabled"))
+ .then(() => checkAudioEnabled(localAnalyserClone))
+ .then(() => info("Checking remote clone enabled"))
+ .then(() => checkAudioEnabled(remoteAnalyserClone))
+
+ .then(() => info("Re-enabling original; disabling clone"))
+ .then(() => originalStream.getAudioTracks()[0].enabled = true)
+ .then(() => test.pcLocal._pc.getLocalStreams()[0].getAudioTracks()[0].enabled = false)
+
+ .then(() => info("Checking local original enabled"))
+ .then(() => checkAudioEnabled(localAnalyserOriginal))
+ .then(() => info("Checking local clone disabled"))
+ .then(() => checkAudioDisabled(localAnalyserClone))
+ .then(() => info("Checking remote clone disabled"))
+ .then(() => checkAudioDisabled(remoteAnalyserClone))
+ }
+ ]);
+ test.run();
+});
+</script>
+</pre>
+</body>
+</html>