tenfourfox/dom/media/tests/mochitest/test_peerConnection_bug825703.html
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

95 lines
2.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "825703",
title: "RTCConfiguration valid/invalid permutations"
});
var makePC = (config, expected_error) => {
var exception;
try {
new RTCPeerConnection(config).close();
} catch (e) {
exception = e;
}
is((exception? exception.name : "success"), expected_error || "success",
"RTCPeerConnection(" + JSON.stringify(config) + ")");
};
// This is a test of the iceServers parsing code + readable errors
runNetworkTest(() => {
var exception = null;
try {
new RTCPeerConnection().close();
} catch (e) {
exception = e;
}
ok(!exception, "RTCPeerConnection() succeeds");
exception = null;
makePC();
makePC(1, "TypeError");
makePC({});
makePC({ iceServers: [] });
makePC({ iceServers: [{ urls:"" }] }, "SyntaxError");
makePC({ iceServers: [
{ urls:"stun:127.0.0.1" },
{ urls:"stun:localhost", foo:"" },
{ urls: ["stun:127.0.0.1", "stun:localhost"] },
{ urls:"stuns:localhost", foo:"" },
{ urls:"turn:[::1]:3478", username:"p", credential:"p" },
{ urls:"turn:localhost:3478?transport=udp", username:"p", credential:"p" },
{ urls: ["turn:[::1]:3478", "turn:localhost"], username:"p", credential:"p" },
{ urls:"turns:localhost:3478?transport=udp", username:"p", credential:"p" },
{ url:"stun:localhost", foo:"" },
{ url:"turn:localhost", username:"p", credential:"p" }
]});
makePC({ iceServers: [{ urls: ["stun:127.0.0.1", ""] }] }, "SyntaxError");
makePC({ iceServers: [{ urls:"turns:localhost:3478", username:"p" }] }, "InvalidAccessError");
makePC({ iceServers: [{ url:"turns:localhost:3478", credential:"p" }] }, "InvalidAccessError");
makePC({ iceServers: [{ urls:"http:0.0.0.0" }] }, "SyntaxError");
try {
new RTCPeerConnection({ iceServers: [{ url:"http:0.0.0.0" }] }).close();
} catch (e) {
ok(e.message.indexOf("http") > 0,
"RTCPeerConnection() constructor has readable exceptions");
}
// Below tests are setting the about:config User preferences for default
// ice servers and checking the outputs when RTCPeerConnection() is
// invoked. See Bug 1167922 for more information.
// Note - We use promises here since the SpecialPowers API will be
// performed asynchronously.
var push = prefs => new Promise(resolve =>
SpecialPowers.pushPrefEnv(prefs, resolve));
push({ set: [['media.peerconnection.default_iceservers', ""]] })
.then(() => makePC())
.then(() => push({ set: [['media.peerconnection.default_iceservers', "k"]] }))
.then(() => makePC())
.then(() => push({ set: [['media.peerconnection.default_iceservers', "[{\"urls\": [\"stun:stun.services.mozilla.com\"]}]"]] }))
.then(() => makePC())
.then(networkTestFinished);
});
</script>
</pre>
</body>
</html>