mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 837458 - Cleanup PC Test Framework to Allow for Better Maintainability and Reusability for Future Tests. r=ekr, r=jsmith
This commit is contained in:
parent
f0f7e9cca3
commit
2a2d754bb6
@ -9,13 +9,110 @@ var Cr = SpecialPowers.Cr;
|
||||
// Specifies whether we are using fake streams to run this automation
|
||||
var FAKE_ENABLED = true;
|
||||
|
||||
|
||||
/**
|
||||
* Create the necessary HTML elements for head and body as used by Mochitests
|
||||
*
|
||||
* @param {object} meta
|
||||
* Meta information of the test
|
||||
* @param {string} meta.title
|
||||
* Description of the test
|
||||
* @param {string} [meta.bug]
|
||||
* Bug the test was created for
|
||||
* @param {boolean} [meta.visible=false]
|
||||
* Visibility of the media elements
|
||||
*/
|
||||
function createHTML(meta) {
|
||||
var test = document.getElementById('test');
|
||||
|
||||
// Create the head content
|
||||
var elem = document.createElement('meta');
|
||||
elem.setAttribute('charset', 'utf-8');
|
||||
document.head.appendChild(elem);
|
||||
|
||||
var title = document.createElement('title');
|
||||
title.textContent = meta.title;
|
||||
document.head.appendChild(title);
|
||||
|
||||
// Create the body content
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('target', '_blank');
|
||||
|
||||
if (meta.bug) {
|
||||
anchor.setAttribute('href', 'https://bugzilla.mozilla.org/show_bug.cgi?id=' + meta.bug);
|
||||
}
|
||||
|
||||
anchor.textContent = meta.title;
|
||||
document.body.insertBefore(anchor, test);
|
||||
|
||||
var display = document.createElement('p');
|
||||
display.setAttribute('id', 'display');
|
||||
document.body.insertBefore(display, test);
|
||||
|
||||
var content = document.createElement('div');
|
||||
content.setAttribute('id', 'content');
|
||||
content.style.display = meta.visible ? 'block' : "none";
|
||||
document.body.appendChild(content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the HTML element if it doesn't exist yet and attach
|
||||
* it to the content node.
|
||||
*
|
||||
* @param {string} type
|
||||
* Type of media element to create ('audio' or 'video')
|
||||
* @param {string} label
|
||||
* Description to use for the element
|
||||
* @return {HTMLMediaElement} The created HTML media element
|
||||
*/
|
||||
function createMediaElement(type, label) {
|
||||
var id = label + '_' + type;
|
||||
var element = document.getElementById(id);
|
||||
|
||||
// Sanity check that we haven't created the element already
|
||||
if (element)
|
||||
return element;
|
||||
|
||||
element = document.createElement(type === 'audio' ? 'audio' : 'video');
|
||||
element.setAttribute('id', id);
|
||||
element.setAttribute('height', 100);
|
||||
element.setAttribute('width', 150);
|
||||
element.setAttribute('controls', 'controls');
|
||||
document.getElementById('content').appendChild(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper function for mozGetUserMedia to allow a singular area of control
|
||||
* for determining whether we run this with fake devices or not.
|
||||
*
|
||||
* @param {Dictionary} constraints
|
||||
* The constraints for this mozGetUserMedia callback
|
||||
* @param {Function} onSuccess
|
||||
* The success callback if the stream is successfully retrieved
|
||||
* @param {Function} onError
|
||||
* The error callback if the stream fails to be retrieved
|
||||
*/
|
||||
function getUserMedia(constraints, onSuccess, onError) {
|
||||
constraints["fake"] = FAKE_ENABLED;
|
||||
|
||||
info("Call getUserMedia for " + JSON.stringify(constraints));
|
||||
navigator.mozGetUserMedia(constraints, onSuccess, onError);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup any Mochitest for WebRTC by enabling the preference for
|
||||
* peer connections. As by bug 797979 it will also enable mozGetUserMedia().
|
||||
* peer connections. As by bug 797979 it will also enable mozGetUserMedia()
|
||||
* and disable the mozGetUserMedia() permission checking.
|
||||
*
|
||||
* @param {Function} aCallback Test method to execute after initialization
|
||||
* @param {Boolean} desktopSupportedOnly specifies if the test currently
|
||||
* is known to work on desktop only
|
||||
* @param {Function} aCallback
|
||||
* Test method to execute after initialization
|
||||
* @param {Boolean} desktopSupportedOnly
|
||||
* Specifies if the test currently is known to work on desktop only
|
||||
*/
|
||||
function runTest(aCallback, desktopSupportedOnly) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
@ -28,8 +125,9 @@ function runTest(aCallback, desktopSupportedOnly) {
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
SpecialPowers.pushPrefEnv({'set': [
|
||||
['media.peerconnection.enabled', true],
|
||||
['media.navigator.permission.denied', true]]}, function () {
|
||||
['media.peerconnection.enabled', true],
|
||||
['media.navigator.permission.denied', true]]
|
||||
}, function () {
|
||||
try {
|
||||
aCallback();
|
||||
}
|
||||
@ -40,27 +138,13 @@ function runTest(aCallback, desktopSupportedOnly) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for mozGetUserMedia to allow a singular area of control
|
||||
* for determining whether we run this with fake devices or not.
|
||||
*
|
||||
* @param {Dictionary} constraints the constraints for this mozGetUserMedia
|
||||
* callback
|
||||
* @param {Function} onSuccess the success callback if the stream is
|
||||
* successfully retrieved
|
||||
* @param {Function} onError the error callback if the stream fails to be
|
||||
* retrieved
|
||||
*/
|
||||
function getUserMedia(constraints, onSuccess, onError) {
|
||||
constraints["fake"] = FAKE_ENABLED;
|
||||
navigator.mozGetUserMedia(constraints, onSuccess, onError);
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback function fired only under unexpected circumstances while
|
||||
* running the tests. Kills off the test as well gracefully.
|
||||
*
|
||||
* @param {object} aObj The object fired back from the callback
|
||||
* @param {object} aObj
|
||||
* The object fired back from the callback
|
||||
*/
|
||||
function unexpectedCallbackAndFinish(aObj) {
|
||||
ok(false, "Unexpected error callback with " + aObj);
|
||||
|
@ -3,75 +3,607 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
var PeerConnection = {
|
||||
pc1_offer : null,
|
||||
pc2_answer : null,
|
||||
/**
|
||||
* This class mimics a state machine and handles a list of commands by
|
||||
* executing them synchronously.
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} framework
|
||||
* A back reference to the framework which makes use of the class. It's
|
||||
* getting passed in as parameter to each command callback.
|
||||
*/
|
||||
function CommandChain(framework) {
|
||||
this._framework = framework;
|
||||
|
||||
this._commands = [ ];
|
||||
this._current = 0;
|
||||
|
||||
this.onFinished = null;
|
||||
}
|
||||
|
||||
CommandChain.prototype = {
|
||||
|
||||
/**
|
||||
* Establishes the peer connection between two clients
|
||||
* Returns the index of the current command of the chain
|
||||
*
|
||||
* @param {object) aPCLocal Local client
|
||||
* @param {object} aPCRemote Remote client
|
||||
* @param {function} aSuccessCallback Method to call when the connection has been established
|
||||
* @returns {number} Index of the current command
|
||||
*/
|
||||
handShake: function PC_handShake(aPCLocal, aPCRemote, aSuccessCallback) {
|
||||
|
||||
function onCreateOfferSuccess(aOffer) {
|
||||
pc1_offer = aOffer;
|
||||
info("Calling setLocalDescription on local peer connection");
|
||||
aPCLocal.setLocalDescription(aOffer, onSetLocalDescriptionSuccess1,
|
||||
unexpectedCallbackAndFinish);
|
||||
}
|
||||
|
||||
function onSetLocalDescriptionSuccess1() {
|
||||
info("Calling setRemoteDescription on remote peer connection");
|
||||
aPCRemote.setRemoteDescription(pc1_offer, onSetRemoteDescriptionSuccess1,
|
||||
unexpectedCallbackAndFinish);
|
||||
}
|
||||
|
||||
function onSetRemoteDescriptionSuccess1() {
|
||||
info("Calling createAnswer on remote peer connection");
|
||||
aPCRemote.createAnswer(onCreateAnswerSuccess, unexpectedCallbackAndFinish);
|
||||
}
|
||||
|
||||
function onCreateAnswerSuccess(aAnswer) {
|
||||
pc2_answer = aAnswer;
|
||||
info("Calling setLocalDescription on remote peer connection");
|
||||
aPCRemote.setLocalDescription(aAnswer, onSetLocalDescriptionSuccess2,
|
||||
unexpectedCallbackAndFinish);
|
||||
}
|
||||
|
||||
function onSetLocalDescriptionSuccess2() {
|
||||
info("Calling setRemoteDescription on local peer connection");
|
||||
aPCLocal.setRemoteDescription(pc2_answer, onSetRemoteDescriptionSuccess2,
|
||||
unexpectedCallbackAndFinish);
|
||||
}
|
||||
|
||||
function onSetRemoteDescriptionSuccess2() {
|
||||
aSuccessCallback();
|
||||
}
|
||||
|
||||
info("Calling createOffer on local peer connection");
|
||||
aPCLocal.createOffer(onCreateOfferSuccess, unexpectedCallbackAndFinish);
|
||||
get current() {
|
||||
return this._current;
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the given media stream in the list of available streams.
|
||||
* Checks if the chain has already processed all the commands
|
||||
*
|
||||
* This function is necessary because localStreams and remoteStreams don't have
|
||||
* an indexOf method.
|
||||
*
|
||||
* @param {object} aMediaStreamList List of available media streams
|
||||
* @param {object} aMediaStream Media stream to check for
|
||||
* @return {number} Index in the media stream list
|
||||
* @returns {boolean} True, if all commands have been processed
|
||||
*/
|
||||
findStream: function PC_findStream(aMediaStreamList, aMediaStream) {
|
||||
for (var index = 0; index < aMediaStreamList.length; index++) {
|
||||
if (aMediaStreamList[index] === aMediaStream) {
|
||||
return index;
|
||||
get finished() {
|
||||
return this._current === this._commands.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the assigned commands of the chain.
|
||||
*
|
||||
* @returns {Array[]} Commands of the chain
|
||||
*/
|
||||
get commands() {
|
||||
return this._commands;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets new commands for the chain. All existing commands will be replaced.
|
||||
*
|
||||
* @param {Array[]} commands
|
||||
* List of commands
|
||||
*/
|
||||
set commands(commands) {
|
||||
this._commands = commands;
|
||||
},
|
||||
|
||||
/**
|
||||
* Execute the next command in the chain.
|
||||
*/
|
||||
executeNext : function () {
|
||||
var self = this;
|
||||
|
||||
function _executeNext() {
|
||||
if (!self.finished) {
|
||||
var step = self._commands[self._current];
|
||||
self._current++;
|
||||
|
||||
info("Run step: " + step[0]); // Label
|
||||
step[1](self._framework); // Execute step
|
||||
}
|
||||
else if (typeof(self.onFinished) === 'function') {
|
||||
self.onFinished();
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
// To prevent building up the stack we have to execute the next
|
||||
// step asynchronously
|
||||
window.setTimeout(_executeNext, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add new commands to the end of the chain
|
||||
*
|
||||
* @param {Array[]} commands
|
||||
* List of commands
|
||||
*/
|
||||
append: function (commands) {
|
||||
this._commands = this._commands.concat(commands);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the index of the specified command in the chain.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @returns {number} Index of the command
|
||||
*/
|
||||
indexOf: function (id) {
|
||||
for (var i = 0; i < this._commands.length; i++) {
|
||||
if (this._commands[i][0] === id) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Inserts the new commands after the specified command.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @param {Array[]} commands
|
||||
* List of commands
|
||||
*/
|
||||
insertAfter: function (id, commands) {
|
||||
var index = this.indexOf(id);
|
||||
|
||||
if (index > -1) {
|
||||
var tail = this.removeAfter(id);
|
||||
|
||||
this.append(commands);
|
||||
this.append(tail);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Inserts the new commands before the specified command.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @param {Array[]} commands
|
||||
* List of commands
|
||||
*/
|
||||
insertBefore: function (id, commands) {
|
||||
var index = this.indexOf(id);
|
||||
|
||||
if (index > -1) {
|
||||
var tail = this.removeAfter(id);
|
||||
var object = this.remove(id);
|
||||
|
||||
this.append(commands);
|
||||
this.append(object);
|
||||
this.append(tail);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the specified command
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @returns {object[]} Removed command
|
||||
*/
|
||||
remove : function (id) {
|
||||
return this._commands.splice(this.indexOf(id), 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all commands after the specified one.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @returns {object[]} Removed commands
|
||||
*/
|
||||
removeAfter : function (id) {
|
||||
var index = this.indexOf(id);
|
||||
|
||||
if (index > -1) {
|
||||
return this._commands.splice(index + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all commands before the specified one.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @returns {object[]} Removed commands
|
||||
*/
|
||||
removeBefore : function (id) {
|
||||
var index = this.indexOf(id);
|
||||
|
||||
if (index > -1) {
|
||||
return this._commands.splice(0, index);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Replaces all commands after the specified one.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @returns {object[]} Removed commands
|
||||
*/
|
||||
replaceAfter : function (id, commands) {
|
||||
var oldCommands = this.removeAfter(id);
|
||||
this.append(commands);
|
||||
|
||||
return oldCommands;
|
||||
},
|
||||
|
||||
/**
|
||||
* Replaces all commands before the specified one.
|
||||
*
|
||||
* @param {string} id
|
||||
* Identifier of the command
|
||||
* @returns {object[]} Removed commands
|
||||
*/
|
||||
replaceBefore : function (id, commands) {
|
||||
var oldCommands = this.removeBefore(id);
|
||||
this.insertBefore(id, commands);
|
||||
|
||||
return oldCommands;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Default list of commands to execute for a PeerConnection test.
|
||||
*/
|
||||
var commandsPeerConnection = [
|
||||
[
|
||||
'PC_LOCAL_GUM',
|
||||
function (test) {
|
||||
test.pcLocal.getAllUserMedia(function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_GUM',
|
||||
function (test) {
|
||||
test.pcRemote.getAllUserMedia(function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_CREATE_OFFER',
|
||||
function (test) {
|
||||
test.pcLocal.createOffer(function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SET_LOCAL_DESCRIPTION',
|
||||
function (test) {
|
||||
test.pcLocal.setLocalDescription(test.pcLocal._last_offer, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SET_REMOTE_DESCRIPTION',
|
||||
function (test) {
|
||||
test.pcRemote.setRemoteDescription(test.pcLocal._last_offer, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_CREATE_ANSWER',
|
||||
function (test) {
|
||||
test.pcRemote.createAnswer(function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SET_REMOTE_DESCRIPTION',
|
||||
function (test) {
|
||||
test.pcLocal.setRemoteDescription(test.pcRemote._last_answer, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SET_LOCAL_DESCRIPTION',
|
||||
function (test) {
|
||||
test.pcRemote.setLocalDescription(test.pcRemote._last_answer, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_CHECK_MEDIA',
|
||||
function (test) {
|
||||
test.pcLocal.checkMedia(test.pcRemote.constraints);
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_CHECK_MEDIA',
|
||||
function (test) {
|
||||
test.pcRemote.checkMedia(test.pcLocal.constraints);
|
||||
test.next();
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* This class handles tests for peer connections.
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} [options={}]
|
||||
* Optional options for the peer connection test
|
||||
* @param {object} [options.config_pc1=undefined]
|
||||
* Configuration for the local peer connection instance
|
||||
* @param {object} [options.config_pc2=undefined]
|
||||
* Configuration for the remote peer connection instance. If not defined
|
||||
* the configuration from the local instance will be used
|
||||
*/
|
||||
function PeerConnectionTest(options) {
|
||||
// If no options are specified make it an empty object
|
||||
options = options || { };
|
||||
|
||||
this.pcLocal = new PeerConnectionWrapper('pcLocal', options.config_pc1);
|
||||
this.pcRemote = new PeerConnectionWrapper('pcRemote', options.config_pc2 || options.config_pc1);
|
||||
|
||||
// Create command chain instance and assign default commands
|
||||
this.chain = new CommandChain(this);
|
||||
this.chain.commands = commandsPeerConnection;
|
||||
|
||||
var self = this;
|
||||
this.chain.onFinished = function () {
|
||||
self.teardown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the next command.
|
||||
*/
|
||||
PeerConnectionTest.prototype.next = function PCT_next() {
|
||||
this.chain.executeNext();
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the media constraints for both peer connection instances.
|
||||
*
|
||||
* @param {object} constraintsLocal
|
||||
* Media constrains for the local peer connection instance
|
||||
* @param constraintsRemote
|
||||
*/
|
||||
PeerConnectionTest.prototype.setMediaConstraints =
|
||||
function PCT_setMediaConstraints(constraintsLocal, constraintsRemote) {
|
||||
this.pcLocal.constraints = constraintsLocal;
|
||||
this.pcRemote.constraints = constraintsRemote;
|
||||
};
|
||||
|
||||
/**
|
||||
* Start running the tests as assigned to the command chain.
|
||||
*/
|
||||
PeerConnectionTest.prototype.run = function PCT_run() {
|
||||
this.next();
|
||||
};
|
||||
|
||||
/**
|
||||
* Clean up the objects used by the test
|
||||
*/
|
||||
PeerConnectionTest.prototype.teardown = function PCT_teardown() {
|
||||
if (this.pcLocal) {
|
||||
this.pcLocal.close();
|
||||
this.pcLocal = null;
|
||||
}
|
||||
|
||||
if (this.pcRemote) {
|
||||
this.pcRemote.close();
|
||||
this.pcRemote = null;
|
||||
}
|
||||
|
||||
info("Test finished");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class handles acts as a wrapper around a PeerConnection instance.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} label
|
||||
* Description for the peer connection instance
|
||||
* @param {object} configuration
|
||||
* Configuration for the peer connection instance
|
||||
*/
|
||||
function PeerConnectionWrapper(label, configuration) {
|
||||
this.configuration = configuration;
|
||||
this.label = label;
|
||||
|
||||
this.constraints = [ ];
|
||||
this.streams = [ ];
|
||||
|
||||
info("Creating new PeerConnectionWrapper: " + this.label);
|
||||
this._pc = new mozRTCPeerConnection(this.configuration);
|
||||
|
||||
var self = this;
|
||||
this._pc.onaddstream = function (event) {
|
||||
// Bug 834835: Assume type is video until we get get{Audio,Video}Tracks.
|
||||
self.attachMedia(event.stream, 'video', 'remote');
|
||||
};
|
||||
}
|
||||
|
||||
PeerConnectionWrapper.prototype = {
|
||||
|
||||
/**
|
||||
* Returns the local description.
|
||||
*
|
||||
* @returns {object} The local description
|
||||
*/
|
||||
get localDescription() {
|
||||
return this._pc.localDescription;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the local description.
|
||||
*
|
||||
* @param {object} desc
|
||||
* The new local description
|
||||
*/
|
||||
set localDescription(desc) {
|
||||
this._pc.localDescription = desc;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the remote description.
|
||||
*
|
||||
* @returns {object} The remote description
|
||||
*/
|
||||
get remoteDescription() {
|
||||
return this._pc.remoteDescription;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the remote description.
|
||||
*
|
||||
* @param {object} desc
|
||||
* The new remote description
|
||||
*/
|
||||
set remoteDescription(desc) {
|
||||
this._pc.remoteDescription = desc;
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback when we get media from either side. Also an appropriate
|
||||
* HTML media element will be created.
|
||||
*
|
||||
* @param {MediaStream} stream
|
||||
* Media stream to handle
|
||||
* @param {string} type
|
||||
* The type of media stream ('audio' or 'video')
|
||||
* @param {string} side
|
||||
* The location the stream is coming from ('local' or 'remote')
|
||||
*/
|
||||
attachMedia : function PCW_attachMedia(stream, type, side) {
|
||||
info("Got media stream: " + type + " (" + side + ")");
|
||||
this.streams.push(stream);
|
||||
|
||||
if (side === 'local') {
|
||||
this._pc.addStream(stream);
|
||||
}
|
||||
|
||||
var element = createMediaElement(type, this._label + '_' + side);
|
||||
element.mozSrcObject = stream;
|
||||
element.play();
|
||||
},
|
||||
|
||||
/**
|
||||
* Requests all the media streams as specified in the constrains property.
|
||||
*
|
||||
* @param {function} onSuccess
|
||||
* Callback to execute if all media has been requested successfully
|
||||
*/
|
||||
getAllUserMedia : function PCW_GetAllUserMedia(onSuccess) {
|
||||
var self = this;
|
||||
|
||||
function _getAllUserMedia(constraintsList, index) {
|
||||
if (index < constraintsList.length) {
|
||||
var constraints = constraintsList[index];
|
||||
|
||||
getUserMedia(constraints, function (stream) {
|
||||
var type = constraints;
|
||||
|
||||
if (constraints.audio) {
|
||||
type = 'audio';
|
||||
}
|
||||
|
||||
if (constraints.video) {
|
||||
type += 'video';
|
||||
}
|
||||
|
||||
self.attachMedia(stream, type, 'local');
|
||||
|
||||
_getAllUserMedia(constraintsList, index + 1);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
} else {
|
||||
onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
info("Get " + this.constraints.length + " local streams");
|
||||
_getAllUserMedia(this.constraints, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates an offer and automatically handles the failure case.
|
||||
*
|
||||
* @param {function} onSuccess
|
||||
* Callback to execute if the offer was created successfully
|
||||
*/
|
||||
createOffer : function PCW_createOffer(onSuccess) {
|
||||
var self = this;
|
||||
|
||||
this._pc.createOffer(function (offer) {
|
||||
info("Got offer: " + JSON.stringify(offer));
|
||||
self._last_offer = offer;
|
||||
onSuccess(offer);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates an answer and automatically handles the failure case.
|
||||
*
|
||||
* @param {function} onSuccess
|
||||
* Callback to execute if the answer was created successfully
|
||||
*/
|
||||
createAnswer : function PCW_createAnswer(onSuccess) {
|
||||
var self = this;
|
||||
|
||||
this._pc.createAnswer(function (answer) {
|
||||
info('Got answer for ' + self.label + ': ' + JSON.stringify(answer));
|
||||
self._last_answer = answer;
|
||||
onSuccess(answer);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the local description and automatically handles the failure case.
|
||||
*
|
||||
* @param {object} sdp
|
||||
* SDP for the local description request
|
||||
* @param {function} onSuccess
|
||||
* Callback to execute if the local description was set successfully
|
||||
*/
|
||||
setLocalDescription : function PCW_setLocalDescription(sdp, onSuccess) {
|
||||
var self = this;
|
||||
|
||||
this._pc.setLocalDescription(sdp, function () {
|
||||
info("Successfully set the local description for " + self.label);
|
||||
onSuccess();
|
||||
}, unexpectedCallbackAndFinish);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the remote description and automatically handles the failure case.
|
||||
*
|
||||
* @param {object} sdp
|
||||
* SDP for the remote description request
|
||||
* @param {function} onSuccess
|
||||
* Callback to execute if the remote description was set successfully
|
||||
*/
|
||||
setRemoteDescription : function PCW_setRemoteDescription(sdp, onSuccess) {
|
||||
var self = this;
|
||||
|
||||
this._pc.setRemoteDescription(sdp, function () {
|
||||
info("Successfully set remote description for " + self.label);
|
||||
onSuccess();
|
||||
}, unexpectedCallbackAndFinish);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that we are getting the media we expect.
|
||||
*
|
||||
* @param {object} constraintsRemote
|
||||
* The media constraints of the remote peer connection object
|
||||
*/
|
||||
checkMedia : function PCW_checkMedia(constraintsRemote) {
|
||||
is(this._pc.localStreams.length, this.constraints.length,
|
||||
this.label + ' has ' + this.constraints.length + ' local streams');
|
||||
|
||||
// TODO: change this when multiple incoming streams are allowed.
|
||||
is(this._pc.remoteStreams.length, 1,
|
||||
this.label + ' has ' + 1 + ' remote streams');
|
||||
},
|
||||
|
||||
/**
|
||||
* Closes the connection
|
||||
*/
|
||||
close : function PCW_close() {
|
||||
// It might be that a test has already closed the pc. In those cases
|
||||
// we should not fail.
|
||||
try {
|
||||
this._pc.close();
|
||||
info(this.label + ": Closed connection.");
|
||||
} catch (e) {
|
||||
info(this.label + ": Failure in closing connection - " + e.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,109 +1,29 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=796892
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Basic audio-only peer connection</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=796888">Basic audio-only peer connection</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<audio id="audioPCLocal" controls></audio>
|
||||
<audio id="audioPCRemote" controls></audio>
|
||||
<audio id="audioLocal" controls></audio>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 1);
|
||||
}
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 1);
|
||||
}
|
||||
|
||||
var audioLocal;
|
||||
var audioPCLocal;
|
||||
var audioPCRemote;
|
||||
|
||||
var pcLocal;
|
||||
var pcRemote;
|
||||
|
||||
var test_data = {
|
||||
pcLocal: [],
|
||||
pcRemote: []
|
||||
};
|
||||
createHTML({
|
||||
bug: "796892",
|
||||
title: "Basic audio-only peer connection"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
audioLocal = document.getElementById("audioLocal");
|
||||
audioPCLocal = document.getElementById("audioPCLocal");
|
||||
audioPCRemote = document.getElementById("audioPCRemote");
|
||||
|
||||
pcLocal = new mozRTCPeerConnection();
|
||||
pcRemote = new mozRTCPeerConnection();
|
||||
|
||||
pcLocal.onaddstream = function (aObj) {
|
||||
info("Local Peer Connection onaddstream has been called");
|
||||
test_data.pcLocal.push(aObj.stream);
|
||||
|
||||
audioPCRemote.mozSrcObject = aObj.stream;
|
||||
audioPCRemote.play();
|
||||
};
|
||||
|
||||
pcRemote.onaddstream = function (aObj) {
|
||||
info("Remote Peer Connection onaddstream has been called");
|
||||
test_data.pcRemote.push(aObj.stream);
|
||||
|
||||
audioPCLocal.mozSrcObject = aObj.stream;
|
||||
audioPCLocal.play();
|
||||
};
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true}, function onSuccess(aLocalInputStream) {
|
||||
info("Calling addStream on local peer connection");
|
||||
pcLocal.addStream(aLocalInputStream);
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true}, function onSuccess(aRemoteInputStream) {
|
||||
info("Calling addStream on remote peer connection");
|
||||
pcRemote.addStream(aRemoteInputStream);
|
||||
|
||||
audioLocal.mozSrcObject = aLocalInputStream;
|
||||
audioLocal.play();
|
||||
|
||||
PeerConnection.handShake(pcLocal, pcRemote, function () {
|
||||
info("Finished peer connection handshake");
|
||||
is(pcLocal.localStreams.length, 1,
|
||||
"A single local stream has been attached to the local peer");
|
||||
is(pcRemote.localStreams.length, 1,
|
||||
"A single local stream has been attached to the remote peer");
|
||||
|
||||
// TODO: check that the streams are of the expected types.
|
||||
// Bug 834837.
|
||||
|
||||
ok(PeerConnection.findStream(pcLocal.remoteStreams, test_data.pcLocal[0]) !== -1,
|
||||
"Remote audio stream for local peer is accessible");
|
||||
ok(PeerConnection.findStream(pcRemote.remoteStreams, test_data.pcRemote[0]) !== -1,
|
||||
"Remote audio stream for remote peer is accessible");
|
||||
|
||||
info("For now simply disconnect. We will add checks for media in a follow-up bug");
|
||||
disconnect();
|
||||
});
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.run();
|
||||
}, true);
|
||||
|
||||
function disconnect() {
|
||||
info("Calling close on the local peer connection");
|
||||
pcLocal.close();
|
||||
info("Calling close on the remote peer connection");
|
||||
pcRemote.close();
|
||||
|
||||
info("We can't run any checks and clean-up code due to a crash (see bug 820072)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,26 +1,13 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=796890
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Basic video-only peer connection</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=796890">Basic audio-video peer connection</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<audio id="audioLocal" controls></audio>
|
||||
|
||||
<video id="videoPCLocal" width="160" height="120" controls></video>
|
||||
<video id="videoPCRemote" width="160" height="120" controls></video>
|
||||
<video id="videoLocal" width="160" height="120" controls></video>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
@ -32,115 +19,17 @@ if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 6);
|
||||
}
|
||||
|
||||
var audioLocal;
|
||||
var audioPCLocal;
|
||||
var audioPCRemote;
|
||||
|
||||
var videoLocal;
|
||||
var videoPCLocal;
|
||||
var videoPCRemote;
|
||||
|
||||
var pcLocal;
|
||||
var pcRemote;
|
||||
|
||||
var test_data = {
|
||||
pcLocal: [],
|
||||
pcRemote: []
|
||||
};
|
||||
createHTML({
|
||||
bug: "796890",
|
||||
title: "Basic audio/video (separate) peer connection"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
audioLocal = document.getElementById("audioLocal");
|
||||
audioPCLocal = document.getElementById("audioPCLocal");
|
||||
audioPCRemote = document.getElementById("audioPCRemote");
|
||||
|
||||
videoLocal = document.getElementById("videoLocal");
|
||||
videoPCLocal = document.getElementById("videoPCLocal");
|
||||
videoPCRemote = document.getElementById("videoPCRemote");
|
||||
|
||||
pcLocal = new mozRTCPeerConnection();
|
||||
pcRemote = new mozRTCPeerConnection();
|
||||
|
||||
pcLocal.onaddstream = function (aObj) {
|
||||
info("Local Peer Connection onaddstream has been called");
|
||||
test_data.pcLocal.push(aObj.stream);
|
||||
|
||||
videoPCRemote.mozSrcObject = aObj.stream;
|
||||
videoPCRemote.play();
|
||||
};
|
||||
|
||||
pcRemote.onaddstream = function (aObj) {
|
||||
info("Remote Peer Connection onaddstream has been called");
|
||||
test_data.pcRemote.push(aObj.stream);
|
||||
|
||||
videoPCLocal.mozSrcObject = aObj.stream;
|
||||
videoPCLocal.play();
|
||||
};
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true},
|
||||
function onSuccess(aLocalAudioInputStream) {
|
||||
info("Calling addStream on local peer connection with audio stream");
|
||||
pcLocal.addStream(aLocalAudioInputStream);
|
||||
|
||||
audioLocal.mozSrcObject = aLocalAudioInputStream;
|
||||
audioLocal.play();
|
||||
|
||||
navigator.mozGetUserMedia({video: true, fake: true},
|
||||
function onSuccess(aLocalVideoInputStream) {
|
||||
info("Calling addStream on local peer connection with video stream");
|
||||
pcLocal.addStream(aLocalVideoInputStream);
|
||||
|
||||
videoLocal.mozSrcObject = aLocalVideoInputStream;
|
||||
videoLocal.play();
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true},
|
||||
function onSuccess(aRemoteAudioInputStream) {
|
||||
info("Calling addStream on remote peer connection with audio stream");
|
||||
pcRemote.addStream(aRemoteAudioInputStream);
|
||||
|
||||
navigator.mozGetUserMedia({video: true, fake: true},
|
||||
function onSuccess(aRemoteVideoInputStream) {
|
||||
info("Calling addStream on remote peer connection with video stream");
|
||||
pcRemote.addStream(aRemoteVideoInputStream);
|
||||
|
||||
PeerConnection.handShake(pcLocal, pcRemote, function () {
|
||||
info("Finished peer connection handshake");
|
||||
is(pcLocal.localStreams.length, 2,
|
||||
"Two local streams have been attached to the local peer");
|
||||
is(pcRemote.localStreams.length, 2,
|
||||
"Two local local streams have been attached to the remote peer");
|
||||
|
||||
is(test_data.pcLocal.length, 1,
|
||||
"A remote stream has been attached to the local peer");
|
||||
is(test_data.pcRemote.length, 1,
|
||||
"A remote stream has been attached to the remote peer");
|
||||
|
||||
// TODO: check that the streams are of the expected types.
|
||||
// Bug 834837.
|
||||
|
||||
ok(PeerConnection.findStream(pcLocal.remoteStreams, test_data.pcLocal[0]) !== -1,
|
||||
"Remote stream for local peer is accessible");
|
||||
ok(PeerConnection.findStream(pcRemote.remoteStreams, test_data.pcRemote[0]) !== -1,
|
||||
"Remote stream for remote peer is accessible");
|
||||
|
||||
info("For now simply disconnect. We will add checks for media in a follow-up bug");
|
||||
disconnect();
|
||||
});
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
}, true);
|
||||
|
||||
function disconnect() {
|
||||
info("Calling close on the local peer connection");
|
||||
pcLocal.close();
|
||||
info("Calling close on the remote peer connection");
|
||||
pcRemote.close();
|
||||
|
||||
info("We can't run any checks and clean-up code due to a crash (see bug 820072)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,119 +1,29 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=796890
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Basic video-only peer connection</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=796890">Basic audio-video peer connection</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<audio id="audioLocal" controls></audio>
|
||||
|
||||
<video id="videoPCLocal" width="160" height="120" controls></video>
|
||||
<video id="videoPCRemote" width="160" height="120" controls></video>
|
||||
<video id="videoLocal" width="160" height="120" controls></video>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.expectAssertions(0, 13);
|
||||
|
||||
var audioLocal;
|
||||
var videoLocal;
|
||||
var videoPCLocal;
|
||||
var videoPCRemote;
|
||||
|
||||
var pcLocal;
|
||||
var pcRemote;
|
||||
|
||||
var test_data = {
|
||||
pcLocal: [],
|
||||
pcRemote: []
|
||||
};
|
||||
createHTML({
|
||||
bug: "796890",
|
||||
title: "Basic audio/video (combined) peer connection"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
audioLocal = document.getElementById("audioLocal");
|
||||
videoLocal = document.getElementById("videoLocal");
|
||||
videoPCLocal = document.getElementById("videoPCLocal");
|
||||
videoPCRemote = document.getElementById("videoPCRemote");
|
||||
|
||||
pcLocal = new mozRTCPeerConnection();
|
||||
pcRemote = new mozRTCPeerConnection();
|
||||
|
||||
pcLocal.onaddstream = function (aObj) {
|
||||
info("Local Peer Connection onaddstream has been called");
|
||||
test_data.pcLocal.push(aObj.stream);
|
||||
|
||||
videoPCRemote.mozSrcObject = aObj.stream;
|
||||
videoPCRemote.play();
|
||||
};
|
||||
|
||||
pcRemote.onaddstream = function (aObj) {
|
||||
info("Remote Peer Connection onaddstream has been called");
|
||||
test_data.pcRemote.push(aObj.stream);
|
||||
|
||||
videoPCLocal.mozSrcObject = aObj.stream;
|
||||
videoPCLocal.play();
|
||||
};
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, video: true, fake: true},
|
||||
function onSuccess(aLocalInputStream) {
|
||||
info("Calling addStream on local peer connection");
|
||||
pcLocal.addStream(aLocalInputStream);
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, video: true, fake: true},
|
||||
function onSuccess(aRemoteInputStream) {
|
||||
info("Calling addStream on remote peer connection");
|
||||
pcRemote.addStream(aRemoteInputStream);
|
||||
|
||||
videoLocal.mozSrcObject = aLocalInputStream;
|
||||
videoLocal.play();
|
||||
|
||||
PeerConnection.handShake(pcLocal, pcRemote, function () {
|
||||
info("Finished peer connection handshake");
|
||||
is(pcLocal.localStreams.length, 1,
|
||||
"A single local stream has been attached to the local peer");
|
||||
is(pcRemote.localStreams.length, 1,
|
||||
"A single local stream has been attached to the remote peer");
|
||||
|
||||
is(test_data.pcLocal.length, 1,
|
||||
"A remote stream has been attached to the local peer");
|
||||
is(test_data.pcRemote.length, 1,
|
||||
"A remote stream has been attached to the remote peer");
|
||||
|
||||
// TODO: check that the streams are of the expected types.
|
||||
// Bug 834837.
|
||||
|
||||
ok(PeerConnection.findStream(pcLocal.remoteStreams, test_data.pcLocal[0]) !== -1,
|
||||
"Remote stream for local peer is accessible");
|
||||
ok(PeerConnection.findStream(pcRemote.remoteStreams, test_data.pcRemote[0]) !== -1,
|
||||
"Remote stream for remote peer is accessible");
|
||||
|
||||
info("For now simply disconnect. We will add checks for media in a follow-up bug");
|
||||
disconnect();
|
||||
});
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}, {video: true}],
|
||||
[{audio: true}, {video: true}]);
|
||||
test.run();
|
||||
}, true);
|
||||
|
||||
function disconnect() {
|
||||
info("Calling close on the local peer connection");
|
||||
pcLocal.close();
|
||||
info("Calling close on the remote peer connection");
|
||||
pcRemote.close();
|
||||
|
||||
info("We can't run any checks and clean-up code due to a crash (see bug 820072)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,105 +1,25 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=796888
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Basic video-only peer connection</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=796888">Basic video-only peer connection</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<video id="videoPCLocal" width="160" height="120" controls></video>
|
||||
<video id="videoPCRemote" width="160" height="120" controls></video>
|
||||
<video id="videoLocal" width="160" height="120" controls></video>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
var videoLocal;
|
||||
var videoPCLocal;
|
||||
var videoPCRemote;
|
||||
|
||||
var pcLocal;
|
||||
var pcRemote;
|
||||
|
||||
var test_data = {
|
||||
pcLocal: [],
|
||||
pcRemote: []
|
||||
};
|
||||
createHTML({
|
||||
bug: "796888",
|
||||
title: "Basic video-only peer connection"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
videoLocal = document.getElementById("videoLocal");
|
||||
videoPCLocal = document.getElementById("videoPCLocal");
|
||||
videoPCRemote = document.getElementById("videoPCRemote");
|
||||
|
||||
pcLocal = new mozRTCPeerConnection();
|
||||
pcRemote = new mozRTCPeerConnection();
|
||||
|
||||
pcLocal.onaddstream = function (aObj) {
|
||||
info("Local Peer Connection onaddstream has been called");
|
||||
test_data.pcLocal.push(aObj.stream);
|
||||
|
||||
videoPCRemote.mozSrcObject = aObj.stream;
|
||||
videoPCRemote.play();
|
||||
};
|
||||
|
||||
pcRemote.onaddstream = function (aObj) {
|
||||
info("Remote Peer Connection onaddstream has been called");
|
||||
test_data.pcRemote.push(aObj.stream);
|
||||
|
||||
videoPCLocal.mozSrcObject = aObj.stream;
|
||||
videoPCLocal.play();
|
||||
};
|
||||
|
||||
navigator.mozGetUserMedia({video: true, fake: true}, function onSuccess(aLocalInputStream) {
|
||||
info("Calling addStream on local peer connection");
|
||||
pcLocal.addStream(aLocalInputStream);
|
||||
|
||||
navigator.mozGetUserMedia({video: true, fake: true}, function onSuccess(aRemoteInputStream) {
|
||||
info("Calling addStream on remote peer connection");
|
||||
pcRemote.addStream(aRemoteInputStream);
|
||||
|
||||
videoLocal.mozSrcObject = aLocalInputStream;
|
||||
videoLocal.play();
|
||||
|
||||
PeerConnection.handShake(pcLocal, pcRemote, function () {
|
||||
info("Finished peer connection handshake");
|
||||
is(pcLocal.localStreams.length, 1,
|
||||
"A single local stream has been attached to the local peer");
|
||||
is(pcRemote.localStreams.length, 1,
|
||||
"A single local stream has been attached to the remote peer");
|
||||
|
||||
// TODO: check that the streams are of the expected types.
|
||||
// Bug 834837.
|
||||
|
||||
ok(PeerConnection.findStream(pcLocal.remoteStreams, test_data.pcLocal[0]) !== -1,
|
||||
"Remote video stream for local peer is accessible");
|
||||
ok(PeerConnection.findStream(pcRemote.remoteStreams, test_data.pcRemote[0]) !== -1,
|
||||
"Remote video stream for remote peer is accessible");
|
||||
|
||||
info("For now simply disconnect. We will add checks for media in a follow-up bug");
|
||||
disconnect();
|
||||
});
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{video: true}], [{video: true}]);
|
||||
test.run();
|
||||
}, true);
|
||||
|
||||
function disconnect() {
|
||||
info("Calling close on the local peer connection");
|
||||
pcLocal.close();
|
||||
info("Calling close on the remote peer connection");
|
||||
pcRemote.close();
|
||||
|
||||
info("We can't run any checks and clean-up code due to a crash (see bug 820072)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,33 +1,29 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=822674
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 822674</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 822674 **/
|
||||
runTest(function() {
|
||||
var pc = new mozRTCPeerConnection();
|
||||
pc.thereIsNeverGoingToBeAPropertyWithThisNameOnThisInterface = 1;
|
||||
is(pc.thereIsNeverGoingToBeAPropertyWithThisNameOnThisInterface, 1,
|
||||
"Can set expandos on an RTCPeerConnection")
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822674">Mozilla Bug 822674</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({
|
||||
bug: "822674",
|
||||
title: "mozRTCPeerConnection isn't a true javascript object as it should be"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
var pc = new mozRTCPeerConnection();
|
||||
|
||||
pc.thereIsNeverGoingToBeAPropertyWithThisNameOnThisInterface = 1;
|
||||
is(pc.thereIsNeverGoingToBeAPropertyWithThisNameOnThisInterface, 1,
|
||||
"Can set expandos on an RTCPeerConnection");
|
||||
|
||||
pc = null;
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,62 +1,58 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=825703
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bug 825703: RTCConfiguration valid/invalid permutations</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</meta>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=825703">RTCConfiguration valid/invalid permutations</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript">
|
||||
runTest(function () {
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 280);
|
||||
}
|
||||
var pc;
|
||||
var pcs;
|
||||
var exception = null;
|
||||
try { pcs = new mozRTCPeerConnection(); } catch (e) { exception = e; }
|
||||
ok(!exception, "mozRTCPeerConnection() succeeds");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection(1); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection(1) throws");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({}); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({}) throws");
|
||||
exception = null;
|
||||
try { pcs = new mozRTCPeerConnection([]); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection([]) throws");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: {}}); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: {}}) throws");
|
||||
exception = null;
|
||||
try { pcs = new mozRTCPeerConnection({ iceServers: [] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "mozRTCPeerConnection({ iceServers: [] }) succeeds");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: [{ url:"" }] }); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: [{ url:\"\" }] }) throws");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: [{ url:"http:0.0.0.0" }] }); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: [{ url:\"http:0.0.0.0\" }] }) throws");
|
||||
exception = null;
|
||||
try { pcs = new mozRTCPeerConnection({ iceServers: [{ url:"stun:0.0.0.0" }, { url:"stuns:x.net", foo:"" }, { url: "turn:[::192.9.5.5]:42" }, { url:"turns:user@x.org:42", credential:"p" }] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "mozRTCPeerConnection({ iceServers: [{ url:\"stun:0.0.0.0\" }, { url:\"stuns:x.net\", foo:\"\" }, { url: \"turn:[::192.9.5.5]:42\" }, { url:\"turns:user@x.org:42\", credential:\"p\" }] }) succeeds");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: [{ url:"stun:0.0.0.0", credential:{}}] }); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: [{ url:\"stun:0.0.0.0\", credential:{}}] }) throws");
|
||||
pc = null;
|
||||
pcs = null;
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
<script type="application/javascript">
|
||||
createHTML({
|
||||
bug: "825703",
|
||||
title: "RTCConfiguration valid/invalid permutations"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 280);
|
||||
}
|
||||
var pc;
|
||||
var pcs;
|
||||
var exception = null;
|
||||
try { pcs = new mozRTCPeerConnection(); } catch (e) { exception = e; }
|
||||
ok(!exception, "mozRTCPeerConnection() succeeds");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection(1); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection(1) throws");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({}); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({}) throws");
|
||||
exception = null;
|
||||
try { pcs = new mozRTCPeerConnection([]); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection([]) throws");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: {}}); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: {}}) throws");
|
||||
exception = null;
|
||||
try { pcs = new mozRTCPeerConnection({ iceServers: [] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "mozRTCPeerConnection({ iceServers: [] }) succeeds");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: [{ url:"" }] }); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: [{ url:\"\" }] }) throws");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: [{ url:"http:0.0.0.0" }] }); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: [{ url:\"http:0.0.0.0\" }] }) throws");
|
||||
exception = null;
|
||||
try { pcs = new mozRTCPeerConnection({ iceServers: [{ url:"stun:0.0.0.0" }, { url:"stuns:x.net", foo:"" }, { url: "turn:[::192.9.5.5]:42" }, { url:"turns:user@x.org:42", credential:"p" }] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "mozRTCPeerConnection({ iceServers: [{ url:\"stun:0.0.0.0\" }, { url:\"stuns:x.net\", foo:\"\" }, { url: \"turn:[::192.9.5.5]:42\" }, { url:\"turns:user@x.org:42\", credential:\"p\" }] }) succeeds");
|
||||
exception = null;
|
||||
try { pc = new mozRTCPeerConnection({ iceServers: [{ url:"stun:0.0.0.0", credential:{}}] }); } catch (e) { exception = e; }
|
||||
ok(exception, "mozRTCPeerConnection({ iceServers: [{ url:\"stun:0.0.0.0\", credential:{}}] }) throws");
|
||||
pc = null;
|
||||
pcs = null;
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,114 +1,94 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=827843
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bug 827843: Ensure that localDescription and remoteDescription are null after close</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=827843">Make sure functions act correctly after close()</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<audio id="audioPCLocal" controls></audio>
|
||||
<audio id="audioPCRemote" controls></audio>
|
||||
<audio id="audioLocal" controls></audio>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 200);
|
||||
}
|
||||
|
||||
var audioLocal;
|
||||
var audioPCLocal;
|
||||
var audioPCRemote;
|
||||
|
||||
var pcLocal;
|
||||
var pcRemote;
|
||||
createHTML({
|
||||
bug: "827843",
|
||||
title: "Ensure that localDescription and remoteDescription are null after close"
|
||||
});
|
||||
|
||||
var test_data = {
|
||||
pcLocal: [],
|
||||
pcRemote: []
|
||||
};
|
||||
var steps = [
|
||||
[
|
||||
"CHECK_FOR_SANE_SDP",
|
||||
function (test) {
|
||||
// TODO: We might want to move those checks into the default chain
|
||||
ok(test.pcLocal.localDescription,
|
||||
"test.pcLocal.localDescription is not null");
|
||||
is(test.pcLocal.localDescription.type, "offer",
|
||||
"test.pcLocal.localDescription type is offer");
|
||||
ok(test.pcLocal.localDescription.sdp.length > 10,
|
||||
"test.pcLocal.localDescription body length is plausible");
|
||||
|
||||
ok(test.pcLocal.remoteDescription,
|
||||
"test.pcLocal.remoteDescription is not null");
|
||||
is(test.pcLocal.remoteDescription.type, "answer",
|
||||
"test.pcLocal.remoteDescription type is answer");
|
||||
ok(test.pcLocal.remoteDescription.sdp.length > 10,
|
||||
"test.pcLocal.remoteDescription body length is plausible");
|
||||
|
||||
ok(test.pcRemote.localDescription,
|
||||
"test.pcRemote.localDescription is not null");
|
||||
is(test.pcRemote.localDescription.type, "answer",
|
||||
"test.pcRemote.localDescription type is answer");
|
||||
ok(test.pcRemote.localDescription.sdp.length > 10,
|
||||
"test.pcRemote.localDescription body length is plausible");
|
||||
|
||||
ok(test.pcRemote.remoteDescription,
|
||||
"test.pcRemote.remoteDescription is not null");
|
||||
is(test.pcRemote.remoteDescription.type, "offer",
|
||||
"test.pcRemote.remoteDescription type is offer");
|
||||
ok(test.pcRemote.remoteDescription.sdp.length > 10,
|
||||
"test.pcRemote.remoteDescription body length is plausible");
|
||||
|
||||
test.next();
|
||||
}
|
||||
], [
|
||||
"CHECK_SDP_ON_CLOSED_PC",
|
||||
function (test) {
|
||||
var description;
|
||||
var exception = null;
|
||||
|
||||
test.pcLocal.close();
|
||||
|
||||
try { description = test.pcLocal.localDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "Attempt to access localDescription of pcLocal after close throws exception");
|
||||
exception = null;
|
||||
|
||||
try { description = test.pcLocal.remoteDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "Attempt to access remoteDescription of pcLocal after close throws exception");
|
||||
exception = null;
|
||||
|
||||
test.pcRemote.close();
|
||||
|
||||
try { description = test.pcRemote.localDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "Attempt to access localDescription of pcRemote after close throws exception");
|
||||
exception = null;
|
||||
|
||||
try { description = test.pcRemote.remoteDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "Attempt to access remoteDescription of pcRemote after close throws exception");
|
||||
|
||||
test.next();
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
runTest(function () {
|
||||
audioLocal = document.getElementById("audioLocal");
|
||||
audioPCLocal = document.getElementById("audioPCLocal");
|
||||
audioPCRemote = document.getElementById("audioPCRemote");
|
||||
|
||||
pcLocal = new mozRTCPeerConnection();
|
||||
pcRemote = new mozRTCPeerConnection();
|
||||
|
||||
pcLocal.onaddstream = function (aObj) {
|
||||
test_data.pcLocal.push(aObj.stream);
|
||||
|
||||
audioPCRemote.mozSrcObject = aObj.stream;
|
||||
audioPCRemote.play();
|
||||
};
|
||||
|
||||
pcRemote.onaddstream = function (aObj) {
|
||||
test_data.pcRemote.push(aObj.stream);
|
||||
|
||||
audioPCLocal.mozSrcObject = aObj.stream;
|
||||
audioPCLocal.play();
|
||||
};
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true}, function onSuccess(aLocalInputStream) {
|
||||
pcLocal.addStream(aLocalInputStream);
|
||||
|
||||
navigator.mozGetUserMedia({audio: true, fake: true}, function onSuccess(aRemoteInputStream) {
|
||||
pcRemote.addStream(aRemoteInputStream);
|
||||
|
||||
audioLocal.mozSrcObject = aLocalInputStream;
|
||||
audioLocal.play();
|
||||
|
||||
PeerConnection.handShake(pcLocal, pcRemote, function () {
|
||||
|
||||
/* Check that the SDP is sane to start with */
|
||||
ok(pcLocal.localDescription, "pcLocal.localDescription is not null");
|
||||
is(pcLocal.localDescription.type, "offer", "pcLocal.localDescription type is offer");
|
||||
ok(pcLocal.localDescription.sdp.length > 10, "pcLocal.localDescription body length is plausible");
|
||||
|
||||
ok(pcLocal.remoteDescription, "pcLocal.remoteDescription is not null");
|
||||
is(pcLocal.remoteDescription.type, "answer", "pcLocal.remoteDescription type is answer");
|
||||
ok(pcLocal.remoteDescription.sdp.length > 10, "pcLocal.remoteDescription body length is plausible");
|
||||
|
||||
ok(pcRemote.localDescription, "pcRemote.localDescription is not null");
|
||||
is(pcRemote.localDescription.type, "answer", "pcRemote.localDescription type is answer");
|
||||
ok(pcRemote.localDescription.sdp.length > 10, "pcRemote.localDescription body length is plausible");
|
||||
|
||||
ok(pcRemote.remoteDescription, "pcRemote.remoteDescription is not null");
|
||||
is(pcRemote.remoteDescription.type, "offer", "pcRemote.remoteDescription type is offer");
|
||||
ok(pcRemote.remoteDescription.sdp.length > 10, "pcRemote.remoteDescription body length is plausible");
|
||||
|
||||
pcLocal.close();
|
||||
var exception = null;
|
||||
try { description = pcLocal.localDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "attempt to access pcLocal.localDescription after close throws exception");
|
||||
exception = null;
|
||||
try { description = pcLocal.remoteDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "attempt to access pcLocal.remoteDescription after close throws exception");
|
||||
|
||||
pcRemote.close();
|
||||
exception = null;
|
||||
try { description = pcRemote.localDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "attempt to access pcRemote.localDescription after close throws exception");
|
||||
exception = null;
|
||||
try { description = pcRemote.remoteDescription; } catch (e) { exception = e; }
|
||||
ok(exception, "attempt to access pcRemote.remoteDescription after close throws exception");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, unexpectedCallbackAndFinish);
|
||||
}, unexpectedCallbackAndFinish);
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true}], [{audio: true}]);
|
||||
test.chain.append(steps);
|
||||
test.run();
|
||||
}, true);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,57 +1,47 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=834153
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bug 834153: Queue CreateAnswer in PeerConnection.js</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</meta>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=834153">Queue CreateAnswer in PeerConnection.js</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript">
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 369);
|
||||
}
|
||||
|
||||
function croak(msg) {
|
||||
ok(0,msg);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
createHTML({
|
||||
bug: "834153",
|
||||
title: "Queue CreateAnswer in PeerConnection.js"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
var pc1;
|
||||
function croak(msg) {
|
||||
ok(0, msg);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
pc1 = new mozRTCPeerConnection();
|
||||
ok(pc1, "pc1 is non-null");
|
||||
runTest(function () {
|
||||
var pc1 = new mozRTCPeerConnection();
|
||||
|
||||
pc1.createOffer(
|
||||
function(d) {
|
||||
pc2 = new mozRTCPeerConnection();
|
||||
ok(pc2, "pc2 is non-null");
|
||||
pc1.createOffer(function (d) {
|
||||
var pc2 = new mozRTCPeerConnection();
|
||||
|
||||
// The whole point of this test is not to wait for the
|
||||
// setRemoteDescription call to succesfully complete, so we
|
||||
// don't do anything in its callbacks.
|
||||
pc2.setRemoteDescription(d,function(x){},function(x){});
|
||||
pc2.createAnswer(
|
||||
function (d) {
|
||||
is(d.type,"answer","CreateAnswer created an answer");
|
||||
SimpleTest.finish();
|
||||
},
|
||||
function(err){croak("createAnswer failed: " + err);}
|
||||
);
|
||||
},
|
||||
function(err){croak("createOffer failed: " + err);}
|
||||
);
|
||||
}, true);
|
||||
pc2.setRemoteDescription(d, function (x) {}, function (x) {});
|
||||
pc2.createAnswer(function (d) {
|
||||
is(d.type,"answer","CreateAnswer created an answer");
|
||||
SimpleTest.finish();
|
||||
}, function (err) {
|
||||
croak("createAnswer failed: " + err);
|
||||
});
|
||||
}, function (err) {
|
||||
croak("createOffer failed: " + err);
|
||||
});
|
||||
}, true);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,69 +1,66 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=825703
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bug 835370: PeerConnection.createOffer valid/invalid constraints permutations</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</meta>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=825703">PeerConnection.createOffer constraints valid/invalid constraints permutations</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript">
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Win")) {
|
||||
SimpleTest.expectAssertions(0, 9);
|
||||
}
|
||||
runTest(function () {
|
||||
var pconnect = new mozRTCPeerConnection();
|
||||
var pconnects = new mozRTCPeerConnection();
|
||||
|
||||
function step1(offer) {}
|
||||
function failed(code) {}
|
||||
createHTML({
|
||||
bug: "825703",
|
||||
title: "PeerConnection.createOffer valid/invalid constraints permutations"
|
||||
});
|
||||
|
||||
var exception = null;
|
||||
try { pconnects.createOffer(step1, failed); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed) succeeds");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, 1); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, 1) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, []); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, []) throws");
|
||||
exception = null;
|
||||
try { pconnects.createOffer(step1, failed, {}); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed, {}) succeeds");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { mandatory: [] }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { mandatory: [] }) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { mandatory: { FooBar: true } }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { mandatory: { FooBar: true } }) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { optional: {} }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { optional: {} }) throws");
|
||||
exception = null;
|
||||
try { pconnects.createOffer(step1, failed, { optional: [] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed, { optional: [] }) succeeds");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { optional: [1] }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { optional: [1] }) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { optional: [{ OfferToReceiveVideo: false, OfferToReceiveAudio: true, }] }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { optional: [{ OfferToReceiveVideo: false, OfferToReceiveAudio: true, }] }) throws");
|
||||
exception = null;
|
||||
try { pconnects.createOffer(step1, failed, { mandatory: { OfferToReceiveVideo: false, OfferToReceiveAudio: true, MozDontOfferDataChannel: true}, optional: [{ VoiceActivityDetection: true }, { FooBar: "42" }] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed, { mandatory: { OfferToReceiveVideo: false, OfferToReceiveAudio: true, MozDontOfferDataChannel: true}, optional: [{ VoiceActivityDetection: true }, { FooBar: \"42\" }] }) succeeds");
|
||||
pconnect = null;
|
||||
pconnects = null;
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
runTest(function () {
|
||||
var pconnect = new mozRTCPeerConnection();
|
||||
var pconnects = new mozRTCPeerConnection();
|
||||
|
||||
function step1(offer) {}
|
||||
function failed(code) {}
|
||||
|
||||
var exception = null;
|
||||
try { pconnects.createOffer(step1, failed); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed) succeeds");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, 1); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, 1) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, []); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, []) throws");
|
||||
exception = null;
|
||||
try { pconnects.createOffer(step1, failed, {}); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed, {}) succeeds");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { mandatory: [] }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { mandatory: [] }) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { mandatory: { FooBar: true } }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { mandatory: { FooBar: true } }) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { optional: {} }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { optional: {} }) throws");
|
||||
exception = null;
|
||||
try { pconnects.createOffer(step1, failed, { optional: [] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed, { optional: [] }) succeeds");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { optional: [1] }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { optional: [1] }) throws");
|
||||
exception = null;
|
||||
try { pconnect.createOffer(step1, failed, { optional: [{ OfferToReceiveVideo: false, OfferToReceiveAudio: true, }] }); } catch (e) { exception = e; }
|
||||
ok(exception, "createOffer(step1, failed, { optional: [{ OfferToReceiveVideo: false, OfferToReceiveAudio: true, }] }) throws");
|
||||
exception = null;
|
||||
try { pconnects.createOffer(step1, failed, { mandatory: { OfferToReceiveVideo: false, OfferToReceiveAudio: true, MozDontOfferDataChannel: true}, optional: [{ VoiceActivityDetection: true }, { FooBar: "42" }] }); } catch (e) { exception = e; }
|
||||
ok(!exception, "createOffer(step1, failed, { mandatory: { OfferToReceiveVideo: false, OfferToReceiveAudio: true, MozDontOfferDataChannel: true}, optional: [{ VoiceActivityDetection: true }, { FooBar: \"42\" }] }) succeeds");
|
||||
pconnect = null;
|
||||
pconnects = null;
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,25 +1,14 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=840344
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bug 840344: Assertion failure</title>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
|
||||
</script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</meta>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=840344">
|
||||
Bug 840344</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<script type="application/javascript">
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
SimpleTest.expectAssertions(0, 1);
|
||||
@ -27,108 +16,109 @@ Bug 840344</a>
|
||||
SimpleTest.expectAssertions(0, 125);
|
||||
}
|
||||
|
||||
runTest(function () {
|
||||
var answerCount = 0;
|
||||
var setLocalCount = 0;
|
||||
createHTML({
|
||||
bug: "840344",
|
||||
title: "Prevent multiple creations of local SDP"
|
||||
});
|
||||
|
||||
// SDP to stand in for an offer coming from a (theoretical) remote endpoint
|
||||
var offer = { sdp: "v=0\r\n"+
|
||||
"o=Mozilla-SIPUA 23597 0 IN IP4 0.0.0.0\r\n"+
|
||||
"s=SIP Call\r\n"+
|
||||
"t=0 0\r\n"+
|
||||
"a=ice-ufrag:f5fda439\r\n"+
|
||||
"a=ice-pwd:d0df8e2904bdbd29587966e797655970\r\n"+
|
||||
"a=fingerprint:sha-256 DF:69:78:20:8D:2E:08:CE:49:82:A3:11:79:1D:BF:"+
|
||||
"B5:49:49:2D:32:82:2F:0D:88:84:A7:C6:63:23:63:A9:0F\r\n"+
|
||||
"m=audio 52757 RTP/SAVPF 109 0 8 101\r\n"+
|
||||
"c=IN IP4 192.168.129.33\r\n"+
|
||||
"a=rtpmap:109 opus/48000/2\r\n"+
|
||||
"a=ptime:20\r\n"+
|
||||
"a=rtpmap:0 PCMU/8000\r\n"+
|
||||
"a=rtpmap:8 PCMA/8000\r\n"+
|
||||
"a=rtpmap:101 telephone-event/8000\r\n"+
|
||||
"a=fmtp:101 0-15\r\n"+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=candidate:0 1 UDP 2113601791 192.168.129.33 52757 typ host\r\n"+
|
||||
"a=candidate:0 2 UDP 2113601790 192.168.129.33 59738 typ host\r\n"+
|
||||
"m=video 63901 RTP/SAVPF 120\r\n"+
|
||||
"c=IN IP4 192.168.129.33\r\n"+
|
||||
"a=rtpmap:120 VP8/90000\r\n"+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=candidate:0 1 UDP 2113601791 192.168.129.33 63901 typ host\r\n"+
|
||||
"a=candidate:0 2 UDP 2113601790 192.168.129.33 54165 typ host\r\n"+
|
||||
"m=application 65080 SCTP/DTLS 5000 \r\n"+
|
||||
"c=IN IP4 192.168.129.33\r\n"+
|
||||
"a=fmtp:5000 protocol=webrtc-datachannel;streams=16\r\n"+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=candidate:0 1 UDP 2113601791 192.168.129.33 65080 typ host\r\n"+
|
||||
"a=candidate:0 2 UDP 2113601790 192.168.129.33 62658 typ host\r\n",
|
||||
type: "offer" };
|
||||
// SDP to stand in for an offer coming from a (theoretical) remote endpoint
|
||||
var offer = {
|
||||
sdp: "v=0\r\n"+
|
||||
"o=Mozilla-SIPUA 23597 0 IN IP4 0.0.0.0\r\n"+
|
||||
"s=SIP Call\r\n"+
|
||||
"t=0 0\r\n"+
|
||||
"a=ice-ufrag:f5fda439\r\n"+
|
||||
"a=ice-pwd:d0df8e2904bdbd29587966e797655970\r\n"+
|
||||
"a=fingerprint:sha-256 DF:69:78:20:8D:2E:08:CE:49:82:A3:11:79:1D:BF:"+
|
||||
"B5:49:49:2D:32:82:2F:0D:88:84:A7:C6:63:23:63:A9:0F\r\n"+
|
||||
"m=audio 52757 RTP/SAVPF 109 0 8 101\r\n"+
|
||||
"c=IN IP4 192.168.129.33\r\n"+
|
||||
"a=rtpmap:109 opus/48000/2\r\n"+
|
||||
"a=ptime:20\r\n"+
|
||||
"a=rtpmap:0 PCMU/8000\r\n"+
|
||||
"a=rtpmap:8 PCMA/8000\r\n"+
|
||||
"a=rtpmap:101 telephone-event/8000\r\n"+
|
||||
"a=fmtp:101 0-15\r\n"+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=candidate:0 1 UDP 2113601791 192.168.129.33 52757 typ host\r\n"+
|
||||
"a=candidate:0 2 UDP 2113601790 192.168.129.33 59738 typ host\r\n"+
|
||||
"m=video 63901 RTP/SAVPF 120\r\n"+
|
||||
"c=IN IP4 192.168.129.33\r\n"+
|
||||
"a=rtpmap:120 VP8/90000\r\n"+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=candidate:0 1 UDP 2113601791 192.168.129.33 63901 typ host\r\n"+
|
||||
"a=candidate:0 2 UDP 2113601790 192.168.129.33 54165 typ host\r\n"+
|
||||
"m=application 65080 SCTP/DTLS 5000 \r\n"+
|
||||
"c=IN IP4 192.168.129.33\r\n"+
|
||||
"a=fmtp:5000 protocol=webrtc-datachannel;streams=16\r\n"+
|
||||
"a=sendrecv\r\n"+
|
||||
"a=candidate:0 1 UDP 2113601791 192.168.129.33 65080 typ host\r\n"+
|
||||
"a=candidate:0 2 UDP 2113601790 192.168.129.33 62658 typ host\r\n",
|
||||
type: "offer"
|
||||
};
|
||||
|
||||
info("Step 0: Instantiate a Peer Connection");
|
||||
var pc = new mozRTCPeerConnection();
|
||||
|
||||
// First: Kick off the chain of events by asking for a mic and camera
|
||||
var start = function() {
|
||||
info("Step 1: Get User Media for Audio and Video");
|
||||
getUserMedia({audio:true, video:true},
|
||||
gumSuccess, unexpectedCallbackAndFinish);
|
||||
};
|
||||
|
||||
// Second: set the remote description
|
||||
var gumSuccess = function(x) {
|
||||
info("Step 2a: Add stream");
|
||||
pc.addStream(x);
|
||||
info("Step 2b: Create Session Description");
|
||||
var osd = new mozRTCSessionDescription(offer);
|
||||
info("Step 2c: Set Remote Description");
|
||||
pc.setRemoteDescription(osd,
|
||||
setRemoteSuccess,
|
||||
unexpectedCallbackAndFinish);
|
||||
};
|
||||
|
||||
// Third: Attempt to create an answer. Twice.
|
||||
var setRemoteSuccess = function() {
|
||||
info("Step 3a: Create answer #1");
|
||||
pc.createAnswer(answerSuccess, unexpectedCallbackAndFinish);
|
||||
info("Step 3b: Create answer #2");
|
||||
pc.createAnswer(answerSuccess, unexpectedCallbackAndFinish);
|
||||
};
|
||||
|
||||
// Fourth: Count the answers and push them into the local description
|
||||
var answerSuccess = function(answer) {
|
||||
answerCount++;
|
||||
ok (answerCount < 3, "Answer count is less than three.")
|
||||
info("got answer #" + answerCount);
|
||||
is(answer.type,'answer',"Answer is of type 'answer'");
|
||||
ok(answer.sdp.length > 10, "Answer has length " + answer.sdp.length);
|
||||
info("Step 4: Set local description");
|
||||
pc.setLocalDescription(answer,
|
||||
setLocalSuccess,
|
||||
unexpectedCallbackAndFinish);
|
||||
};
|
||||
|
||||
// Fifth: Once we have two successful rounds through here, we're done.
|
||||
var setLocalSuccess = function(x) {
|
||||
setLocalCount++;
|
||||
info("Set local description #" + setLocalCount);
|
||||
// Then shalt thou count to two, no more, no less. Two shall be the
|
||||
// number thou shalt count, and the number of the counting shall be
|
||||
// two. Three shalt thou not count, neither count thou one, excepting
|
||||
// that thou then proceed to two. Four is right out. Once the number two,
|
||||
// being the second number, be reached, then thou shalt declare success.
|
||||
ok (setLocalCount < 3, "Set local count is less than three.")
|
||||
if (setLocalCount === 2) {
|
||||
is (answerCount, 2, "Answer count is 2.")
|
||||
info("Step 5: Finished");
|
||||
SimpleTest.finish();
|
||||
var steps = [
|
||||
[
|
||||
"SET_REMOTE_DESCRIPTION",
|
||||
function (test) {
|
||||
var osd = new mozRTCSessionDescription(offer);
|
||||
test.pcLocal.setRemoteDescription(osd, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
};
|
||||
],
|
||||
[
|
||||
"CHECK_MULTIPLE_ANSWERS",
|
||||
function (test) {
|
||||
var answerCount = 0;
|
||||
var setLocalCount = 0;
|
||||
|
||||
start();
|
||||
info("Create answer #1");
|
||||
test.pcLocal.createAnswer(answerSuccess);
|
||||
|
||||
info("Create answer #2");
|
||||
test.pcLocal.createAnswer(answerSuccess);
|
||||
|
||||
|
||||
// Fourth: Count the answers and push them into the local description
|
||||
function answerSuccess(answer) {
|
||||
answerCount++;
|
||||
ok (answerCount < 3, "Answer count is less than three.")
|
||||
|
||||
info("Got answer #" + answerCount);
|
||||
is(answer.type, 'answer', "Answer is of type 'answer'");
|
||||
ok(answer.sdp.length > 10, "Answer has length " + answer.sdp.length);
|
||||
|
||||
info("Set local description for answer #" + answerCount);
|
||||
test.pcLocal.setLocalDescription(answer, setLocalSuccess);
|
||||
}
|
||||
|
||||
// Fifth: Once we have two successful rounds through here, we're done.
|
||||
function setLocalSuccess() {
|
||||
setLocalCount++;
|
||||
|
||||
info("Set local description #" + setLocalCount);
|
||||
// Then shalt thou count to two, no more, no less. Two shall be the
|
||||
// number thou shalt count, and the number of the counting shall be
|
||||
// two. Three shalt thou not count, neither count thou one, excepting
|
||||
// that thou then proceed to two. Four is right out. Once the number two,
|
||||
// being the second number, be reached, then thou shalt declare success.
|
||||
ok (setLocalCount < 3, "Set local count is less than three.")
|
||||
if (setLocalCount === 2) {
|
||||
is (answerCount, 2, "Answer count is 2.")
|
||||
test.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
runTest(function () {
|
||||
var test = new PeerConnectionTest();
|
||||
test.setMediaConstraints([{audio: true, video: true}], [ ]);
|
||||
test.chain.replaceAfter("PC_LOCAL_GUM", steps);
|
||||
test.run();
|
||||
}, true);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user