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