LibWebRTCRtpReceiverBackend::getSynchronizationSources should use Vector::append
[WebKit-https.git] / LayoutTests / webrtc / video-disabled-black.html
1 <!doctype html>
2 <html>
3     <head>
4         <meta charset="utf-8">
5         <title>Testing basic video exchange from offerer to receiver</title>
6         <script src="../resources/testharness.js"></script>
7         <script src="../resources/testharnessreport.js"></script>
8     </head>
9     <body>
10         <video id="video" autoplay playsinline></video>
11         <canvas id="canvas" width="640" height="480"></canvas>
12         <script src ="routines.js"></script>
13         <script>
14 if (window.testRunner)
15     testRunner.setUserMediaPermission(true);
16
17 video = document.getElementById("video");
18 canvas = document.getElementById("canvas");
19 // FIXME: We should use tracks
20
21 function testImage()
22 {
23     try {
24         if (!video.videoWidth || !video.videoHeight)
25             throw `Video size invalid: ${video.videoWidth}x${video.videoHeight}`;
26
27         canvas.width = video.videoWidth;
28         canvas.height = video.videoHeight;
29         canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
30
31         imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
32         assert_true(imageData.data.every( (pixel, index) => {
33             return pixel === 0 || (index % 4) === 3;
34         }));
35
36         finishTest();
37     } catch(e) {
38         errorTest(e);
39     }
40 }
41
42 function testStream(stream)
43 {
44     video.srcObject = stream;
45     video.onplay = setTimeout(() => {
46         stream.getTracks()[0].enabled = false;
47         setTimeout(() => {
48             testImage();
49         }, 0);
50     }, 2000);
51 }
52
53 var finishTest, errorTest;
54 promise_test((test) => {
55     return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
56         return new Promise((resolve, reject) => {
57             finishTest = resolve;
58             errorTest = reject;
59             createConnections((firstConnection) => {
60                 firstConnection.addTrack(stream.getVideoTracks()[0], stream);
61             }, (secondConnection) => {
62                 secondConnection.ontrack = (trackEvent) => { testStream(trackEvent.streams[0]); };
63             });
64         });
65     });
66 }, "Disabled source exchange");
67         </script>
68     </body>
69 </html>