-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdatachannel.js
More file actions
62 lines (56 loc) · 1.78 KB
/
Copy pathdatachannel.js
File metadata and controls
62 lines (56 loc) · 1.78 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
/* 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 getTestpage = require('./webdriver').getTestpage;
var WebRTCClient = require('./webrtcclient');
function interop(t, browserA, browserB, preferredAudioCodec) {
var driverA = buildDriver(browserA);
var driverB = buildDriver(browserB);
var clientA = new WebRTCClient(driverA);
var clientB = new WebRTCClient(driverB);
getTestpage(driverA)
.then(() => getTestpage(driverB))
.then(() => clientA.create())
.then(() => clientB.create())
.then(() => clientA.createDataChannel('somechannel'))
.then(() => clientA.createOffer())
.then(offer => {
t.pass('created offer');
return clientA.setLocalDescription(offer);
})
.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');
})
.then(() => Promise.all([driverA.quit(), driverB.quit()])
.then(() => {
t.end();
}))
.catch(err => {
t.fail(err);
});
}
test('Chrome-Firefox', t => {
interop(t, 'chrome', 'firefox');
});
test('Firefox-Chrome', t => {
interop(t, 'firefox', 'chrome');
});