| 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 MediaStreamTrack::getSourceInfos."); | 11 description("Tests MediaStreamTrack::getSources."); |
| 12 | 12 |
| 13 var sources = null; | 13 var sources = null; |
| 14 var previousId; | 14 var previousId; |
| 15 | 15 |
| 16 function error() { | 16 function error() { |
| 17 testFailed('Stream generation failed.'); | 17 testFailed('Stream generation failed.'); |
| 18 finishJSTest(); | 18 finishJSTest(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 function getUserMedia(constraints, callback) { | 21 function getUserMedia(constraints, callback) { |
| 22 try { | 22 try { |
| 23 navigator.webkitGetUserMedia(constraints, callback, error); | 23 navigator.webkitGetUserMedia(constraints, callback, error); |
| 24 } catch (e) { | 24 } catch (e) { |
| 25 testFailed('webkitGetUserMedia threw exception :' + e); | 25 testFailed('webkitGetUserMedia threw exception :' + e); |
| 26 finishJSTest(); | 26 finishJSTest(); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 function gotStream(s) { | 30 function gotSources2(s) { |
| 31 shouldNotThrow('sources = MediaStreamTrack.getSourceInfos();'); | 31 testPassed('gotSources2 was called.'); |
| 32 sources = s; |
| 32 shouldBeTrue('sources.length > 0'); | 33 shouldBeTrue('sources.length > 0'); |
| 33 shouldBeTrue('sources[0].id === previousId'); | 34 shouldBeTrue('sources[0].id === previousId'); |
| 34 shouldBeTrue('sources[0].label.length > 0'); | 35 shouldBeTrue('sources[0].label.length > 0'); |
| 36 |
| 35 finishJSTest(); | 37 finishJSTest(); |
| 36 } | 38 } |
| 37 | 39 |
| 38 shouldNotThrow('sources = MediaStreamTrack.getSourceInfos();'); | 40 function gotStream(s) { |
| 39 shouldBeTrue('sources.length > 0'); | 41 testPassed('gotStream was called.'); |
| 40 previousId = sources[0].id; | |
| 41 | 42 |
| 42 getUserMedia({audio:true, video:true}, gotStream); | 43 shouldNotThrow('MediaStreamTrack.getSources(gotSources2);'); |
| 44 } |
| 45 |
| 46 function gotSources1(s) { |
| 47 testPassed('gotSources1 was called.'); |
| 48 sources = s; |
| 49 shouldBeTrue('sources.length > 0'); |
| 50 previousId = sources[0].id; |
| 51 |
| 52 getUserMedia({audio:true, video:true}, gotStream); |
| 53 } |
| 54 |
| 55 shouldNotThrow('MediaStreamTrack.getSources(gotSources1);'); |
| 43 | 56 |
| 44 window.jsTestIsAsync = true; | 57 window.jsTestIsAsync = true; |
| 45 window.successfullyParsed = true; | 58 window.successfullyParsed = true; |
| 46 </script> | 59 </script> |
| 47 <script src="../js/resources/js-test-post.js"></script> | 60 <script src="../js/resources/js-test-post.js"></script> |
| 48 </body> | 61 </body> |
| 49 </html> | 62 </html> |
| OLD | NEW |