 Chromium Code Reviews
 Chromium Code Reviews Issue 2156063002:
  Preparation for new Promise-based RTCPeerConnection.getStats.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2156063002:
  Preparation for new Promise-based RTCPeerConnection.getStats.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-statsPromise.html | 
| diff --git a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-statsPromise.html b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-statsPromise.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..a6a9dd390a54190f9e29e6216d1dec4966fc0f11 | 
| --- /dev/null | 
| +++ b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-statsPromise.html | 
| @@ -0,0 +1,58 @@ | 
| +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 
| +<html> | 
| +<head> | 
| +<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.
 | 
| +</head> | 
| +<body> | 
| +<script> | 
| +description("Tests the promise-based RTCPeerConnection.getStats function."); | 
| + | 
| +var pc = null; | 
| +var selector = null; | 
| + | 
| +function getUserMedia(dictionary, callback) { | 
| + try { | 
| + 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.
 | 
| + } catch (e) { | 
| + testFailed('webkitGetUserMedia threw exception :' + e); | 
| + finishJSTest(); | 
| + } | 
| +} | 
| + | 
| +function error() { | 
| + testFailed('Stream generation failed.'); | 
| + finishJSTest(); | 
| +} | 
| + | 
| +function gotStream(stream) { | 
| + testPassed('Got a stream.'); | 
| + | 
| + pc.addStream(stream); | 
| + shouldNotThrow('selector = pc.getLocalStreams()[0].getVideoTracks()[0]'); | 
| + shouldBeNonNull('selector'); | 
| + | 
| + shouldNotThrow('pc.getStats(selector).then(onResolve, onReject1)'); | 
| +} | 
| + | 
| +function onResolve(report) { | 
| + // Until getStats is implemented, we expect the promise to be rejected. | 
| + testFailed("onResolve called - getStats promise expected to be rejected."); | 
| + finishJSTest(); | 
| +} | 
| +function onReject1(reason) { | 
| + testPassed("pc.getStats(selector) was rejected."); | 
| + 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.
 | 
| +} | 
| +function onReject2(reason) { | 
| + testPassed("pc.getStats() was rejected."); | 
| + finishJSTest(); | 
| +} | 
| + | 
| +shouldNotThrow('pc = new webkitRTCPeerConnection(null)'); | 
| +shouldNotThrow('getUserMedia({audio:true, video:true}, gotStream)'); | 
| + | 
| +window.jsTestIsAsync = true; | 
| +window.successfullyParsed = true; | 
| +</script> | 
| +</body> | 
| +</html> |