8e282b68c132114e9da3291edc6ae174e9ac6370
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / mediacapture-streams / MediaStream-gettrackid.https.html
1 <!doctype html>
2 <html>
3 <head>
4 <title>Retrieving a track from a MediaStream</title>
5 <link rel="author" title="Dominique Hazael-Massieux" href="mailto:dom@w3.org"/>
6 <link rel="help" href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#widl-MediaStream-getTrackById-MediaStreamTrack-DOMString-trackId">
7 </head>
8 <body>
9 <p class="instructions">When prompted, accept to share your video stream.</p>
10 <h1 class="instructions">Description</h1>
11 <p class="instructions">This test checks that MediaStream.getTrackById behaves as expected</p>
12
13 <div id='log'></div>
14 <script src=/resources/testharness.js></script>
15 <script src=/resources/testharnessreport.js></script>
16 <script>
17 var t = async_test("Tests that MediaStream.getTrackById works as expected", {timeout: 10000});
18 t.step(function () {
19   navigator.mediaDevices.getUserMedia({video: true})
20       .then(t.step_func(gotVideo), t.step_func(function (error) {
21         assert_unreached('Unexpected getUserMedia error: ' + error);
22       }));
23   function gotVideo(stream) {
24     var track = stream.getVideoTracks()[0];
25     assert_equals(track, stream.getTrackById(track.id), "getTrackById returns track of given id");
26     assert_equals(stream.getTrackById(track.id + "foo"), null, "getTrackById of inexistant id  returns null");
27     t.done();
28   }
29 });
30 </script>
31 </body>
32 </html>