diff --git a/package.json b/package.json index 401bcad8e..662696be1 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ ], "devDependencies": { "chai": "^4.3.6", - "chromedriver": "^98.0.1", + "chromedriver": ">98.0.1", "eslint": "^8.9.0", "eslint-config-google": "^0.14.0", "geckodriver": "^3.0.1", diff --git a/src/content/peerconnection/restart-ice/js/main.js b/src/content/peerconnection/restart-ice/js/main.js index ffb7b92d7..6e996789a 100644 --- a/src/content/peerconnection/restart-ice/js/main.js +++ b/src/content/peerconnection/restart-ice/js/main.js @@ -32,6 +32,8 @@ remoteVideo.addEventListener('loadedmetadata', function() { console.log(`Remote video videoWidth: ${this.videoWidth}px, videoHeight: ${this.videoHeight}px`); }); +const useSelectedCandidatePairChange = window.RTCIceTransport && 'onselectedcandidatepairchange' in RTCIceTransport.prototype; + remoteVideo.onresize = () => { console.log(`Remote video size changed to ${remoteVideo.videoWidth}x${remoteVideo.videoHeight}`); // We'll use the first onsize callback as an indication that video has started @@ -170,6 +172,18 @@ function onCreateAnswerSuccess(desc) { pc2.setLocalDescription(desc).then(() => onSetLocalSuccess(pc2), onSetSessionDescriptionError); console.log('pc1 setRemoteDescription start'); pc1.setRemoteDescription(desc).then(() => onSetRemoteSuccess(pc1), onSetSessionDescriptionError); + + if (useSelectedCandidatePairChange) { + pc1.getSenders()[0].transport.iceTransport.onselectedcandidatepairchange = () => { + checkStats(pc1); + if (pc1.iceConnectionState === 'connected') { + restartButton.disabled = false; + } + }; + pc2.getSenders()[0].transport.iceTransport.onselectedcandidatepairchange = () => { + checkStats(pc2); + }; + } } function onIceCandidate(pc, event) { @@ -191,10 +205,11 @@ function onIceStateChange(pc, event) { if (pc) { console.log(`${getName(pc)} ICE state: ${pc.iceConnectionState}`); console.log('ICE state change event: ', event); - // TODO: get rid of this in favor of http://w3c.github.io/webrtc-pc/#widl-RTCIceTransport-onselectedcandidatepairchange - if (pc.iceConnectionState === 'connected' || - pc.iceConnectionState === 'completed') { - checkStats(pc); + if (!useSelectedCandidatePairChange) { + if (pc.iceConnectionState === 'connected' || + pc.iceConnectionState === 'completed') { + checkStats(pc); + } } } } diff --git a/src/content/peerconnection/restart-ice/js/test.js b/src/content/peerconnection/restart-ice/js/test.js index 5e0ec5acc..133a0ed67 100644 --- a/src/content/peerconnection/restart-ice/js/test.js +++ b/src/content/peerconnection/restart-ice/js/test.js @@ -16,7 +16,7 @@ let driver; const path = '/src/content/peerconnection/restart-ice/index.html'; const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`; -describe.skip('peerconnection ice restart', () => { +describe('peerconnection ice restart', () => { before(() => { driver = seleniumHelpers.buildDriver(); }); @@ -58,7 +58,6 @@ describe.skip('peerconnection ice restart', () => { await driver.wait(() => driver.findElement(webdriver.By.id('restartButton')).isEnabled()); await driver.findElement(webdriver.By.id('restartButton')).click(); - await driver.wait(() => !driver.findElement(webdriver.By.id('restartButton')).isEnabled()); await driver.wait(() => driver.findElement(webdriver.By.id('restartButton')).isEnabled()); const secondCandidateIds = await Promise.all([