| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Ensuring ICE UDP candidates have a valid port</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script> |
| function gatherCandidates(pc) |
| { |
| var candidates = []; |
| return new Promise((resolve, reject) => { |
| setTimeout(() => { |
| reject("gathering did time out with " + candidates.length + " candidates"); |
| }, 10000); |
| pc.onicecandidate = (event) => { |
| if (event.candidate === null) { |
| resolve(candidates); |
| return; |
| } |
| candidates.push(event.candidate.candidate); |
| }; |
| pc.createOffer().then((offer) => { |
| pc.setLocalDescription(offer); |
| }); |
| }); |
| } |
| |
| promise_test((test) => { |
| var pc = new RTCPeerConnection(); |
| pc.createDataChannel(""); |
| |
| var hasCandidate = false; |
| return gatherCandidates(pc).then((candidates) => { |
| for(candidate of candidates) { |
| if (candidate.toLowerCase().indexOf(" udp ") === -1) |
| continue; |
| items = candidate.split(" "); |
| var port = parseInt(items[5]); |
| assert_true(port > 1024, "port is expected to be above 1024 but was " + port); |
| hasCandidate = true; |
| } |
| assert_true(hasCandidate, "Candidates should be gathered"); |
| }); |
| }, "Checking UDP ICE candidate ports"); |
| </script> |
| </body> |
| </html> |