Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ice-restart: fix functionality #1534

Merged
merged 3 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
test:
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
browser: [chrome]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"start": "http-server . -c-1",
"test": "npm run eslint && npm run stylelint",
"eslint": "eslint 'src/content/**/*.js'",
"mocha": "mocha 'src/content/**/test.js'",
"mocha": "mocha --timeout 5000 'src/content/**/test.js'",
"stylelint": "stylelint 'src/**/*.css'"
},
"eslintIgnore": [
"'**/third_party/*.js'"
],
"devDependencies": {
"chai": "^4.3.6",
"chromedriver": "^98.0.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by fix, otherwise chromedriver gets stuck on a version incompatible with the chrome version that gets installed

"chromedriver": ">98.0.1",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"geckodriver": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/content/datachannel/filetransfer/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let driver;
const path = '/src/content/datachannel/filetransfer/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('datachannel basic', () => {
describe('datachannel filetransfer', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by too

before(() => {
driver = seleniumHelpers.buildDriver();
});
Expand Down
23 changes: 19 additions & 4 deletions src/content/peerconnection/restart-ice/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/content/peerconnection/restart-ice/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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([
Expand Down