summaryrefslogtreecommitdiff
path: root/dom/media/tests/mochitest/pc.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/tests/mochitest/pc.js')
-rw-r--r--dom/media/tests/mochitest/pc.js30
1 files changed, 29 insertions, 1 deletions
diff --git a/dom/media/tests/mochitest/pc.js b/dom/media/tests/mochitest/pc.js
index a9383358f9..2e9c7c63f1 100644
--- a/dom/media/tests/mochitest/pc.js
+++ b/dom/media/tests/mochitest/pc.js
@@ -1822,6 +1822,33 @@ function createHTML(options) {
var iceServerWebsocket;
var iceServersArray = [];
+var addTurnsSelfsignedCerts = () => {
+ var gUrl = SimpleTest.getTestFileURL('addTurnsSelfsignedCert.js');
+ var gScript = SpecialPowers.loadChromeScript(gUrl);
+ var certs = [];
+ // If the ICE server is running TURNS, and includes a "cert" attribute in
+ // its JSON, we set up an override that will forgive things like
+ // self-signed for it.
+ iceServersArray.forEach(iceServer => {
+ if (iceServer.hasOwnProperty("cert")) {
+ iceServer.urls.forEach(url => {
+ if (url.startsWith("turns:")) {
+ // Assumes no port or params!
+ certs.push({"cert": iceServer.cert, "hostname": url.substr(6)});
+ }
+ });
+ }
+ });
+
+ return new Promise((resolve, reject) => {
+ gScript.addMessageListener('certs-added', () => {
+ resolve();
+ });
+
+ gScript.sendAsyncMessage('add-turns-certs', certs);
+ });
+};
+
var setupIceServerConfig = useIceServer => {
// We disable ICE support for HTTP proxy when using a TURN server, because
// mochitest uses a fake HTTP proxy to serve content, which will eat our STUN
@@ -1863,7 +1890,8 @@ var setupIceServerConfig = useIceServer => {
return enableHttpProxy(false)
.then(spawnIceServer)
- .then(iceServersStr => { iceServersArray = JSON.parse(iceServersStr); });
+ .then(iceServersStr => { iceServersArray = JSON.parse(iceServersStr); })
+ .then(addTurnsSelfsignedCerts);
};
function runNetworkTest(testFunction, fixtureOptions) {