<!-- These files are in place when executing on W3C. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script type="text/javascript">
let gFirstConnection = null;
let gSecondConnection = null;
function onIceConnectionStateChange(done, failed, event) {
try {
assert_equals(event.type, 'iceconnectionstatechange');
assert_not_equals(gFirstConnection.iceConnectionState, "failed", "iceConnectionState of first connection");
assert_not_equals(gSecondConnection.iceConnectionState, "failed", "iceConnectionState of second connection");
const stateinfo = document.getElementById('stateinfo');
stateinfo.innerHTML = 'First: ' + gFirstConnection.iceConnectionState
+ ' Second: ' + gSecondConnection.iceConnectionState;
// Note: All these combinations are legal states indicating that the
// call has connected. All browsers should end up in completed/completed,
// but as of this moment, we've chosen to terminate the test early.
// TODO: Revise test to ensure completed/completed is reached.
const allowedStates = [ 'connected', 'completed'];
if (allowedStates.includes(gFirstConnection.iceConnectionState) &&
allowedStates.includes(gSecondConnection.iceConnectionState)) {
done();
}
} catch(e) {
failed(e);
}
};
// This function starts the test.
promise_test((test) => {
return new Promise(async (resolve, reject) => {
gFirstConnection = new RTCPeerConnection(null);
test.add_cleanup(() => gFirstConnection.close());
gFirstConnection.onicecandidate =
(event) => onIceCandidate(gSecondConnection, event, reject);
gFirstConnection.oniceconnectionstatechange =
(event) => onIceConnectionStateChange(resolve, reject, event);
// Similarly, this would go over the application's signaling solution.
await gFirstConnection.setRemoteDescription({ type: 'answer',
sdp: answer.sdp });
// The test is terminated by onIceConnectionStateChange() calling resolve
// once both connections are connected.
})
});
</script>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.