mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1210330 - TCPSocket data event should be an ArrayBuffer in non-e10s case too. r=jdm
The conversion to WebIDL introduced a minor regression where the "data" event carried a Uint8Array payload instead of an ArrayBuffer. This patch corrects the type and introduces a fix.
This commit is contained in:
parent
8ff287ea02
commit
dd110fee88
@ -1040,7 +1040,7 @@ TCPSocket::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext, nsIInput
|
||||
JSContext* cx = api.cx();
|
||||
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
if (!ToJSValue(cx, TypedArrayCreator<Uint8Array>(buffer), &value)) {
|
||||
if (!ToJSValue(cx, TypedArrayCreator<ArrayBuffer>(buffer), &value)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
FireDataEvent(cx, NS_LITERAL_STRING("data"), value);
|
||||
|
@ -1,4 +1,6 @@
|
||||
this.EXPORTED_SYMBOLS = ['createSocket', 'createServer', 'enablePrefsAndPermissions'];
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
'createSocket', 'createServer', 'enablePrefsAndPermissions',
|
||||
'socketCompartmentInstanceOfArrayBuffer'];
|
||||
|
||||
this.createSocket = function(host, port, options) {
|
||||
return new TCPSocket(host, port, options);
|
||||
@ -11,3 +13,8 @@ this.createServer = function(port, options, backlog) {
|
||||
this.enablePrefsAndPermissions = function() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// See test_tcpsocket_client_and_server_basics.html's version for rationale.
|
||||
this.socketCompartmentInstanceOfArrayBuffer = function(obj) {
|
||||
return obj instanceof ArrayBuffer;
|
||||
}
|
||||
|
@ -25,6 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1084245
|
||||
function enablePrefsAndPermissions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// In the JSM case, ArrayBuffers will be created in the compartment of the
|
||||
// JSM with different globals than the
|
||||
// test_tcpsocket_client_and_server_basics.js test logic sees, so we (and
|
||||
// tcpsocket_test.jsm) need to do something. To avoid complexity relating
|
||||
// to wrappers and the varying nuances of the module scope and global scope
|
||||
// in JSM's (they differ on B2G), we hardcode ArrayBuffer rather than taking
|
||||
// a string that we look up, etc.
|
||||
function socketCompartmentInstanceOfArrayBuffer(obj) {
|
||||
return obj instanceof ArrayBuffer;
|
||||
}
|
||||
</script>
|
||||
<script type="application/javascript;version=1.7" src="test_tcpsocket_client_and_server_basics.js"></script>
|
||||
</head>
|
||||
|
@ -55,6 +55,8 @@ function listenForEventsOnSocket(socket, socketType) {
|
||||
socket.ondata = function(event) {
|
||||
dump('(' + socketType + ' event: ' + event.type + ' length: ' +
|
||||
event.data.byteLength + ')\n');
|
||||
ok(socketCompartmentInstanceOfArrayBuffer(event.data),
|
||||
'payload is ArrayBuffer');
|
||||
var arr = new Uint8Array(event.data);
|
||||
if (receivedData === null) {
|
||||
receivedData = arr;
|
||||
|
Loading…
Reference in New Issue
Block a user