blob: 1323140bff651a702d63f6b2f73e6af9ffe02ce7 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing DTLS10 connectivity</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
'use strict';
var useDTLS10ForLocalConnection = false;
var useDTLS10ForRemoteConnection = false;
async function createDTLS10andDTLS12Connections(setupLocalConnection, setupRemoteConnection) {
internals.setUseDTLS10(useDTLS10ForLocalConnection);
const localConnection = new RTCPeerConnection();
internals.setUseDTLS10(useDTLS10ForRemoteConnection);
const remoteConnection = new RTCPeerConnection();
internals.setUseDTLS10(false);
remoteConnection.onicecandidate = (event) => { localConnection.addIceCandidate(event.candidate); };
localConnection.onicecandidate = (event) => { remoteConnection.addIceCandidate(event.candidate); };
setupLocalConnection(localConnection);
setupRemoteConnection(localConnection);
const offer = await localConnection.createOffer();
await localConnection.setLocalDescription(offer);
await remoteConnection.setRemoteDescription(offer);
const answer = await remoteConnection.createAnswer();
await remoteConnection.setLocalDescription(answer);
await localConnection.setRemoteDescription(answer);
return [localConnection, remoteConnection];
}
promise_test(async (test) => {
if (!window.internals)
return Promise.reject("test requires internals");
useDTLS10ForLocalConnection = false;
useDTLS10ForRemoteConnection = false;
const [localConnection, remoteConnection] = await createDTLS10andDTLS12Connections((connection) => {
connection.createDataChannel('test');
}, (remoteConnection) => {
});
let counter = 0;
while (++counter < 20) {
if (localConnection.connectionState === "connected")
return;
await new Promise(resolve => setTimeout(resolve, 10));
}
}, "Verify regular clients can connect with each other");
promise_test(async (test) => {
if (!window.internals)
return Promise.reject("test requires internals");
useDTLS10ForLocalConnection = false;
useDTLS10ForRemoteConnection = true;
const [localConnection, remoteConnection] = await createDTLS10andDTLS12Connections((connection) => {
connection.createDataChannel('test');
}, (remoteConnection) => {
});
await new Promise(resolve => setTimeout(resolve, 200));
assert_not_equals(localConnection.connectionState, "connected");
}, "Verify regular clients cannot connect with DTLS1-only clients");
</script>
</body>
</html>