| 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 <script> | |
| 8 description("Tests the RTCPeerConnection stats selector argument."); | |
| 9 | |
| 10 var pc = null; | |
| 11 var result; | |
| 12 | |
| 13 function getUserMedia(dictionary, callback) { | |
| 14 try { | |
| 15 navigator.webkitGetUserMedia(dictionary, callback, error); | |
| 16 } catch (e) { | |
| 17 testFailed('webkitGetUserMedia threw exception :' + e); | |
| 18 finishJSTest(); | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 function error() { | |
| 23 testFailed('Stream generation failed.'); | |
| 24 finishJSTest(); | |
| 25 } | |
| 26 | |
| 27 function gotStream(s) { | |
| 28 testPassed('Got a stream.'); | |
| 29 stream = s; | |
| 30 | |
| 31 pc.addStream(stream); | |
| 32 shouldNotThrow('pc.getStats(statsHandler2, pc.getLocalStreams()[0].getVideoT
racks()[0])'); | |
| 33 } | |
| 34 | |
| 35 function statsHandler2(status) | |
| 36 { | |
| 37 testPassed("statsHandler2 was called"); | |
| 38 result = status.result(); | |
| 39 shouldBeGreaterThanOrEqual('result.length', '1'); | |
| 40 // Windows XP sometimes gives time that appears to go backwards. | |
| 41 // This hack will make the tests non-flaky if it never goes backwards | |
| 42 // by more than 20 milliseconds. | |
| 43 // Up to 10 milliseconds has been observed on XP, 2 milliseconds on Win7. | |
| 44 fudgeForXP = 20; | |
| 45 res = result[0]; | |
| 46 timediff = res.timestamp - startTime + fudgeForXP; | |
| 47 shouldBeGreaterThanOrEqual('timediff', '0'); | |
| 48 shouldBe('res.stat("type")', '"video"'); | |
| 49 finishJSTest(); | |
| 50 } | |
| 51 | |
| 52 var startTime = new Date().getTime(); | |
| 53 shouldNotThrow('pc = new webkitRTCPeerConnection(null)'); | |
| 54 shouldNotThrow('getUserMedia({audio:true, video:true}, gotStream)'); | |
| 55 | |
| 56 window.jsTestIsAsync = true; | |
| 57 window.successfullyParsed = true; | |
| 58 </script> | |
| 59 </body> | |
| 60 </html> | |
| OLD | NEW |