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