Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
add githooks postinstall step + update version deps + some more lint …
Browse files Browse the repository at this point in the history
…fixes
  • Loading branch information
KaptenJansson committed Jul 11, 2017
1 parent 4639d6a commit aef645d
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 94 deletions.
7 changes: 7 additions & 0 deletions .csslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"box-model": false,
"ids": false,
"known-properties": false,
"overqualified-elements": false,
"unique-headings": false
}
58 changes: 58 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"rules": {
"array-bracket-spacing": 2,
"block-spacing": [2, "never"],
"brace-style": [2, "1tbs", { "allowSingleLine": false }],
"camelcase": [2, {"properties": "always"}],
"curly": 2,
"default-case": 2,
"dot-notation": 2,
"eqeqeq": 2,
"indent": [
2,
2
],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"max-len": [2, 80, 2, {"ignoreUrls": true}],
"new-cap": 2,
"no-console": 0,
"no-else-return": 2,
"no-eval": 2,
"no-multi-spaces": 2,
"no-multiple-empty-lines": [2, {"max": 2}],
"no-shadow": 2,
"no-trailing-spaces": 2,
"no-unused-expressions": 2,
"no-unused-vars": [2, {"args": "none"}],
"object-curly-spacing": [2, "never"],
"padded-blocks": [2, "never"],
"quotes": [
2,
"single"
],
"semi": [
2,
"always"
],
"space-before-blocks": 2,
"space-before-function-paren": [2, "never"],
"spaced-comment": 2,
"valid-typeof": 2
},
"env": {
"es6": true,
"browser": true,
"node": false
},
"extends": ["eslint:recommended", "webrtc"],
"globals": {
"adapter": true,
"audioContext": true,
"browserSupportsIPHandlingPolicy": true,
"browserSupportsNonProxiedUdpBoolean": true,
"chrome": true,
"ga": true,
"getPolicyFromBooleans": true,
"trace": true,
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.DS_Store
.eslintcache
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist: trusty
language: node_js
cache:
- node_modules
node_js:
- 6

branches:
only:
- gh-pages

script:
- grunt
6 changes: 5 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ module.exports = function(grunt) {
},
target: ['src/**/*.js']
},
// Runs the npm test command which has access to the grunt path.
githooks: {
all: {
'pre-commit': 'csslint htmlhint eslint'
options: {
command: 'npm',
},
'pre-commit': 'test'
}
},
htmlhint: {
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
"url": "https://github.com/webrtc/test-pages.git"
},
"scripts": {
"test": "grunt"
"test": "grunt",
"postinstall": "grunt githooks"
},
"devDependencies": {
"eslint-config-webrtc": "^1.0.0",
"eslint-config-webrtc": ">=1.0.0",
"express": "^4.14.1",
"grunt": "^0.4.5",
"grunt": ">=0.4.5",
"grunt-cli": ">=0.1.9",
"grunt-contrib-csslint": ">=0.3.1",
"grunt-eslint": "^17.2.0",
"grunt-githooks": "^0.3.1",
"grunt-eslint": ">=17.2.0",
"grunt-githooks": ">=0.3.1",
"grunt-htmlhint": ">=0.9.12",
"pem": "^1.9.4"
"pem": ">=1.9.4"
}
}
8 changes: 4 additions & 4 deletions src/multiple-peerconnections/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function PeerConnection(id, cpuOveruseDetection) {
audio: true,
video: true
})
.then(onGetUserMediaSuccess)
.catch(logError);
.then(onGetUserMediaSuccess)
.catch(logError);
};

this.onGetUserMediaSuccess = function(stream) {
Expand Down Expand Up @@ -82,7 +82,7 @@ function PeerConnection(id, cpuOveruseDetection) {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
})
.then(onCreateOfferSuccess, logError);
.then(onCreateOfferSuccess, logError);
};

this.onCreateOfferSuccess = function(desc) {
Expand All @@ -91,7 +91,7 @@ function PeerConnection(id, cpuOveruseDetection) {

var onCreateAnswerSuccess = this.onCreateAnswerSuccess.bind(this);
this.remoteConnection.createAnswer()
.then(onCreateAnswerSuccess, logError);
.then(onCreateAnswerSuccess, logError);
};

this.onCreateAnswerSuccess = function(desc) {
Expand Down
33 changes: 16 additions & 17 deletions src/pause-play/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class FeedTable {
}

class PeerConnection {

constructor(id, element, constraints) {
this.id = id;
this.localConnection = null;
Expand All @@ -48,8 +47,8 @@ class PeerConnection {
start() {
const onGetUserMediaSuccess = this.onGetUserMediaSuccess.bind(this);
return navigator.mediaDevices
.getUserMedia(this.constraints)
.then(onGetUserMediaSuccess);
.getUserMedia(this.constraints)
.then(onGetUserMediaSuccess);
}

onGetUserMediaSuccess(stream) {
Expand All @@ -69,8 +68,8 @@ class PeerConnection {

var onCreateOfferSuccess = this.onCreateOfferSuccess.bind(this);
this.localConnection
.createOffer({offerToReceiveAudio: 1, offerToReceiveVideo: 1})
.then(onCreateOfferSuccess, logError);
.createOffer({offerToReceiveAudio: 1, offerToReceiveVideo: 1})
.then(onCreateOfferSuccess, logError);
}

onCreateOfferSuccess(desc) {
Expand Down Expand Up @@ -120,20 +119,20 @@ class TestRunner {
}
this.elements.push(element);
this.peerConnections.push(
new PeerConnection(++this.numConnections, element, constraints));
new PeerConnection(++this.numConnections, element, constraints));
}

startTest() {
this.startTime = Date.now();
let promises = testRunner.peerConnections.map((conn) => conn.start());
Promise.all(promises)
.then(() => {
this.startTime = Date.now();
this.pauseAndPlayLoop();
})
.catch((e) => {
throw e;
});
.then(() => {
this.startTime = Date.now();
this.pauseAndPlayLoop();
})
.catch((e) => {
throw e;
});
}

pauseAndPlayLoop() {
Expand All @@ -150,7 +149,7 @@ class TestRunner {
$('status').textContent = status;
if (status !== 'ok-done') {
setTimeout(
() => this.pauseAndPlayLoop(), this.pausePlayIterationDelayMillis);
() => this.pauseAndPlayLoop(), this.pausePlayIterationDelayMillis);
}
}

Expand All @@ -174,10 +173,10 @@ class TestRunner {
let testRunner;

function startTest(
runtimeSeconds, numPeerConnections, pausePlayIterationDelayMillis,
elementType) {
runtimeSeconds, numPeerConnections, pausePlayIterationDelayMillis,
elementType) {
testRunner = new TestRunner(
runtimeSeconds, pausePlayIterationDelayMillis);
runtimeSeconds, pausePlayIterationDelayMillis);
for (let i = 0; i < numPeerConnections; i++) {
testRunner.addPeerConnection(elementType);
}
Expand Down
2 changes: 1 addition & 1 deletion src/peer2peer-video/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function start() {
startButton.onclick = hangup;
startButton.className = 'red';
startButton.innerHTML = 'Stop test';
if (localVideo.readyState >= 3) { // HAVE_FUTURE_DATA
if (localVideo.readyState >= 3) { // HAVE_FUTURE_DATA
// Video is already ready to play, call maybeCreateStream in case oncanplay
// fired before we registered the event handler.
maybeCreateStream();
Expand Down
20 changes: 10 additions & 10 deletions src/peer2peer/extension/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ function requestScreenSharing(port, msg) {
// - 'streamId' String that can be passed to getUserMedia() API
desktopMediaRequestId =
chrome.desktopCapture.chooseDesktopMedia(dataSources, port.sender.tab,
function(streamId, options) {
if (streamId) {
msg.type = 'SS_DIALOG_SUCCESS';
msg.streamId = streamId;
msg.requestAudio = options && options.canRequestAudioTrack;
} else {
msg.type = 'SS_DIALOG_CANCEL';
}
port.postMessage(msg);
});
function(streamId, options) {
if (streamId) {
msg.type = 'SS_DIALOG_SUCCESS';
msg.streamId = streamId;
msg.requestAudio = options && options.canRequestAudioTrack;
} else {
msg.type = 'SS_DIALOG_CANCEL';
}
port.postMessage(msg);
});
}

function cancelScreenSharing() {
Expand Down
Loading

0 comments on commit aef645d

Please sign in to comment.