OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
hta - Chromium
2016/07/19 09:56:48
This test is new. Can you make it a testharness.js
hbos_chromium
2016/07/19 13:59:34
Done. Much nicer.
| |
5 </head> | |
6 <body> | |
7 <script> | |
8 description("Tests the promise-based RTCPeerConnection.getStats function."); | |
9 | |
10 var pc = null; | |
11 var selector = null; | |
12 | |
13 function getUserMedia(dictionary, callback) { | |
14 try { | |
15 navigator.webkitGetUserMedia(dictionary, callback, error); | |
hta - Chromium
2016/07/19 09:56:48
Use navigator.mediaDevices.getUserMedia => promise
hbos_chromium
2016/07/19 13:59:34
Done.
| |
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(stream) { | |
28 testPassed('Got a stream.'); | |
29 | |
30 pc.addStream(stream); | |
31 shouldNotThrow('selector = pc.getLocalStreams()[0].getVideoTracks()[0]'); | |
32 shouldBeNonNull('selector'); | |
33 | |
34 shouldNotThrow('pc.getStats(selector).then(onResolve, onReject1)'); | |
35 } | |
36 | |
37 function onResolve(report) { | |
38 // Until getStats is implemented, we expect the promise to be rejected. | |
39 testFailed("onResolve called - getStats promise expected to be rejected."); | |
40 finishJSTest(); | |
41 } | |
42 function onReject1(reason) { | |
43 testPassed("pc.getStats(selector) was rejected."); | |
44 shouldNotThrow('pc.getStats().then(onResolve, onReject2)'); | |
hta - Chromium
2016/07/19 09:56:48
In general, when testing promises, it's better to
hbos_chromium
2016/07/19 13:59:34
Done.
| |
45 } | |
46 function onReject2(reason) { | |
47 testPassed("pc.getStats() was rejected."); | |
48 finishJSTest(); | |
49 } | |
50 | |
51 shouldNotThrow('pc = new webkitRTCPeerConnection(null)'); | |
52 shouldNotThrow('getUserMedia({audio:true, video:true}, gotStream)'); | |
53 | |
54 window.jsTestIsAsync = true; | |
55 window.successfullyParsed = true; | |
56 </script> | |
57 </body> | |
58 </html> | |
OLD | NEW |