-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdtls.js
More file actions
93 lines (85 loc) · 2.5 KB
/
Copy pathdtls.js
File metadata and controls
93 lines (85 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* webrtc interop testing using using selenium
* Copyright (c) 2016, Philipp Hancke
*/
var os = require('os');
var test = require('tape');
var buildDriver = require('./webdriver').buildDriver;
var WebRTCClient = require('./webrtcclient');
function dtls(t, browserA, browserB, preferredAudioCodec) {
var driverA = buildDriver(browserA);
var driverB = buildDriver(browserB);
var clientA = new WebRTCClient(driverA);
var clientB = new WebRTCClient(driverB);
// static page with adapter shim
driverA.get('https://fippo.github.io/adapter/testpage.html')
.then(() => driverB.get('https://fippo.github.io/adapter/testpage.html'))
.then(() => clientA.create(null, {
name: 'ECDSA',
namedCurve: 'P-256'
}))
.then(() => clientB.create(null, {
name: 'ECDSA',
namedCurve: 'P-256'
}))
.then(() => clientA.getUserMedia({audio: true}))
.then((stream) => {
t.pass('got user media');
return clientA.addStream(stream);
})
.then(() => clientA.createOffer())
.then(offer => {
t.pass('created offer');
return clientA.setLocalDescription(offer); // modify offer here?
})
.then(offerWithCandidates => {
t.pass('offer ready to signal');
return clientB.setRemoteDescription(offerWithCandidates);
})
.then(() => clientB.createAnswer())
.then(answer => {
t.pass('created answer');
return clientB.setLocalDescription(answer); // modify answer here?
})
.then(answerWithCandidates => {
t.pass('answer ready to signal');
return clientA.setRemoteDescription(answerWithCandidates);
})
.then(() => // wait for the iceConnectionState to become either connected/completed
// or failed.
clientA.waitForIceConnectionStateChange())
.then(iceConnectionState => {
t.ok(iceConnectionState !== 'failed', 'ICE connection is established');
})
/*
* here is where the fun starts. getStats etc
*/
.then(() => {
if (browserA !== 'MicrosoftEdge') {
return clientA.getStats();
} else {
return clientB.getStats();
}
})
.then(stats => {
console.log(stats);
})
.then(() => Promise.all([driverA.quit(), driverB.quit()])
.then(() => {
t.end();
}))
.catch(err => {
t.fail(err);
});
}
test('Chrome-Edge', {skip: os.platform() !== 'win32'}, t => {
dtls(t, 'chrome', 'MicrosoftEdge');
});
test('Chrome-Firefox', t => {
dtls(t, 'chrome', 'firefox');
});
test('Firefox-Chrome', t => {
dtls(t, 'firefox', 'chrome');
});
test('Edge-Chrome', {skip: os.platform() !== 'win32'}, t => {
dtls(t, 'MicrosoftEdge', 'chrome');
});