зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1020024 - fix data channel connecting race conditions. r=jib
This commit is contained in:
Родитель
9c58a25bae
Коммит
6cbdff01c3
|
@ -1119,23 +1119,17 @@ DataChannelTest.prototype = Object.create(PeerConnectionTest.prototype, {
|
|||
*/
|
||||
value : function DCT_waitForInitialDataChannel(peer, onSuccess, onFailure) {
|
||||
var dcConnectionTimeout = null;
|
||||
var dcOpened = false;
|
||||
|
||||
function dataChannelConnected(channel) {
|
||||
// in case the switch statement below had called onSuccess already we
|
||||
// don't want to call it again
|
||||
if (!dcOpened) {
|
||||
clearTimeout(dcConnectionTimeout);
|
||||
is(channel.readyState, "open", peer + " dataChannels[0] switched to state: 'open'");
|
||||
dcOpened = true;
|
||||
onSuccess();
|
||||
}
|
||||
|
||||
if (peer.dataChannels.length >= 1) {
|
||||
if (peer.dataChannels[0].readyState === "open") {
|
||||
is(peer.dataChannels[0].readyState, "open", peer + " dataChannels[0] is already in state: 'open'");
|
||||
onSuccess();
|
||||
return;
|
||||
} else {
|
||||
is(peer.dataChannels[0].readyState, "connecting", peer + " dataChannels[0] is in state: 'connecting'");
|
||||
}
|
||||
} else {
|
||||
info(peer + "'s dataChannels[] is empty");
|
||||
}
|
||||
|
||||
// TODO: drno: convert dataChannels into an object and make
|
||||
|
@ -1146,12 +1140,34 @@ DataChannelTest.prototype = Object.create(PeerConnectionTest.prototype, {
|
|||
peer.registerDataChannelOpenEvents(dataChannelConnected);
|
||||
}
|
||||
|
||||
if (peer.dataChannels.length >= 1) {
|
||||
// snapshot of the live value as it might change during test execution
|
||||
const readyState = peer.dataChannels[0].readyState;
|
||||
switch (readyState) {
|
||||
case "open": {
|
||||
is(readyState, "open", peer + " dataChannels[0] is already in state: 'open'");
|
||||
dcOpened = true;
|
||||
onSuccess();
|
||||
break;
|
||||
}
|
||||
case "connecting": {
|
||||
is(readyState, "connecting", peer + " dataChannels[0] is in state: 'connecting'");
|
||||
if (onFailure) {
|
||||
dcConnectionTimeout = setTimeout(function () {
|
||||
info(peer + " timed out while waiting for dataChannels[0] to connect");
|
||||
is(peer.dataChannels[0].readyState, "open", peer + " timed out while waiting for dataChannels[0] to open");
|
||||
onFailure();
|
||||
}, 60000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ok(false, "dataChannels[0] is in unexpected state " + readyState);
|
||||
if (onFailure) {
|
||||
onFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче