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