131 lines
4.5 KiB
HTML
131 lines
4.5 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Testing ICE candidate filtering when using data channel</title>
|
|
<script src="../../resources/testharness.js"></script>
|
|
<script src="../../resources/testharnessreport.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
promise_test((test) => {
|
|
return new Promise((resolve, reject) => {
|
|
setTimeout(() => { reject("Test timed out"); }, 5000);
|
|
|
|
if (window.internals)
|
|
internals.setICECandidateFiltering(true);
|
|
|
|
var counter = 0;
|
|
var pc = new RTCPeerConnection();
|
|
pc.createDataChannel('sendDataChannel');
|
|
pc.onicecandidate = (event) => {
|
|
if (event.candidate) {
|
|
counter++;
|
|
return;
|
|
}
|
|
assert_equals(pc.localDescription.sdp.indexOf("a=candidate"), -1);
|
|
assert_true(pc.localDescription.sdp.indexOf("c=IN IP4 0.0.0.0\r\n") != -1 || pc.localDescription.sdp.indexOf("c=IN IP6 ::\r\n") != -1);
|
|
if (counter === 0) {
|
|
pc.createOffer().then((offer) => {
|
|
assert_true(offer.sdp.indexOf("c=IN IP4 0.0.0.0\r\n") != -1 || pc.localDescription.sdp.indexOf("c=IN IP6 ::\r\n") != -1);
|
|
assert_equals(offer.sdp.indexOf("a=candidate"), -1);
|
|
resolve();
|
|
});
|
|
} else
|
|
reject("No candidate should be found");
|
|
};
|
|
pc.createOffer().then((offer) => {
|
|
assert_equals(offer.sdp.indexOf("a=candidate"), -1);
|
|
pc.setLocalDescription(offer);
|
|
});
|
|
});
|
|
}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on");
|
|
|
|
promise_test((test) => {
|
|
return new Promise((resolve, reject) => {
|
|
setTimeout(() => { reject("Test timed out"); }, 5000);
|
|
|
|
if (window.internals)
|
|
internals.setICECandidateFiltering(false);
|
|
|
|
var counter = 0;
|
|
var pc = new RTCPeerConnection();
|
|
pc.createDataChannel('sendDataChannel');
|
|
pc.onicecandidate = (event) => {
|
|
if (event.candidate) {
|
|
counter++;
|
|
return;
|
|
}
|
|
assert_true(pc.localDescription.sdp.indexOf("c=IN IP4 0.0.0.0\r\n") === -1 && pc.localDescription.sdp.indexOf("c=IN IP6 ::\r\n") === -1);
|
|
assert_false(pc.localDescription.sdp.indexOf("a=candidate") === -1);
|
|
if (counter !== 0) {
|
|
// Redoing an offer now that we have some candidates.
|
|
pc.createOffer().then((offer) => {
|
|
assert_true(offer.sdp.indexOf("c=IN IP4 0.0.0.0\r\n") === -1 && pc.localDescription.sdp.indexOf("c=IN IP6 ::\r\n") === -1);
|
|
assert_false(offer.sdp.indexOf("a=candidate") === -1);
|
|
resolve();
|
|
});
|
|
} else
|
|
reject("Host candidates should be found");
|
|
};
|
|
pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
|
|
});
|
|
}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off");
|
|
|
|
promise_test(async (test) => {
|
|
if (window.internals)
|
|
internals.setICECandidateFiltering(true);
|
|
|
|
const pc = new RTCPeerConnection();
|
|
|
|
let resolve;
|
|
const promise = new Promise(r => resolve = r);
|
|
|
|
pc.createDataChannel('sendDataChannel');
|
|
pc.onicecandidate = (event) => {
|
|
if (event.candidate) {
|
|
if (event.candidate.protocol !== "tcp")
|
|
return;
|
|
assert_equals(event.candidate.port, 9);
|
|
assert_true(event.candidate.address.indexOf(".local") !== -1);
|
|
return;
|
|
}
|
|
resolve();
|
|
}
|
|
pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
|
|
|
|
await promise;
|
|
|
|
pc.onicecandidate = null;
|
|
}, "Verify TCP candidates with filtering");
|
|
|
|
promise_test(async (test) => {
|
|
if (window.internals)
|
|
internals.setICECandidateFiltering(false);
|
|
|
|
const pc = new RTCPeerConnection();
|
|
|
|
let resolve;
|
|
const promise = new Promise(r => resolve = r);
|
|
|
|
pc.createDataChannel('sendDataChannel');
|
|
pc.onicecandidate = (event) => {
|
|
if (event.candidate) {
|
|
if (event.candidate.protocol !== "tcp")
|
|
return;
|
|
assert_equals(event.candidate.port, 9);
|
|
assert_true(event.candidate.address.indexOf(".local") === -1);
|
|
return;
|
|
}
|
|
resolve();
|
|
}
|
|
pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
|
|
|
|
await promise;
|
|
|
|
pc.onicecandidate = null;
|
|
}, "Verify TCP candidates without filtering");
|
|
</script>
|
|
</body>
|
|
</html>
|