-
Notifications
You must be signed in to change notification settings - Fork 478
Expand file tree
/
Copy pathrollback.js
More file actions
85 lines (79 loc) · 2.31 KB
/
Copy pathrollback.js
File metadata and controls
85 lines (79 loc) · 2.31 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
"use strict";
const test = require("tape");
const { RTCPeerConnection } = require("..");
test("local rollback (wrong state)", async (t) => {
const pc = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
try {
await pc.setLocalDescription({ type: "rollback" });
t.fail();
} catch (error) {
t.pass(error);
} finally {
pc.close();
t.end();
}
});
test("remote rollback (wrong state)", async (t) => {
const pc = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
try {
await pc.setRemoteDescription({ type: "rollback" });
t.fail();
} catch (error) {
t.pass(error);
} finally {
pc.close();
t.end();
}
});
test("local rollback", async (t) => {
const pc = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
try {
pc.addTransceiver("audio");
const localDescription = await pc.createOffer();
await pc.setLocalDescription(localDescription);
t.equal(pc.signalingState, "have-local-offer");
await pc.setLocalDescription({ type: "rollback" });
t.equal(pc.signalingState, "stable");
} catch (error) {
t.fail(error);
} finally {
pc.close();
t.end();
}
});
test("remote rollback", async (t) => {
const pc1 = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
const pc2 = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
try {
pc1.addTransceiver("audio");
const remoteDescription = await pc1.createOffer();
await pc2.setRemoteDescription(remoteDescription);
t.equal(pc2.signalingState, "have-remote-offer");
await pc2.setRemoteDescription({ type: "rollback" });
t.equal(pc2.signalingState, "stable");
} catch (error) {
t.fail(`${error}`);
} finally {
pc1.close();
pc2.close();
t.end();
}
});
test("remote rollback", async (t) => {
const pc1 = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
const pc2 = new RTCPeerConnection({ sdpSemantics: "unified-plan" });
try {
pc1.addTransceiver("audio");
const remoteDescription = await pc1.createOffer();
await pc2.setRemoteDescription(remoteDescription);
t.equal(pc2.signalingState, "have-remote-offer");
await pc2.setRemoteDescription({ type: "rollback" });
t.equal(pc2.signalingState, "stable");
} catch (error) {
t.fail(`${error}`);
} finally {
pc1.close();
pc2.close();
t.end();
}
});