OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 description("Test cloning mediastreams onended."); | 8 description("Test cloning mediastreams onactive/oninactive callbacks."); |
9 | 9 |
10 var cloned_stream; | 10 var cloned_stream; |
11 | 11 |
12 function onStreamEnded() { | 12 function error() { |
13 testPassed('Stream ended.'); | 13 testFailed('Stream generation failed.'); |
14 finishJSTest(); | 14 finishJSTest(); |
15 } | 15 } |
16 | 16 |
17 function onTrackAdded() { | 17 function getUserMedia(dictionary, callback) { |
18 testPassed('Mock test track added.'); | 18 try { |
19 shouldBe('cloned_stream.getVideoTracks().length', '1'); | 19 navigator.webkitGetUserMedia(dictionary, callback, error); |
20 cloned_stream.getVideoTracks()[0].stop(); | 20 } catch (e) { |
| 21 testFailed('webkitGetUserMedia threw exception :' + e); |
| 22 finishJSTest(); |
| 23 } |
21 } | 24 } |
22 | 25 |
23 function run(s) { | 26 function onStreamActive() { |
24 cloned_stream = new webkitMediaStream(); | 27 testPassed('Clone stream active.'); |
25 cloned_stream.onaddtrack = onTrackAdded; | 28 shouldBeTrue('cloned_stream.active'); |
26 cloned_stream.onended = onStreamEnded; | 29 finishJSTest(); |
27 } | 30 } |
28 | 31 |
29 run(); | 32 function gotStream2(s) { |
| 33 cloned_stream.onactive = onStreamActive; |
| 34 cloned_stream.addTrack(s.getVideoTracks()[0]); |
| 35 } |
| 36 |
| 37 function onStreamInactive() { |
| 38 testPassed('Clone stream inactive.'); |
| 39 shouldBeFalse('cloned_stream.active'); |
| 40 |
| 41 getUserMedia({audio:true, video:true}, gotStream2); |
| 42 } |
| 43 |
| 44 function gotStream(s) { |
| 45 var stream = s; |
| 46 |
| 47 cloned_stream = stream.clone(); |
| 48 cloned_stream.oninactive = onStreamInactive; |
| 49 shouldBeTrue('cloned_stream.active'); |
| 50 shouldBe('cloned_stream.getVideoTracks().length', '1'); |
| 51 shouldBe('cloned_stream.getAudioTracks().length', '1'); |
| 52 cloned_stream.getVideoTracks()[0].stop(); |
| 53 cloned_stream.getAudioTracks()[0].stop(); |
| 54 } |
| 55 |
| 56 getUserMedia({audio:true, video:true}, gotStream); |
30 | 57 |
31 window.jsTestIsAsync = true; | 58 window.jsTestIsAsync = true; |
32 window.successfullyParsed = true; | 59 window.successfullyParsed = true; |
33 </script> | 60 </script> |
34 </body> | 61 </body> |
35 </html> | 62 </html> |
OLD | NEW |