diff options
Diffstat (limited to 'testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js')
-rw-r--r-- | testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js b/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js index 6f35fde76c..cd27b033d3 100644 --- a/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js +++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js @@ -230,6 +230,20 @@ async function waitForConnectionStateChange(pc, wantedStates) { } } +function waitForConnectionStateChangeWithTimeout(t, pc, wantedStates, timeout) { + return new Promise((resolve, reject) => { + if (wantedStates.includes(pc.connectionState)) { + resolve(); + return; + } + pc.addEventListener('connectionstatechange', () => { + if (wantedStates.includes(pc.connectionState)) + resolve(); + }); + t.step_timeout(reject, timeout); + }); +} + async function waitForIceGatheringState(pc, wantedStates) { while (!wantedStates.includes(pc.iceGatheringState)) { await waitUntilEvent(pc, 'icegatheringstatechange'); |