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 <p id="description"></p> | 7 <p id="description"></p> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 <script> | 9 <script> |
10 description("Tests MediaStream::onended callback."); | 10 description("Tests MediaStream::onended callback."); |
11 | 11 |
12 function error() { | 12 function error() { |
13 testFailed('Stream generation failed.'); | 13 testFailed('Stream generation failed.'); |
14 finishJSTest(); | 14 finishJSTest(); |
15 } | 15 } |
16 | 16 |
17 function getUserMedia(dictionary, callback) { | 17 function getUserMedia(dictionary, callback) { |
18 try { | 18 try { |
19 navigator.webkitGetUserMedia(dictionary, callback, error); | 19 navigator.webkitGetUserMedia(dictionary, callback, error); |
20 } catch (e) { | 20 } catch (e) { |
21 testFailed('webkitGetUserMedia threw exception :' + e); | 21 testFailed('webkitGetUserMedia threw exception :' + e); |
22 finishJSTest(); | 22 finishJSTest(); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 var stream; | 26 var stream; |
27 | 27 |
28 function streamEnded2() { | 28 function streamEnded2() { |
29 testPassed('streamEnded was called.'); | 29 testPassed('streamEnded was called.'); |
30 shouldBeTrue('stream.ended'); | |
31 finishJSTest(); | 30 finishJSTest(); |
32 } | 31 } |
33 | 32 |
34 function gotStream2(s) { | 33 function gotStream2(s) { |
35 stream = new webkitMediaStream(s); | 34 stream = new webkitMediaStream(s); |
36 shouldBeFalse('stream.ended'); | |
37 try { | 35 try { |
38 stream.onended = streamEnded2; | 36 stream.onended = streamEnded2; |
39 s.stop(); | 37 s.getAudioTracks()[0].stop(); |
| 38 s.getVideoTracks()[0].stop(); |
40 } catch (e) { | 39 } catch (e) { |
41 testFailed('MediaStream threw exception :' + e); | 40 testFailed('MediaStream threw exception :' + e); |
42 finishJSTest(); | 41 finishJSTest(); |
43 } | 42 } |
44 } | 43 } |
45 | 44 |
46 function streamEnded() { | 45 function streamEnded() { |
47 testPassed('streamEnded was called.'); | 46 testPassed('streamEnded was called.'); |
48 shouldBeTrue('stream.ended'); | |
49 | |
50 getUserMedia({audio:true, video:true}, gotStream2); | 47 getUserMedia({audio:true, video:true}, gotStream2); |
51 } | 48 } |
52 | 49 |
53 function gotStream(s) { | 50 function gotStream(s) { |
54 stream = s; | 51 stream = s; |
55 shouldBeFalse('stream.ended'); | |
56 try { | 52 try { |
57 stream.onended = streamEnded; | 53 stream.onended = streamEnded; |
58 stream.stop(); | 54 s.getAudioTracks()[0].stop(); |
| 55 s.getVideoTracks()[0].stop(); |
59 } catch (e) { | 56 } catch (e) { |
60 testFailed('MediaStream threw exception :' + e); | 57 testFailed('MediaStream threw exception :' + e); |
61 finishJSTest(); | 58 finishJSTest(); |
62 } | 59 } |
63 } | 60 } |
64 | 61 |
65 getUserMedia({audio:true, video:true}, gotStream); | 62 getUserMedia({audio:true, video:true}, gotStream); |
66 | 63 |
67 window.jsTestIsAsync = true; | 64 window.jsTestIsAsync = true; |
68 window.successfullyParsed = true; | 65 window.successfullyParsed = true; |
69 </script> | 66 </script> |
70 </body> | 67 </body> |
71 </html> | 68 </html> |
OLD | NEW |