Socket
Socket
Sign inDemoInstall

rtcpeerconnection

Package Overview
Dependencies
Maintainers
5
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtcpeerconnection - npm Package Compare versions

Comparing version 3.1.3 to 3.1.4

test_getstats.js

7

package.json
{
"name": "rtcpeerconnection",
"version": "3.1.3",
"version": "3.1.4",
"description": "A tiny browser module that normalizes and simplifies the API for WebRTC peer connections.",

@@ -24,3 +24,3 @@ "main": "rtcpeerconnection.js",

"wildemitter": "1.x",
"webrtc-adapter-test": "^0.1.4"
"webrtc-adapter-test": "^0.2.1"
},

@@ -34,2 +34,5 @@ "devDependencies": {

},
"scripts": {
"test-travis": "test/run-tests"
},
"testling": {

@@ -36,0 +39,0 @@ "files": "test/*.js",

/* testing basic session establishment */
var test = require('tape');
var PeerConnection = require('../rtcpeerconnection');
var adapter = require('webrtc-adapter-test'); // jshint ignore:line
// deactivated until firefox is fixed
test('answer bandwidth restriction', function (t) {
var pc1, pc2;
var ended = false;
ended = true;
pc1 = new PeerConnection({useJingle:true});
pc2 = new PeerConnection({useJingle:true}, {optional:[{andyetRestrictBandwidth:512}]});
t.end();
/*
pc1.on('ice', function (candidate) {

@@ -19,5 +25,9 @@ pc2.processIce(candidate);

//console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState == 'connected') {
t.pass('P2P connection established');
t.end();
if (pc1.iceConnectionState === 'connected' ||
pc1.iceConnectionState === 'completed') {
if (!ended) {
t.pass('P2P connection established');
ended = true;
t.end();
}
}

@@ -30,35 +40,41 @@ // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414

pc1.offer(function (err, offer) {
if (err) {
t.fail('failed to create offer');
return;
}
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
// constraint assume audio+video
navigator.mediaDevices.getUserMedia({audio: true, video: true, fake: true})
.then(function (stream) {
pc1.addStream(stream);
pc1.offer(function (err, offer) {
if (err) {
// handle error
t.fail('error handling offer');
t.fail('failed to create offer');
return;
}
t.pass('handled offer');
// check that the remote description contains the bandwidth flag
if (!pc2.remoteDescription.contents[1].description.bandwidth) {
t.fail('no bandwidth');
return;
}
t.pass('mangled b=AS');
pc2.answer(function (err, answer) {
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
if (err) {
t.fail('error handling answer');
// handle error
t.fail('error handling offer');
return;
}
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
t.pass('handled offer');
// check that the remote description contains the bandwidth flag
console.log(pc2.remoteDescription.contents);
if (!pc2.remoteDescription.contents[1].description.bandwidth) {
t.fail('no bandwidth');
return;
}
t.pass('mangled b=AS');
pc2.answer(function (err, answer) {
if (err) {
t.fail('failed to handle answer');
t.fail('error handling answer');
return;
}
t.pass('handled answer');
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
if (err) {
t.fail('failed to handle answer');
return;
}
t.pass('handled answer');
});
});

@@ -68,2 +84,3 @@ });

});
*/
});
/* testing basic session establishment */
var test = require('tape');
var PeerConnection = require('../rtcpeerconnection');
var adapter = require('webrtc-adapter-test'); // jshint ignore:line
test('basic connection establishment', function (t) {
var pc1, pc2;
var ended = false;
pc1 = new PeerConnection();

@@ -11,5 +14,7 @@ pc2 = new PeerConnection();

pc1.on('ice', function (candidate) {
//console.log('pc1 candidate', candidate);
pc2.processIce(candidate);
});
pc2.on('ice', function (candidate) {
//console.log('pc2 candidate', candidate);
pc1.processIce(candidate);

@@ -20,5 +25,9 @@ });

//console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState == 'connected') {
t.pass('P2P connection established');
t.end();
if (pc1.iceConnectionState === 'connected' ||
pc1.iceConnectionState === 'completed') {
if (!ended) {
t.pass('P2P connection established');
ended = true;
t.end();
}
}

@@ -31,31 +40,38 @@ // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414

pc1.offer(function (err, offer) {
if (err) {
t.fail('failed to create offer');
return;
}
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
navigator.mediaDevices.getUserMedia({video: true, fake: true})
.then(function (stream) {
pc1.addStream(stream);
pc1.offer(function (err, offer) {
if (err) {
// handle error
t.fail('error handling offer');
t.fail('failed to create offer');
return;
}
t.pass('handled offer');
pc2.answer(function (err, answer) {
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
if (err) {
t.fail('error handling answer');
// handle error
t.fail('error handling offer');
return;
}
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
t.pass('handled offer');
pc2.answer(function (err, answer) {
if (err) {
t.fail('failed to handle answer');
t.fail('error handling answer');
return;
}
t.pass('handled answer');
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
if (err) {
t.fail('failed to handle answer');
return;
}
t.pass('handled answer');
});
});
});
});
})
.catch(function (err) {
t.fail(err);
});

@@ -66,2 +82,3 @@ });

var pc1, pc2;
var ended = false;
pc1 = new PeerConnection({useJingle: true});

@@ -79,5 +96,9 @@ pc2 = new PeerConnection({useJingle: true});

//console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState == 'connected') {
t.pass('P2P connection established');
t.end();
if (pc1.iceConnectionState === 'connected' ||
pc1.iceConnectionState === 'completed') {
if (!ended) {
t.pass('P2P connection established');
ended = true;
t.end();
}
}

@@ -90,28 +111,32 @@ // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414

pc1.offer(function (err, offer) {
if (err) {
t.fail('failed to create offer');
return;
}
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
navigator.mediaDevices.getUserMedia({video: true, fake: true})
.then(function (stream) {
pc1.addStream(stream);
pc1.offer(function (err, offer) {
if (err) {
// handle error
t.fail('error handling offer');
t.fail('failed to create offer');
return;
}
t.pass('handled offer');
pc2.answer(function (err, answer) {
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
if (err) {
t.fail('error handling answer');
// handle error
t.fail('error handling offer');
return;
}
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
t.pass('handled offer');
pc2.answer(function (err, answer) {
if (err) {
t.fail('failed to handle answer');
t.fail('error handling answer');
return;
}
t.pass('handled answer');
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
if (err) {
t.fail('failed to handle answer');
return;
}
t.pass('handled answer');
});
});

@@ -125,2 +150,3 @@ });

var pc1, pc2;
var ended = false;
pc1 = new PeerConnection({useJingle: true});

@@ -138,5 +164,9 @@ pc2 = new PeerConnection({useJingle: true});

//console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState == 'connected') {
t.pass('P2P connection established');
t.end();
if (pc1.iceConnectionState === 'connected' ||
pc1.iceConnectionState === 'completed') {
if (!ended) {
t.pass('P2P connection established');
ended = true;
t.end();
}
}

@@ -149,35 +179,39 @@ // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414

pc1.offer(function (err, offer) {
if (err) {
t.fail('failed to create offer');
return;
}
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
navigator.mediaDevices.getUserMedia({video: true, fake: true})
.then(function (stream) {
pc1.addStream(stream);
pc1.offer(function (err, offer) {
if (err) {
// handle error
t.fail('error handling offer');
t.fail('failed to create offer');
return;
}
t.pass('handled offer');
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
if (err) {
// handle error
t.fail('error handling offer');
return;
}
t.pass('handled offer');
window.setTimeout(function () {
pc2.answer(function (err, answer) {
if (err) {
// handle error
t.fail('error handling answer');
return;
}
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
window.setTimeout(function () {
pc2.answer(function (err, answer) {
if (err) {
t.fail('failed to handle answer');
// handle error
t.fail('error handling answer');
return;
}
t.pass('handled answer');
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
if (err) {
t.fail('failed to handle answer');
return;
}
t.pass('handled answer');
});
});
});
}, 5000);
}, 5000);
});
});
});
});
/* testing basic session establishment */
var test = require('tape');
var PeerConnection = require('../rtcpeerconnection');
var adapter = require('webrtc-adapter-test'); // jshint ignore:line
test('batching trickle ice candidates', function (t) {
var pc1, pc2;
var ended = false;
pc1 = new PeerConnection({useJingle: true});

@@ -25,5 +27,9 @@ pc2 = new PeerConnection({useJingle:true}, {

//console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState == 'connected') {
t.pass('P2P connection established');
t.end();
if (pc1.iceConnectionState === 'connected' ||
pc1.iceConnectionState === 'completed') {
if (!ended) {
t.pass('P2P connection established');
ended = true;
t.end();
}
}

@@ -36,28 +42,32 @@ // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414

pc1.offer(function (err, offer) {
if (err) {
t.fail('failed to create offer');
return;
}
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
navigator.mediaDevices.getUserMedia({video: true, fake: true})
.then(function (stream) {
pc1.addStream(stream);
pc1.offer(function (err, offer) {
if (err) {
// handle error
t.fail('error handling offer');
t.fail('failed to create offer');
return;
}
t.pass('handled offer');
pc2.answer(function (err, answer) {
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
if (err) {
t.fail('error handling answer');
// handle error
t.fail('error handling offer');
return;
}
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
t.pass('handled offer');
pc2.answer(function (err, answer) {
if (err) {
t.fail('failed to handle answer');
t.fail('error handling answer');
return;
}
t.pass('handled answer');
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
if (err) {
t.fail('failed to handle answer');
return;
}
t.pass('handled answer');
});
});

@@ -64,0 +74,0 @@ });

/* testing basic session establishment */
var test = require('tape');
var PeerConnection = require('../rtcpeerconnection');
var adapter = require('webrtc-adapter-test'); // jshint ignore:line
test('firefox workaround', function (t) {
var pc1, pc2;
var ended = false;
pc1 = new PeerConnection(null, {

@@ -30,6 +32,10 @@ optional:[

pc1.on('iceConnectionStateChange', function () {
console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState == 'connected') {
t.pass('P2P connection established');
t.end();
//console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);
if (pc1.iceConnectionState === 'connected' ||
pc1.iceConnectionState === 'completed') {
if (!ended) {
t.pass('P2P connection established');
ended = true;
t.end();
}
}

@@ -39,31 +45,35 @@ // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414

pc2.on('iceConnectionStateChange', function () {
console.log('pc2 iceConnectionStateChange', pc2.iceConnectionState);
//console.log('pc2 iceConnectionStateChange', pc2.iceConnectionState);
});
pc1.offer(function (err, offer) {
if (err) {
t.fail('failed to create offer');
return;
}
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
navigator.mediaDevices.getUserMedia({video: true, fake: true})
.then(function (stream) {
pc1.addStream(stream);
pc1.offer(function (err, offer) {
if (err) {
// handle error
t.fail('error handling offer');
t.fail('failed to create offer');
return;
}
t.pass('handled offer');
pc2.answer(function (err, answer) {
t.pass('created offer');
pc2.handleOffer(offer, function (err) {
if (err) {
t.fail('error handling answer');
// handle error
t.fail('error handling offer');
return;
}
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
t.pass('handled offer');
pc2.answer(function (err, answer) {
if (err) {
t.fail('failed to handle answer');
t.fail('error handling answer');
return;
}
t.pass('handled answer');
t.pass('created answer');
pc1.handleAnswer(answer, function (err) {
if (err) {
t.fail('failed to handle answer');
return;
}
t.pass('handled answer');
});
});

@@ -70,0 +80,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc