mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
673d56f32b
MozReview-Commit-ID: 7EWJ5GaO6fK --HG-- extra : rebase_source : e91581c660ddc59818f2c1b2bec09ffd9ed8a078
97 lines
3.8 KiB
HTML
97 lines
3.8 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: "1219711",
|
|
title: "Disabling locally should be reflected remotely"
|
|
});
|
|
|
|
runNetworkTest(() => {
|
|
var test = new PeerConnectionTest();
|
|
|
|
// Always use fake tracks since we depend on video to be somewhat green and
|
|
// audio to have a large 1000Hz component (or 440Hz if using fake devices).
|
|
test.setMediaConstraints([{audio: true, video: true, fake: true}], []);
|
|
test.chain.append([
|
|
function CHECK_ASSUMPTIONS() {
|
|
is(test.pcLocal.mediaElements.length, 1,
|
|
"pcLocal should only have one media element");
|
|
is(test.pcRemote.mediaElements.length, 1,
|
|
"pcRemote should only have one media element");
|
|
is(test.pcLocal.streams.length, 1,
|
|
"pcLocal should only have one stream (the local one)");
|
|
is(test.pcRemote.streams.length, 1,
|
|
"pcRemote should only have one stream (the remote one)");
|
|
},
|
|
function CHECK_VIDEO() {
|
|
var h = new CaptureStreamTestHelper2D();
|
|
var localVideo = test.pcLocal.mediaElements[0];
|
|
var remoteVideo = test.pcRemote.mediaElements[0];
|
|
// 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;
|
|
|
|
// 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, offsetX*2, offsetY*2)));
|
|
return Promise.resolve()
|
|
.then(() => info("Checking local video enabled"))
|
|
.then(() => checkVideoEnabled(localVideo))
|
|
.then(() => info("Checking remote video enabled"))
|
|
.then(() => checkVideoEnabled(remoteVideo))
|
|
|
|
.then(() => info("Disabling original"))
|
|
.then(() => test.pcLocal.streams[0].getVideoTracks()[0].enabled = false)
|
|
|
|
.then(() => info("Checking local video disabled"))
|
|
.then(() => checkVideoDisabled(localVideo))
|
|
.then(() => info("Checking remote video disabled"))
|
|
.then(() => checkVideoDisabled(remoteVideo))
|
|
},
|
|
function CHECK_AUDIO() {
|
|
var ac = new AudioContext();
|
|
var localAnalyser = new AudioStreamAnalyser(ac, test.pcLocal.streams[0]);
|
|
var remoteAnalyser = new AudioStreamAnalyser(ac, test.pcRemote.streams[0]);
|
|
|
|
var checkAudio = (analyser, fun) => analyser.waitForAnalysisSuccess(fun);
|
|
|
|
var freq1k = localAnalyser.binIndexForFrequency(1000);
|
|
var checkAudioEnabled = analyser =>
|
|
checkAudio(analyser, array => array[freq1k] > 200);
|
|
var checkAudioDisabled = analyser =>
|
|
checkAudio(analyser, array => array[freq1k] < 50);
|
|
|
|
return Promise.resolve()
|
|
.then(() => info("Checking local audio enabled"))
|
|
.then(() => checkAudioEnabled(localAnalyser))
|
|
.then(() => info("Checking remote audio enabled"))
|
|
.then(() => checkAudioEnabled(remoteAnalyser))
|
|
|
|
.then(() => test.pcLocal.streams[0].getAudioTracks()[0].enabled = false)
|
|
|
|
.then(() => info("Checking local audio disabled"))
|
|
.then(() => checkAudioDisabled(localAnalyser))
|
|
.then(() => info("Checking remote audio disabled"))
|
|
.then(() => checkAudioDisabled(remoteAnalyser))
|
|
}
|
|
]);
|
|
test.run();
|
|
});
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|