Skip to content

Commit

Permalink
Use RTCPeerConnection instead of webkitRTCPeerConnection
Browse files Browse the repository at this point in the history
Cases where the second argument (constraints) is used are left alone, as
a reminder that this isn't standarized behavior.

BUG=658423

Review-Url: https://codereview.chromium.org/2446173002
Cr-Commit-Position: refs/heads/master@{#427662}
  • Loading branch information
foolip authored and Commit bot committed Oct 26, 2016
1 parent 162f133 commit 04209ec
Show file tree
Hide file tree
Showing 36 changed files with 174 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ function gotStream(stream) {
video.src = URL.createObjectURL(stream);
stream.onended = function() { console.log('Ended'); };

var servers = null;
pc1 = new webkitRTCPeerConnection(servers);
pc1 = new RTCPeerConnection();
pc1.onicecandidate = function(event) {
onIceCandidate(pc1, event);
};
pc2 = new webkitRTCPeerConnection(servers);
pc2 = new RTCPeerConnection();
pc2.onicecandidate = function(event) {
onIceCandidate(pc2, event);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ chrome.test.runTests([
receiveStream = captureStream;
waitForExpectedColors(colorDeviation);
} else if (transportMethod == 'webrtc') {
var sender = new webkitRTCPeerConnection(null);
var receiver = new webkitRTCPeerConnection(null);
var sender = new RTCPeerConnection();
var receiver = new RTCPeerConnection();
sender.onicecandidate = function (event) {
if (event.candidate) {
receiver.addIceCandidate(new RTCIceCandidate(event.candidate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function TestStream(stream) {
function testThroughWebRTC(stream) {
capture_stream = stream;
console.log("Testing through webrtc.");
var sender = new webkitRTCPeerConnection(null);
var receiver = new webkitRTCPeerConnection(null);
var sender = new RTCPeerConnection();
var receiver = new RTCPeerConnection();
sender.onicecandidate = function (event) {
if (event.candidate) {
receiver.addIceCandidate(new RTCIceCandidate(event.candidate));
Expand Down
4 changes: 2 additions & 2 deletions content/test/data/media/datachannel_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Tests that an RTCDataChannel with event handlers is not garbage-collected
// prematurely.
function testDataChannelGC() {
var pc1 = new webkitRTCPeerConnection(null);
var pc2 = new webkitRTCPeerConnection(null);
var pc1 = new RTCPeerConnection();
var pc2 = new RTCPeerConnection();

var iceCandidateHandler = function(rpc) {
return function(e) {
Expand Down
4 changes: 2 additions & 2 deletions content/test/data/media/mediarecorder_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
return new Promise(function(resolve, reject) {
var localStream = stream;
var remoteStream = null;
var localPeerConnection = new webkitRTCPeerConnection(null);
var remotePeerConnection = new webkitRTCPeerConnection(null);
var localPeerConnection = new RTCPeerConnection();
var remotePeerConnection = new RTCPeerConnection();

function createAnswer(description) {
remotePeerConnection.createAnswer(function(description) {
Expand Down
6 changes: 3 additions & 3 deletions content/test/data/media/peerconnection-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
}

function callWithDevicePermissionGranted() {
var pc = new webkitRTCPeerConnection(null, null);
var pc = new RTCPeerConnection();
gatherIceCandidates(pc, function(candidates) {
var hasLoopbackCandidate = false;
assertEquals(candidates.length > 0, true);
Expand All @@ -534,15 +534,15 @@
}

function callWithNoCandidateExpected() {
var pc = new webkitRTCPeerConnection({iceServers:[]}, null);
var pc = new RTCPeerConnection();
gatherIceCandidates(pc, function(candidates) {
assertEquals(candidates.length, 0);
reportTestSuccess();
});
}

function callAndExpectNonLoopbackCandidates() {
var pc = new webkitRTCPeerConnection(null, null);
var pc = new RTCPeerConnection();
gatherIceCandidates(pc, function(candidates) {
var hasCandidate = false;
assertEquals(candidates.length > 0, true);
Expand Down
1 change: 0 additions & 1 deletion ppapi/examples/video_effects/video_effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
width="320" height="240"/>

<script>
var RTCPeerConnection = webkitRTCPeerConnection;
var getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
var attachMediaStream = function(element, stream) {
element.src = URL.createObjectURL(stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Tests the JSEP PeerConnection related constructors.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS typeof webkitRTCPeerConnection === 'function' is true
PASS typeof RTCPeerConnection === 'function' is true
PASS typeof RTCSessionDescription === 'function' is true
PASS typeof RTCIceCandidate === 'function' is true
PASS webkitRTCPeerConnection() threw exception TypeError: Failed to construct 'RTCPeerConnection': Please use the 'new' operator, this DOM object constructor cannot be called as a function..
PASS RTCPeerConnection() threw exception TypeError: Failed to construct 'RTCPeerConnection': Please use the 'new' operator, this DOM object constructor cannot be called as a function..
PASS RTCSessionDescription() threw exception TypeError: Failed to construct 'RTCSessionDescription': Please use the 'new' operator, this DOM object constructor cannot be called as a function..
PASS RTCIceCandidate() threw exception TypeError: Failed to construct 'RTCIceCandidate': Please use the 'new' operator, this DOM object constructor cannot be called as a function..
PASS new webkitRTCPeerConnection({iceServers:[{url:'stun://foobar.com:12345'}]}, null); did not throw exception.
PASS new RTCPeerConnection({iceServers:[{url:'stun://foobar.com:12345'}]}, null); did not throw exception.
PASS new RTCSessionDescription({type:'offer',sdp:'foobar'}); did not throw exception.
PASS new RTCIceCandidate({candidate:'foo'}); did not throw exception.
PASS successfullyParsed is true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<script>
description("Tests the JSEP PeerConnection related constructors.");

shouldBeTrue("typeof webkitRTCPeerConnection === 'function'");
shouldBeTrue("typeof RTCPeerConnection === 'function'");
shouldBeTrue("typeof RTCSessionDescription === 'function'");
shouldBeTrue("typeof RTCIceCandidate === 'function'");

shouldThrow("webkitRTCPeerConnection()");
shouldThrow("RTCPeerConnection()");
shouldThrow("RTCSessionDescription()");
shouldThrow("RTCIceCandidate()");

shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'stun://foobar.com:12345'}]}, null);");
shouldNotThrow("new RTCPeerConnection({iceServers:[{url:'stun://foobar.com:12345'}]}, null);");
shouldNotThrow("new RTCSessionDescription({type:'offer',sdp:'foobar'});");
shouldNotThrow("new RTCIceCandidate({candidate:'foo'});");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
navigator.webkitGetUserMedia(options, (stream2) => {
assert_false(stream1.id === stream2.id);

pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();

pc.onnegotiationneeded = (event) => {
assert_equals(pc.getStreamById(stream1.id), stream1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// In all other cases, createAnswer() fails in the test runner.

defaultError = new DOMException('TEST_ERROR', 'OperationError')
pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();

// Test that createAnswer with voiceActivityDetection succeeds.
// voiceActivityDetection is true by default.
Expand Down Expand Up @@ -40,7 +40,7 @@
}, 'createAnswer(1)' );

// Test closed connection
closedPC = new webkitRTCPeerConnection(null);
closedPC = new RTCPeerConnection();
closedPC.close();
promise_test(function() {
var invalidStateError = new DOMException('', 'InvalidStateError');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

function testExecutionOrderClosedConnection()
{
var localPeerConnection = new webkitRTCPeerConnection(null, null);
var localPeerConnection = new RTCPeerConnection();
localPeerConnection.close();
var counter = 0;
window.events = [];
Expand All @@ -54,7 +54,7 @@
}

shouldNotThrow('testExecutionOrderClosedConnection()');
pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();
pc.createOffer(unexpectedCallback, createOfferWithoutDescriptionFailed);

window.jsTestIsAsync = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// runner.

defaultError = new DOMException('TEST_ERROR', 'OperationError')
pc = new webkitRTCPeerConnection(null);
pc = new RTCPeerConnection();

// Test that creating an offer with voiceActivityDetection, iceRestart,
// offerToReceiveAudio and offerToReceiveVideo returns an accepted promise.
Expand Down Expand Up @@ -69,7 +69,7 @@
}, 'createOffer(1)' );

// Test closed connection
closedPC = new webkitRTCPeerConnection(null);
closedPC = new RTCPeerConnection();
closedPC.close();
promise_test(function() {
var invalidStateError = new DOMException('', 'InvalidStateError');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

function testExecutionOrderClosedConnection()
{
var localPeerConnection = new webkitRTCPeerConnection(null, null);
var localPeerConnection = new RTCPeerConnection();
localPeerConnection.close();
var counter = 0;
window.events = [];
Expand All @@ -112,7 +112,7 @@
}

shouldNotThrow('testExecutionOrderClosedConnection()');
pc = new webkitRTCPeerConnection(null);
pc = new RTCPeerConnection();
shouldNotThrow('pc.createOffer(createOfferSucceeded1, unexpectedCallback, {voiceActivityDetection:true, iceRestart:true, offerToReceiveAudio:1, offerToReceiveVideo:1});');

window.jsTestIsAsync = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}
}

pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();
shouldNotThrow('dc = pc.createDataChannel("label1");');
shouldBe("dc.reliable", "true");
shouldNotThrow('dc = pc.createDataChannel("label2", {});');
Expand All @@ -102,7 +102,7 @@
shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmitTime:0});');
shouldBe("dc.reliable", "false");

pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();
pc.oniceconnectionstatechange = pc_onicechange;
pc.ondatachannel = pc_ondatachannel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
shouldBe('stream.getAudioTracks().length', '1');
shouldBe('stream.getVideoTracks().length', '0');

pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();
pc.oniceconnectionstatechange = pc_onicechange;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
testPassed('gotStream was called.');
stream = s;

pc = new webkitRTCPeerConnection(null, null);
pc = new RTCPeerConnection();
pc.onnegotiationneeded = onNegotiationNeeded;

pc.addStream(stream);
Expand Down
Loading

0 comments on commit 04209ec

Please sign in to comment.