mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
4952084732
Backed out changeset 321a932e01a7 (bug 1155923) Backed out changeset 6ac38acd6ab2 (bug 1155923) Backed out changeset 2981db92416a (bug 1155923)
95 lines
2.9 KiB
HTML
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 mozRTCPeerConnection(config).close();
|
|
} catch (e) {
|
|
exception = e;
|
|
}
|
|
is((exception? exception.name : "success"), expected_error || "success",
|
|
"mozRTCPeerConnection(" + JSON.stringify(config) + ")");
|
|
};
|
|
|
|
// This is a test of the iceServers parsing code + readable errors
|
|
runNetworkTest(() => {
|
|
var exception = null;
|
|
|
|
try {
|
|
new mozRTCPeerConnection().close();
|
|
} catch (e) {
|
|
exception = e;
|
|
}
|
|
ok(!exception, "mozRTCPeerConnection() 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 mozRTCPeerConnection({ iceServers: [{ url:"http:0.0.0.0" }] }).close();
|
|
} catch (e) {
|
|
ok(e.message.indexOf("http") > 0,
|
|
"mozRTCPeerConnection() constructor has readable exceptions");
|
|
}
|
|
|
|
// Below tests are setting the about:config User preferences for default
|
|
// ice servers and checking the outputs when mozRTCPeerConnection() 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>
|