зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1201805 - [Presentation WebAPI] Fix collaboration issues with control channel. Part 1 - String mismatch in channel description. r=fabrice
This commit is contained in:
Родитель
5b9b7ae185
Коммит
61577abd58
|
@ -16,7 +16,7 @@ interface nsIPresentationChannelDescription: nsISupports
|
|||
// Type of transport channel.
|
||||
readonly attribute uint8_t type;
|
||||
|
||||
// Addresses for TCP channel.
|
||||
// Addresses for TCP channel (as a list of nsISupportsCString).
|
||||
// Should only be used while type == TYPE_TCP.
|
||||
readonly attribute nsIArray tcpAddress;
|
||||
|
||||
|
|
|
@ -264,8 +264,8 @@ function ChannelDescription(aInit) {
|
|||
this._tcpAddresses = Cc["@mozilla.org/array;1"]
|
||||
.createInstance(Ci.nsIMutableArray);
|
||||
for (let address of aInit.tcpAddress) {
|
||||
let wrapper = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
let wrapper = Cc["@mozilla.org/supports-cstring;1"]
|
||||
.createInstance(Ci.nsISupportsCString);
|
||||
wrapper.data = address;
|
||||
this._tcpAddresses.appendElement(wrapper, false);
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ function discriptionAsJson(aDescription) {
|
|||
let addresses = aDescription.tcpAddress.QueryInterface(Ci.nsIArray);
|
||||
json.tcpAddress = [];
|
||||
for (let idx = 0; idx < addresses.length; idx++) {
|
||||
let address = addresses.queryElementAt(idx, Ci.nsISupportsString);
|
||||
let address = addresses.queryElementAt(idx, Ci.nsISupportsCString);
|
||||
json.tcpAddress.push(address.data);
|
||||
}
|
||||
json.tcpPort = aDescription.tcpPort;
|
||||
|
@ -541,11 +541,11 @@ TCPControlChannel.prototype = {
|
|||
break;
|
||||
}
|
||||
case "requestSession:Offer": {
|
||||
this._listener.onOffer(new ChannelDescription(aMsg.offer));
|
||||
this._onOffer(aMsg.offer);
|
||||
break;
|
||||
}
|
||||
case "requestSession:Answer": {
|
||||
this._listener.onAnswer(new ChannelDescription(aMsg.answer));
|
||||
this._onAnswer(aMsg.answer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,9 +100,41 @@ const mockedControlChannel = {
|
|||
return this._listener;
|
||||
},
|
||||
sendOffer: function(offer) {
|
||||
sendAsyncMessage('offer-sent');
|
||||
var isValid = false;
|
||||
try {
|
||||
var addresses = offer.tcpAddress;
|
||||
if (addresses.length > 0) {
|
||||
for (var i = 0; i < addresses.length; i++) {
|
||||
// Ensure CString addresses are used. Otherwise, an error will be thrown.
|
||||
addresses.queryElementAt(i, Ci.nsISupportsCString);
|
||||
}
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
} catch (e) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
sendAsyncMessage('offer-sent', isValid);
|
||||
},
|
||||
sendAnswer: function(answer) {
|
||||
var isValid = false;
|
||||
try {
|
||||
var addresses = answer.tcpAddress;
|
||||
if (addresses.length > 0) {
|
||||
for (var i = 0; i < addresses.length; i++) {
|
||||
// Ensure CString addresses are used. Otherwise, an error will be thrown.
|
||||
addresses.queryElementAt(i, Ci.nsISupportsCString);
|
||||
}
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
} catch (e) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
sendAsyncMessage('answer-sent', isValid);
|
||||
|
||||
this._listener.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportReady();
|
||||
},
|
||||
close: function(reason) {
|
||||
|
|
|
@ -62,6 +62,11 @@ function setup() {
|
|||
info("An offer is received.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener('answer-sent', function answerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('answer-sent', answerSentHandler);
|
||||
ok(aIsValid, "A valid answer is sent.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener('control-channel-closed', function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener('control-channel-closed', controlChannelClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The control channel is closed normally.");
|
||||
|
|
|
@ -111,6 +111,11 @@ function setup() {
|
|||
info("An offer is received.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener('answer-sent', function answerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('answer-sent', answerSentHandler);
|
||||
ok(aIsValid, "A valid answer is sent.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener('control-channel-closed', function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener('control-channel-closed', controlChannelClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The control channel is closed normally.");
|
||||
|
|
|
@ -48,9 +48,9 @@ function testStartSession() {
|
|||
info("The control channel is closed. " + aReason);
|
||||
});
|
||||
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler() {
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('offer-sent', offerSentHandler);
|
||||
info("An offer is sent out.");
|
||||
ok(aIsValid, "A valid offer is sent out.");
|
||||
gScript.sendAsyncMessage('trigger-incoming-transport');
|
||||
});
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ function testStartSession() {
|
|||
info("The control channel is closed. " + aReason);
|
||||
});
|
||||
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler() {
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('offer-sent', offerSentHandler);
|
||||
info("An offer is sent out.");
|
||||
ok(aIsValid, "A valid offer is sent out.");
|
||||
gScript.sendAsyncMessage('trigger-incoming-answer');
|
||||
});
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@ function testStartSessionUnexpectedControlChannelCloseBeforeDataTransportInit()
|
|||
info("The control channel is closed. " + aReason);
|
||||
});
|
||||
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler() {
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('offer-sent', offerSentHandler);
|
||||
info("An offer is sent out.");
|
||||
ok(aIsValid, "A valid offer is sent out.");
|
||||
gScript.sendAsyncMessage('trigger-control-channel-close', SpecialPowers.Cr.NS_ERROR_FAILURE);
|
||||
});
|
||||
|
||||
|
@ -120,9 +120,9 @@ function testStartSessionUnexpectedControlChannelCloseBeforeDataTransportReady()
|
|||
info("The control channel is closed. " + aReason);
|
||||
});
|
||||
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler() {
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('offer-sent', offerSentHandler);
|
||||
info("An offer is sent out.");
|
||||
ok(aIsValid, "A valid offer is sent out.");
|
||||
gScript.sendAsyncMessage('trigger-incoming-transport');
|
||||
});
|
||||
|
||||
|
@ -168,9 +168,9 @@ function testStartSessionUnexpectedDataTransportClose() {
|
|||
info("The control channel is closed. " + aReason);
|
||||
});
|
||||
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler() {
|
||||
gScript.addMessageListener('offer-sent', function offerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener('offer-sent', offerSentHandler);
|
||||
info("An offer is sent out.");
|
||||
ok(aIsValid, "A valid offer is sent out.");
|
||||
gScript.sendAsyncMessage('trigger-incoming-transport');
|
||||
});
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ function TestDescription(aType, aTcpAddress, aTcpPort) {
|
|||
this.tcpAddress = Cc["@mozilla.org/array;1"]
|
||||
.createInstance(Ci.nsIMutableArray);
|
||||
for (let address of aTcpAddress) {
|
||||
let wrapper = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
let wrapper = Cc["@mozilla.org/supports-cstring;1"]
|
||||
.createInstance(Ci.nsISupportsCString);
|
||||
wrapper.data = address;
|
||||
this.tcpAddress.appendElement(wrapper, false);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ function testPresentationServer() {
|
|||
this.status = 'onOffer';
|
||||
|
||||
let offer = aOffer.QueryInterface(Ci.nsIPresentationChannelDescription);
|
||||
Assert.strictEqual(offer.tcpAddress.queryElementAt(0,Ci.nsISupportsString).data,
|
||||
Assert.strictEqual(offer.tcpAddress.queryElementAt(0,Ci.nsISupportsCString).data,
|
||||
OFFER_ADDRESS,
|
||||
'expected offer address array');
|
||||
Assert.equal(offer.tcpPort, OFFER_PORT, 'expected offer port');
|
||||
|
@ -148,7 +148,7 @@ function testPresentationServer() {
|
|||
Assert.equal(this.status, 'opened', '2. presenterControlChannel: get answer, close channel');
|
||||
|
||||
let answer = aAnswer.QueryInterface(Ci.nsIPresentationChannelDescription);
|
||||
Assert.strictEqual(answer.tcpAddress.queryElementAt(0,Ci.nsISupportsString).data,
|
||||
Assert.strictEqual(answer.tcpAddress.queryElementAt(0,Ci.nsISupportsCString).data,
|
||||
ANSWER_ADDRESS,
|
||||
'expected answer address array');
|
||||
Assert.equal(answer.tcpPort, ANSWER_PORT, 'expected answer port');
|
||||
|
|
Загрузка…
Ссылка в новой задаче