blob: a825ea2d474fba3bacff3054631f08d151e94822 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing basic video exchange from offerer to receiver</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<video id="video" autoplay=""></video>
<canvas id="canvas" width="640" height="480"></canvas>
<script src ="routines.js"></script>
<script>
if (window.testRunner)
testRunner.setUserMediaPermission(true);
video = document.getElementById("video");
canvas = document.getElementById("canvas");
// FIXME: We should use tracks
function testImage()
{
try {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
assert_true(imageData.data.every( (pixel, index) => {
return pixel === 0 || (index % 4) === 3;
}));
finishTest();
} catch(e) {
errorTest(e);
}
}
function testStream(stream)
{
video.srcObject = stream;
video.onplay = setTimeout(() => {
stream.getTracks()[0].enabled = false;
setTimeout(() => {
testImage();
}, 0);
}, 500);
}
var finishTest, errorTest;
promise_test((test) => {
return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
return new Promise((resolve, reject) => {
finishTest = resolve;
errorTest = reject;
createConnections((firstConnection) => {
firstConnection.addTrack(stream.getVideoTracks()[0], stream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => { testStream(trackEvent.streams[0]); };
});
});
});
}, "Disabled source exchange");
</script>
</body>
</html>