| 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("Test onactive/oninactive 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 streamActive() { |
| 29 testPassed('streamEnded was called.'); | 29 testPassed('streamActive was called.'); |
| 30 shouldBeTrue('stream.ended'); | 30 shouldBeTrue('stream.active'); |
| 31 finishJSTest(); | 31 finishJSTest(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 function gotStream2(s) { | 34 function gotStream2(s) { |
| 35 stream = new webkitMediaStream(s); | 35 stream = new webkitMediaStream(); |
| 36 shouldBeFalse('stream.ended'); | 36 shouldBeFalse('stream.active'); |
| 37 try { | 37 stream.onactive = streamActive; |
| 38 stream.onended = streamEnded2; | 38 stream.addTrack(s.getAudioTracks()[0]); |
| 39 s.stop(); | |
| 40 } catch (e) { | |
| 41 testFailed('MediaStream threw exception :' + e); | |
| 42 finishJSTest(); | |
| 43 } | |
| 44 } | 39 } |
| 45 | 40 |
| 46 function streamEnded() { | 41 function streamInactive() { |
| 47 testPassed('streamEnded was called.'); | 42 testPassed('streamInactive was called.'); |
| 48 shouldBeTrue('stream.ended'); | 43 shouldBeFalse('stream.active'); |
| 49 | 44 |
| 50 getUserMedia({audio:true, video:true}, gotStream2); | 45 getUserMedia({audio:true, video:true}, gotStream2); |
| 51 } | 46 } |
| 52 | 47 |
| 53 function gotStream(s) { | 48 function gotStream(s) { |
| 54 stream = s; | 49 stream = s; |
| 55 shouldBeFalse('stream.ended'); | 50 shouldBeTrue('stream.active'); |
| 56 try { | 51 stream.oninactive = streamInactive; |
| 57 stream.onended = streamEnded; | 52 shouldBe('stream.getAudioTracks().length', '1'); |
| 58 stream.stop(); | 53 shouldBe('stream.getVideoTracks().length', '1'); |
| 59 } catch (e) { | 54 stream.removeTrack(stream.getAudioTracks()[0]); |
| 60 testFailed('MediaStream threw exception :' + e); | 55 stream.removeTrack(stream.getVideoTracks()[0]); |
| 61 finishJSTest(); | |
| 62 } | |
| 63 } | 56 } |
| 64 | 57 |
| 65 getUserMedia({audio:true, video:true}, gotStream); | 58 getUserMedia({audio:true, video:true}, gotStream); |
| 66 | 59 |
| 67 window.jsTestIsAsync = true; | 60 window.jsTestIsAsync = true; |
| 68 window.successfullyParsed = true; | 61 window.successfullyParsed = true; |
| 69 </script> | 62 </script> |
| 70 </body> | 63 </body> |
| 71 </html> | 64 </html> |
| OLD | NEW |