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
|
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1087629",
title: "Wait for ICE failure"
});
// Test iceFailure
function PC_LOCAL_SETUP_NULL_ICE_HANDLER(test) {
test.pcLocal.setupIceCandidateHandler(test, function() {}, function () {});
}
function PC_REMOTE_SETUP_NULL_ICE_HANDLER(test) {
test.pcRemote.setupIceCandidateHandler(test, function() {}, function () {});
}
function PC_REMOTE_ADD_FAKE_ICE_CANDIDATE(test) {
var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.1 12345 typ host","sdpMid":"","sdpMLineIndex":0};
test.pcRemote.storeOrAddIceCandidate(cand);
info(test.pcRemote + " Stored fake candidate: " + JSON.stringify(cand));
}
function PC_LOCAL_ADD_FAKE_ICE_CANDIDATE(test) {
var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.2 56789 typ host","sdpMid":"","sdpMLineIndex":0};
test.pcLocal.storeOrAddIceCandidate(cand);
info(test.pcLocal + " Stored fake candidate: " + JSON.stringify(cand));
}
function PC_LOCAL_WAIT_FOR_ICE_FAILURE(test) {
return test.pcLocal.iceFailed.then(() => {
ok(true, this.pcLocal + " Ice Failure Reached.");
});
}
function PC_REMOTE_WAIT_FOR_ICE_FAILURE(test) {
return test.pcRemote.iceFailed.then(() => {
ok(true, this.pcRemote + " Ice Failure Reached.");
});
}
function PC_LOCAL_WAIT_FOR_ICE_FAILED(test) {
var resolveIceFailed;
test.pcLocal.iceFailed = new Promise(r => resolveIceFailed = r);
test.pcLocal.ice_connection_callbacks.checkIceStatus = () => {
if (test.pcLocal._pc.iceConnectionState === "failed") {
resolveIceFailed();
}
}
}
function PC_REMOTE_WAIT_FOR_ICE_FAILED(test) {
var resolveIceFailed;
test.pcRemote.iceFailed = new Promise(r => resolveIceFailed = r);
test.pcRemote.ice_connection_callbacks.checkIceStatus = () => {
if (test.pcRemote._pc.iceConnectionState === "failed") {
resolveIceFailed();
}
}
}
runNetworkTest(async () => {
await pushPrefs(
['media.peerconnection.ice.stun_client_maximum_transmits', 3],
['media.peerconnection.ice.trickle_grace_period', 3000],
);
var test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER);
test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER);
test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_FAILED);
test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_FAILED", PC_REMOTE_WAIT_FOR_ICE_FAILED);
test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
test.chain.append([
PC_REMOTE_ADD_FAKE_ICE_CANDIDATE,
PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
PC_LOCAL_WAIT_FOR_ICE_FAILURE,
PC_REMOTE_WAIT_FOR_ICE_FAILURE
]);
await test.run();
});
</script>
</pre>
</body>
</html>
|