Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / mediastream / RTCPeerConnection-stats.html
blobd7ec572bf54046b5cf1d8fede9231e5cc1a07283
2 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
3 <html>
4 <head>
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Tests the RTCPeerConnection stats interface.");
11 var pc = null;
12 var result;
14 function getUserMedia(dictionary, callback) {
15 try {
16 navigator.webkitGetUserMedia(dictionary, callback, error);
17 } catch (e) {
18 testFailed('webkitGetUserMedia threw exception :' + e);
19 finishJSTest();
23 function error() {
24 testFailed('Stream generation failed.');
25 finishJSTest();
28 function verifyStats(status)
30 // Status must be a global variable to be used in test statements.
31 status_g = status;
32 result = status.result();
33 shouldBeGreaterThanOrEqual('result.length', '2');
34 // Windows XP sometimes gives time that appears to go backwards.
35 // This hack will make the tests non-flaky if it never goes backwards
36 // by more than 20 milliseconds.
37 // Up to 10 milliseconds has been observed on XP, 2 milliseconds on Win7.
38 fudgeForXP = 20;
39 res = result[0];
40 timediff = res.timestamp - startTime + fudgeForXP;
41 shouldBeGreaterThanOrEqual('timediff', '0');
42 shouldBeNonNull('res.id');
43 shouldBeNonNull('res.type');
44 shouldBeGreaterThanOrEqual('res.names().length', '1');
45 shouldBeGreaterThanOrEqual('res.names().indexOf("type")', '0');
46 shouldBe('res.stat("type")', '"audio"');
47 // Named getter: Can access results by their ID values.
48 shouldBeNonNull('status_g.namedItem(res.id)');
49 shouldBeNonNull('status_g[res.id]');
52 function statsHandler1(status)
54 testPassed("statsHandler1 was called");
55 shouldBeNonNull('status');
56 result = status.result();
57 shouldBe('result.length', '0');
58 shouldNotThrow('getUserMedia({audio:true, video:true}, gotStream)');
61 function gotStream(s) {
62 testPassed('Got a stream.');
63 stream = s;
65 pc.addStream(stream);
66 shouldNotThrow('pc.getStats(statsHandler2)');
69 function statsHandler2(status)
71 testPassed("statsHandler2 was called");
72 verifyStats(status);
73 shouldNotThrow('pc.close()');
74 shouldNotThrow('pc.getStats(statsHandler3)');
77 function statsHandler3(status)
79 testPassed("statsHandler3 was called");
80 verifyStats(status);
81 finishJSTest();
84 var startTime = new Date().getTime();
85 shouldNotThrow('pc = new webkitRTCPeerConnection(null)');
86 shouldNotThrow('pc.getStats(statsHandler1)');
88 window.jsTestIsAsync = true;
89 window.successfullyParsed = true;
90 </script>
91 </body>
92 </html>