Skip to content

Commit

Permalink
Merge pull request #1119 from webrtcHacks/whitespace
Browse files Browse the repository at this point in the history
eslint and travis-multirunner updates, whitespace changes
  • Loading branch information
fippo authored Feb 20, 2023
2 parents a31c418 + 66671f6 commit c2de579
Show file tree
Hide file tree
Showing 33 changed files with 560 additions and 557 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- browser: firefox
version: esr
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install
- run: Xvfb :99 &
- name: e2e-tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install
- run: npm run lint-and-unit-tests
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(grunt) {
},
eslint: {
options: {
configFile: '.eslintrc'
overrideConfigFile: '.eslintrc'
},
target: ['src/**/*.js', 'test/*.js', 'test/unit/*.js', 'test/e2e/*.js']
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"mocha": "^10.1.0",
"sinon": "^2.2.0",
"sinon-chai": "^2.14.0",
"travis-multirunner": "^4.6.0"
"travis-multirunner": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion src/js/adapter_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import * as utils from './utils';

// Browser shims.
// Browser shims.
import * as chromeShim from './chrome/chrome_shim';
import * as firefoxShim from './firefox/firefox_shim';
import * as safariShim from './safari/safari_shim';
Expand Down
58 changes: 29 additions & 29 deletions src/js/chrome/chrome_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* that can be found in the LICENSE file in the root of the source
* tree.
*/
/* eslint-env node */
/* eslint-env node */
'use strict';
import * as utils from '../utils.js';

Expand Down Expand Up @@ -399,7 +399,7 @@ export function shimAddTrackRemoveTrackWithNative(window) {
const alreadyExists = this.getSenders().find(s => s.track === track);
if (alreadyExists) {
throw new DOMException('Track already exists.',
'InvalidAccessError');
'InvalidAccessError');
}
});
const existingSenders = this.getSenders();
Expand Down Expand Up @@ -449,7 +449,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
// also shim pc.getLocalStreams when addTrack is shimmed
// to return the original streams.
const origGetLocalStreams = window.RTCPeerConnection.prototype
.getLocalStreams;
.getLocalStreams;
window.RTCPeerConnection.prototype.getLocalStreams =
function getLocalStreams() {
const nativeStreams = origGetLocalStreams.apply(this);
Expand All @@ -466,7 +466,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
const alreadyExists = this.getSenders().find(s => s.track === track);
if (alreadyExists) {
throw new DOMException('Track already exists.',
'InvalidAccessError');
'InvalidAccessError');
}
});
// Add identity mapping for consistency with addTrack.
Expand All @@ -488,7 +488,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {

origRemoveStream.apply(this, [(this._streams[stream.id] || stream)]);
delete this._reverseStreams[(this._streams[stream.id] ?
this._streams[stream.id].id : stream.id)];
this._streams[stream.id].id : stream.id)];
delete this._streams[stream.id];
};

Expand All @@ -513,7 +513,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
const alreadyExists = this.getSenders().find(s => s.track === track);
if (alreadyExists) {
throw new DOMException('Track already exists.',
'InvalidAccessError');
'InvalidAccessError');
}

this._streams = this._streams || {};
Expand Down Expand Up @@ -547,7 +547,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
const externalStream = pc._reverseStreams[internalId];
const internalStream = pc._streams[externalStream.id];
sdp = sdp.replace(new RegExp(internalStream.id, 'g'),
externalStream.id);
externalStream.id);
});
return new RTCSessionDescription({
type: description.type,
Expand All @@ -560,7 +560,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
const externalStream = pc._reverseStreams[internalId];
const internalStream = pc._streams[externalStream.id];
sdp = sdp.replace(new RegExp(externalStream.id, 'g'),
internalStream.id);
internalStream.id);
});
return new RTCSessionDescription({
type: description.type,
Expand All @@ -587,7 +587,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
]);
}
return nativeMethod.apply(this, arguments)
.then(description => replaceInternalStreamId(this, description));
.then(description => replaceInternalStreamId(this, description));
}};
window.RTCPeerConnection.prototype[method] = methodObj[method];
});
Expand All @@ -606,17 +606,17 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
// TODO: mangle getStats: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamstats-streamidentifier

const origLocalDescription = Object.getOwnPropertyDescriptor(
window.RTCPeerConnection.prototype, 'localDescription');
window.RTCPeerConnection.prototype, 'localDescription');
Object.defineProperty(window.RTCPeerConnection.prototype,
'localDescription', {
get() {
const description = origLocalDescription.get.apply(this);
if (description.type === '') {
return description;
}
return replaceInternalStreamId(this, description);
'localDescription', {
get() {
const description = origLocalDescription.get.apply(this);
if (description.type === '') {
return description;
}
});
return replaceInternalStreamId(this, description);
}
});

window.RTCPeerConnection.prototype.removeTrack =
function removeTrack(sender) {
Expand All @@ -634,7 +634,7 @@ export function shimAddTrackRemoveTrack(window, browserDetails) {
const isLocal = sender._pc === this;
if (!isLocal) {
throw new DOMException('Sender was not created by this connection.',
'InvalidAccessError');
'InvalidAccessError');
}

// Search for the native stream the senders track belongs to.
Expand Down Expand Up @@ -674,16 +674,16 @@ export function shimPeerConnection(window, browserDetails) {
// shim implicit creation of RTCSessionDescription/RTCIceCandidate
if (browserDetails.version < 53) {
['setLocalDescription', 'setRemoteDescription', 'addIceCandidate']
.forEach(function(method) {
const nativeMethod = window.RTCPeerConnection.prototype[method];
const methodObj = {[method]() {
arguments[0] = new ((method === 'addIceCandidate') ?
window.RTCIceCandidate :
window.RTCSessionDescription)(arguments[0]);
return nativeMethod.apply(this, arguments);
}};
window.RTCPeerConnection.prototype[method] = methodObj[method];
});
.forEach(function(method) {
const nativeMethod = window.RTCPeerConnection.prototype[method];
const methodObj = {[method]() {
arguments[0] = new ((method === 'addIceCandidate') ?
window.RTCIceCandidate :
window.RTCSessionDescription)(arguments[0]);
return nativeMethod.apply(this, arguments);
}};
window.RTCPeerConnection.prototype[method] = methodObj[method];
});
}
}

Expand Down
33 changes: 17 additions & 16 deletions src/js/chrome/getusermedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,22 @@ export function shimGetUserMedia(window, browserDetails) {
if (matches) {
// Look for matches in label, or use last cam for back (typical).
return navigator.mediaDevices.enumerateDevices()
.then(devices => {
devices = devices.filter(d => d.kind === 'videoinput');
let dev = devices.find(d => matches.some(match =>
d.label.toLowerCase().includes(match)));
if (!dev && devices.length && matches.includes('back')) {
dev = devices[devices.length - 1]; // more likely the back cam
}
if (dev) {
constraints.video.deviceId = face.exact ? {exact: dev.deviceId} :
{ideal: dev.deviceId};
}
constraints.video = constraintsToChrome_(constraints.video);
logging('chrome: ' + JSON.stringify(constraints));
return func(constraints);
});
.then(devices => {
devices = devices.filter(d => d.kind === 'videoinput');
let dev = devices.find(d => matches.some(match =>
d.label.toLowerCase().includes(match)));
if (!dev && devices.length && matches.includes('back')) {
dev = devices[devices.length - 1]; // more likely the back cam
}
if (dev) {
constraints.video.deviceId = face.exact
? {exact: dev.deviceId}
: {ideal: dev.deviceId};
}
constraints.video = constraintsToChrome_(constraints.video);
logging('chrome: ' + JSON.stringify(constraints));
return func(constraints);
});
}
}
constraints.video = constraintsToChrome_(constraints.video);
Expand Down Expand Up @@ -171,7 +172,7 @@ export function shimGetUserMedia(window, browserDetails) {
// constraints.
if (navigator.mediaDevices.getUserMedia) {
const origGetUserMedia = navigator.mediaDevices.getUserMedia.
bind(navigator.mediaDevices);
bind(navigator.mediaDevices);
navigator.mediaDevices.getUserMedia = function(cs) {
return shimConstraints_(cs, c => origGetUserMedia(c).then(stream => {
if (c.audio && !stream.getAudioTracks().length ||
Expand Down
6 changes: 3 additions & 3 deletions src/js/common_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function shimRTCIceCandidate(window) {
const nativeCandidate = new NativeRTCIceCandidate(args);
const parsedCandidate = SDPUtils.parseCandidate(args.candidate);
const augmentedCandidate = Object.assign(nativeCandidate,
parsedCandidate);
parsedCandidate);

// Add a serializer that does not serialize the extra attributes.
augmentedCandidate.toJSON = function toJSON() {
Expand Down Expand Up @@ -308,12 +308,12 @@ export function shimConnectionState(window) {
set(cb) {
if (this._onconnectionstatechange) {
this.removeEventListener('connectionstatechange',
this._onconnectionstatechange);
this._onconnectionstatechange);
delete this._onconnectionstatechange;
}
if (cb) {
this.addEventListener('connectionstatechange',
this._onconnectionstatechange = cb);
this._onconnectionstatechange = cb);
}
},
enumerable: true,
Expand Down
46 changes: 23 additions & 23 deletions src/js/firefox/firefox_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ export function shimPeerConnection(window, browserDetails) {
if (browserDetails.version < 53) {
// shim away need for obsolete RTCIceCandidate/RTCSessionDescription.
['setLocalDescription', 'setRemoteDescription', 'addIceCandidate']
.forEach(function(method) {
const nativeMethod = window.RTCPeerConnection.prototype[method];
const methodObj = {[method]() {
arguments[0] = new ((method === 'addIceCandidate') ?
window.RTCIceCandidate :
window.RTCSessionDescription)(arguments[0]);
return nativeMethod.apply(this, arguments);
}};
window.RTCPeerConnection.prototype[method] = methodObj[method];
});
.forEach(function(method) {
const nativeMethod = window.RTCPeerConnection.prototype[method];
const methodObj = {[method]() {
arguments[0] = new ((method === 'addIceCandidate') ?
window.RTCIceCandidate :
window.RTCSessionDescription)(arguments[0]);
return nativeMethod.apply(this, arguments);
}};
window.RTCPeerConnection.prototype[method] = methodObj[method];
});
}

const modernStatsTypes = {
Expand Down Expand Up @@ -114,7 +114,7 @@ export function shimSenderGetStats(window) {
}
window.RTCRtpSender.prototype.getStats = function getStats() {
return this.track ? this._pc.getStats(this.track) :
Promise.resolve(new Map());
Promise.resolve(new Map());
};
}

Expand Down Expand Up @@ -266,12 +266,12 @@ export function shimCreateOffer(window) {
window.RTCPeerConnection.prototype.createOffer = function createOffer() {
if (this.setParametersPromises && this.setParametersPromises.length) {
return Promise.all(this.setParametersPromises)
.then(() => {
return origCreateOffer.apply(this, arguments);
})
.finally(() => {
this.setParametersPromises = [];
});
.then(() => {
return origCreateOffer.apply(this, arguments);
})
.finally(() => {
this.setParametersPromises = [];
});
}
return origCreateOffer.apply(this, arguments);
};
Expand All @@ -288,12 +288,12 @@ export function shimCreateAnswer(window) {
window.RTCPeerConnection.prototype.createAnswer = function createAnswer() {
if (this.setParametersPromises && this.setParametersPromises.length) {
return Promise.all(this.setParametersPromises)
.then(() => {
return origCreateAnswer.apply(this, arguments);
})
.finally(() => {
this.setParametersPromises = [];
});
.then(() => {
return origCreateAnswer.apply(this, arguments);
})
.finally(() => {
this.setParametersPromises = [];
});
}
return origCreateAnswer.apply(this, arguments);
};
Expand Down
4 changes: 2 additions & 2 deletions src/js/firefox/getusermedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function shimGetUserMedia(window, browserDetails) {
navigator.getUserMedia = function(constraints, onSuccess, onError) {
// Replace Firefox 44+'s deprecation warning with unprefixed version.
utils.deprecated('navigator.getUserMedia',
'navigator.mediaDevices.getUserMedia');
'navigator.mediaDevices.getUserMedia');
navigator.mediaDevices.getUserMedia(constraints).then(onSuccess, onError);
};

Expand All @@ -31,7 +31,7 @@ export function shimGetUserMedia(window, browserDetails) {
};

const nativeGetUserMedia = navigator.mediaDevices.getUserMedia.
bind(navigator.mediaDevices);
bind(navigator.mediaDevices);
navigator.mediaDevices.getUserMedia = function(c) {
if (typeof c === 'object' && typeof c.audio === 'object') {
c = JSON.parse(JSON.stringify(c));
Expand Down
5 changes: 2 additions & 3 deletions src/js/safari/safari_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function shimGetUserMedia(window) {
navigator.mediaDevices.getUserMedia) {
navigator.getUserMedia = function getUserMedia(constraints, cb, errcb) {
navigator.mediaDevices.getUserMedia(constraints)
.then(cb, errcb);
.then(cb, errcb);
}.bind(navigator);
}
}
Expand Down Expand Up @@ -244,8 +244,7 @@ export function shimRTCIceServerUrls(window) {
const newIceServers = [];
for (let i = 0; i < pcConfig.iceServers.length; i++) {
let server = pcConfig.iceServers[i];
if (!server.hasOwnProperty('urls') &&
server.hasOwnProperty('url')) {
if (server.urls === undefined && server.url) {
utils.deprecated('RTCIceServer.url', 'RTCIceServer.urls');
server = JSON.parse(JSON.stringify(server));
server.urls = server.url;
Expand Down
Loading

0 comments on commit c2de579

Please sign in to comment.