From 94cebd7b33171dbaf51281be818a27ac4ab593d7 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Mon, 25 Apr 2016 16:28:53 +0200 Subject: [PATCH] Backed out changeset a9fcd0e98cc3 (bug 1231981) --- dom/media/tests/mochitest/head.js | 7 +- dom/media/tests/mochitest/pc.js | 89 ++++--------------- dom/media/tests/mochitest/templates.js | 6 +- .../third_party/nICEr/src/ice/ice_candidate.c | 4 +- .../third_party/nICEr/src/ice/ice_ctx.c | 1 - .../peerconnection/PeerConnectionMedia.cpp | 26 +----- .../src/peerconnection/PeerConnectionMedia.h | 1 - testing/mochitest/runtests.py | 16 ++-- 8 files changed, 32 insertions(+), 118 deletions(-) diff --git a/dom/media/tests/mochitest/head.js b/dom/media/tests/mochitest/head.js index 4b2c1dd13a36..8f5b9c6cc817 100644 --- a/dom/media/tests/mochitest/head.js +++ b/dom/media/tests/mochitest/head.js @@ -337,12 +337,9 @@ function run_test(is_initiator,timeout) { function runTestWhenReady(testFunc) { setupEnvironment(); return testConfigured.then(options => testFunc(options)) - .catch(e => { - ok(false, 'Error executing test: ' + e + + .catch(e => ok(false, 'Error executing test: ' + e + ((typeof e.stack === 'string') ? - (' ' + e.stack.split('\n').join(' ... ')) : '')); - SimpleTest.finish(); - }); + (' ' + e.stack.split('\n').join(' ... ')) : ''))); } diff --git a/dom/media/tests/mochitest/pc.js b/dom/media/tests/mochitest/pc.js index d657cfd1c291..08e33f797f51 100644 --- a/dom/media/tests/mochitest/pc.js +++ b/dom/media/tests/mochitest/pc.js @@ -64,13 +64,7 @@ function PeerConnectionTest(options) { options.rtcpmux = "rtcpmux" in options ? options.rtcpmux : true; options.opus = "opus" in options ? options.opus : true; - if (iceServersArray.length) { - options.config_remote = options.config_remote || {} - options.config_local = options.config_local || {} - options.config_remote.iceServers = iceServersArray; - options.config_local.iceServers = iceServersArray; - } - else if (typeof turnServers !== "undefined") { + if (typeof turnServers !== "undefined") { if ((!options.turn_disabled_local) && (turnServers.local)) { if (!options.hasOwnProperty("config_local")) { options.config_local = {}; @@ -1685,7 +1679,7 @@ PeerConnectionWrapper.prototype = { * @param {object} stats * The stats to be verified for relayed vs. direct connection. */ - checkStatsIceConnectionType : function(stats, expectedLocalCandidateType) { + checkStatsIceConnectionType : function(stats) { let lId; let rId; for (let stat of stats.values()) { @@ -1704,25 +1698,21 @@ PeerConnectionWrapper.prototype = { "failed to find candidatepair IDs or stats for local: "+ lId +" remote: "+ rId); return; } - info("checkStatsIceConnectionType verifying: local=" + JSON.stringify(lCand) + " remote=" + JSON.stringify(rCand)); - expectedLocalCandidateType = expectedLocalCandidateType || "host"; - var candidateType = lCand.candidateType; - if ((lCand.mozLocalTransport === "tcp") && (candidateType === "relayed")) { - candidateType = "relayed-tcp"; + if ((this.configuration) && (typeof this.configuration.iceServers !== 'undefined')) { + info("Ice Server configured"); + // Note: the IP comparising is a workaround for bug 1097333 + // And this will fail if a TURN server address is a DNS name! + var serverIp = this.configuration.iceServers[0].url.split(':')[1]; + ok(lCand.candidateType == "relayed" || rCand.candidateType == "relayed" || + lCand.ipAddress === serverIp || rCand.ipAddress === serverIp, + "One peer uses a relay"); + } else { + info("P2P configured"); + ok(lCand.candidateType != "relayed" && rCand.candidateType != "relayed", + "Pure peer to peer call without a relay"); } - - if ((expectedLocalCandidateType === "serverreflexive") && - (candidateType === "peerreflexive")) { - // Be forgiving of prflx when expecting srflx, since that can happen due - // to timing. - candidateType = "serverreflexive"; - } - - is(candidateType, - expectedLocalCandidateType, - "Local candidate type is what we expected for selected pair"); }, /** @@ -1855,59 +1845,10 @@ function createHTML(options) { return scriptsReady.then(() => realCreateHTML(options)); } -var iceServerWebsocket; -var iceServersArray = []; - -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 - // packets for TURN TCP. - var enableHttpProxy = enable => new Promise(resolve => { - SpecialPowers.pushPrefEnv( - {'set': [['media.peerconnection.disable_http_proxy', !enable]]}, - resolve); - }); - - var spawnIceServer = () => new Promise( (resolve, reject) => { - iceServerWebsocket = new WebSocket("ws://localhost:8191/"); - iceServerWebsocket.onopen = (event) => { - info("websocket/process bridge open, starting ICE Server..."); - iceServerWebsocket.send("iceserver"); - } - - iceServerWebsocket.onmessage = event => { - // The first message will contain the iceServers configuration, subsequent - // messages are just logging. - info("ICE Server: " + event.data); - resolve(event.data); - } - - iceServerWebsocket.onerror = () => { - reject("ICE Server error: Is the ICE server websocket up?"); - } - - iceServerWebsocket.onclose = () => { - info("ICE Server websocket closed"); - reject("ICE Server gone before getting configuration"); - } - }); - - if (!useIceServer) { - info("Skipping ICE Server for this test"); - return enableHttpProxy(true); - } - - return enableHttpProxy(false) - .then(spawnIceServer) - .then(iceServersStr => { iceServersArray = JSON.parse(iceServersStr); }); -}; - -function runNetworkTest(testFunction, fixtureOptions) { - fixtureOptions = fixtureOptions || {} +function runNetworkTest(testFunction) { return scriptsReady.then(() => runTestWhenReady(options => startNetworkAndTest() - .then(() => setupIceServerConfig(fixtureOptions.useIceServer)) .then(() => testFunction(options)) ) ); diff --git a/dom/media/tests/mochitest/templates.js b/dom/media/tests/mochitest/templates.js index 7cc7dd96a2dc..62fbb38b2fe9 100644 --- a/dom/media/tests/mochitest/templates.js +++ b/dom/media/tests/mochitest/templates.js @@ -441,15 +441,13 @@ var commandsPeerConnectionOfferAnswer = [ function PC_LOCAL_CHECK_ICE_CONNECTION_TYPE(test) { return test.pcLocal.getStats().then(stats => { - test.pcLocal.checkStatsIceConnectionType(stats, - test.testOptions.expectedLocalCandidateType); + test.pcLocal.checkStatsIceConnectionType(stats); }); }, function PC_REMOTE_CHECK_ICE_CONNECTION_TYPE(test) { return test.pcRemote.getStats().then(stats => { - test.pcRemote.checkStatsIceConnectionType(stats, - test.testOptions.expectedRemoteCandidateType); + test.pcRemote.checkStatsIceConnectionType(stats); }); }, diff --git a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c index e3aa99703d49..f10c5fb43e00 100644 --- a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c +++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c @@ -215,8 +215,8 @@ int nr_ice_candidate_create(nr_ice_ctx *ctx,nr_ice_component *comp,nr_ice_socket nr_ice_candidate_compute_codeword(cand); - r_log(LOG_ICE,LOG_DEBUG,"ICE(%s)/CAND(%s): created candidate %s with type %s", - ctx->label,cand->codeword,cand->label,nr_ctype_name(ctype)); + r_log(LOG_ICE,LOG_DEBUG,"ICE(%s): created candidate %s with type %s", + ctx->label,cand->label,nr_ctype_name(ctype)); *candp=cand; diff --git a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c index b5b350e85895..03b972af0719 100644 --- a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c +++ b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c @@ -515,7 +515,6 @@ void nr_ice_gather_finished_cb(NR_SOCKET s, int h, void *cb_arg) ctx = cand->ctx; ctx->uninitialized_candidates--; - r_log(LOG_ICE,LOG_DEBUG,"ICE(%s)/CAND(%s): initialized, %d remaining",ctx->label,cand->codeword,ctx->uninitialized_candidates); /* Avoid the need for yet another initialization function */ if (cand->state == NR_ICE_CAND_STATE_INITIALIZING && cand->type == HOST) diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp index 6ec2cdb306d2..8cb953661e77 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp @@ -243,20 +243,10 @@ PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl *parent) mIceRestartState(ICE_RESTART_NONE) { } -nsresult -PeerConnectionMedia::InitProxy() +nsresult PeerConnectionMedia::Init(const std::vector& stun_servers, + const std::vector& turn_servers, + NrIceCtx::Policy policy) { -#if !defined(MOZILLA_EXTERNAL_LINKAGE) - // Allow mochitests to disable this, since mochitest configures a fake proxy - // that serves up content. - bool disable = Preferences::GetBool("media.peerconnection.disable_http_proxy", - false); - if (disable) { - mProxyResolveCompleted = true; - return NS_OK; - } -#endif - nsresult rv; nsCOMPtr pps = do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); @@ -314,16 +304,6 @@ PeerConnectionMedia::InitProxy() return NS_ERROR_FAILURE; } - return NS_OK; -} - -nsresult PeerConnectionMedia::Init(const std::vector& stun_servers, - const std::vector& turn_servers, - NrIceCtx::Policy policy) -{ - nsresult rv = InitProxy(); - NS_ENSURE_SUCCESS(rv, rv); - #if !defined(MOZILLA_EXTERNAL_LINKAGE) bool ice_tcp = Preferences::GetBool("media.peerconnection.ice.tcp", false); #else diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h index 5071e51699e8..9ea5bb8f2343 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h @@ -484,7 +484,6 @@ class PeerConnectionMedia : public sigslot::has_slots<> { SignalEndOfLocalCandidates; private: - nsresult InitProxy(); class ProtocolProxyQueryHandler : public nsIProtocolProxyCallback { public: explicit ProtocolProxyQueryHandler(PeerConnectionMedia *pcm) : diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index fd94c8679a57..39c2c7850177 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -528,7 +528,7 @@ class MochitestBase(object): self.update_mozinfo() self.server = None self.wsserver = None - self.websocketprocessbridge = None + self.websocketProcessBridge = None self.sslTunnel = None self._active_tests = None self._locations = None @@ -814,11 +814,11 @@ class MochitestBase(object): command = [sys.executable, os.path.join("websocketprocessbridge", "websocketprocessbridge.py")] - self.websocketprocessbridge = mozprocess.ProcessHandler(command, + self.websocketProcessBridge = mozprocess.ProcessHandler(command, cwd=SCRIPT_DIR) - self.websocketprocessbridge.run() + self.websocketProcessBridge.run() self.log.info("runtests.py | websocket/process bridge pid: %d" - % self.websocketprocessbridge.pid) + % self.websocketProcessBridge.pid) # ensure the server is up, wait for at most ten seconds for i in range(1,100): @@ -892,12 +892,12 @@ class MochitestBase(object): except Exception: self.log.critical('Exception stopping ssltunnel') - if self.websocketprocessbridge is not None: + if self.websocketProcessBridge is not None: try: - self.log.info('Stopping websocket/process bridge') - self.websocketprocessbridge.kill() + self.log.info('Stopping websocketProcessBridge') + self.websocketProcessBridge.kill() except Exception: - self.log.critical('Exception stopping websocket/process bridge') + self.log.critical('Exception stopping websocketProcessBridge') def copyExtraFilesToProfile(self, options): "Copy extra files or dirs specified on the command line to the testing profile."