From 3b640bb239793fc6bde3b4487530394ae2ab7306 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Fri, 26 Apr 2013 11:30:40 -0400 Subject: [PATCH] Backed out changeset d8c4ca787e39 (bug 865652) for xpcshell failures. --- dom/network/tests/unit/test_multisend.js | 152 -------------------- dom/network/tests/unit/xpcshell.ini | 1 - netwerk/base/src/ArrayBufferInputStream.cpp | 13 +- netwerk/base/src/ArrayBufferInputStream.h | 1 - 4 files changed, 6 insertions(+), 161 deletions(-) delete mode 100644 dom/network/tests/unit/test_multisend.js diff --git a/dom/network/tests/unit/test_multisend.js b/dom/network/tests/unit/test_multisend.js deleted file mode 100644 index 7f15f4a02f2..00000000000 --- a/dom/network/tests/unit/test_multisend.js +++ /dev/null @@ -1,152 +0,0 @@ -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cr = Components.results; -const Cu = Components.utils; -const CC = Components.Constructor; - -Cu.import("resource://gre/modules/Services.jsm"); - -const ServerSocket = CC("@mozilla.org/network/server-socket;1", - "nsIServerSocket", - "init"), - InputStreamPump = CC("@mozilla.org/network/input-stream-pump;1", - "nsIInputStreamPump", - "init"), - BinaryInputStream = CC("@mozilla.org/binaryinputstream;1", - "nsIBinaryInputStream", - "setInputStream"), - BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1", - "nsIBinaryOutputStream", - "setOutputStream"), - TCPSocket = new (CC("@mozilla.org/tcp-socket;1", - "nsIDOMTCPSocket"))(); - -var server = null, sock = null; - -/** - * Spin up a listening socket and associate at most one live, accepted socket - * with ourselves. - */ -function TestServer() { - this.listener = ServerSocket(-1, true, -1); - do_print('server: listening on', this.listener.port); - this.listener.asyncListen(this); - - this.binaryInput = null; - this.input = null; - this.binaryOutput = null; - this.output = null; - - this.onaccept = null; - this.ondata = null; - this.onclose = null; -} - -TestServer.prototype = { - onSocketAccepted: function(socket, trans) { - if (this.input) - do_throw("More than one live connection!?"); - - do_print('server: got client connection'); - this.input = trans.openInputStream(0, 0, 0); - this.binaryInput = new BinaryInputStream(this.input); - this.output = trans.openOutputStream(0, 0, 0); - this.binaryOutput = new BinaryOutputStream(this.output); - - new InputStreamPump(this.input, -1, -1, 0, 0, false).asyncRead(this, null); - - if (this.onaccept) - this.onaccept(); - else - do_throw("Received unexpected connection!"); - }, - - onStopListening: function(socket) { - }, - - onDataAvailable: function(request, context, inputStream, offset, count) { - var readData = this.binaryInput.readByteArray(count); - if (this.ondata) { - try { - this.ondata(readData); - } catch(ex) { - // re-throw if this is from do_throw - if (ex === Cr.NS_ERROR_ABORT) - throw ex; - // log if there was a test problem - do_print('Caught exception: ' + ex + '\n' + ex.stack); - do_throw('test is broken; bad ondata handler; see above'); - } - } else { - do_throw('Received ' + count + ' bytes of unexpected data!'); - } - }, - - onStartRequest: function(request, context) { - }, - - onStopRequest: function(request, context, status) { - if (this.onclose) - this.onclose(); - else - do_throw("Received unexpected close!"); - }, - - close: function() { - this.binaryInput.close(); - this.binaryOutput.close(); - }, - - /** - * Forget about the socket we knew about before. - */ - reset: function() { - this.binaryInput = null; - this.input = null; - this.binaryOutput = null; - this.output = null; - }, -}; - -function run_test() { - Services.prefs.setBoolPref('dom.mozTCPSocket.enabled', true); - - do_test_pending(); - - server = new TestServer(); - server.reset(); - sock = TCPSocket.open( - '127.0.0.1', server.listener.port, - { binaryType: 'arraybuffer' }); - - var encoder = new TextEncoder(); - var ok = encoder.encode("OKBYE"); - - var expected = ['O', 'K', 'B', 'Y', 'E'] - .map(function(c) { return c.charCodeAt(0); }); - var seenData = []; - - server.onaccept = function() {}; - server.ondata = function(data) { - do_print(data + ":" + data.length); - - seenData = seenData.concat(data); - - if (seenData.length == expected.length) { - do_print(expected); - do_check_eq(seenData.length, expected.length); - for (var i = 0; i < seenData.length; i++) { - do_check_eq(seenData[i], expected[i]); - } - sock.close(); - server.close(); - do_test_finished(); - } - }; - server.onclose = function() {}; - - sock.onopen = function() { - sock.send(ok.buffer, 0, 2); - sock.send(ok.buffer, 2, 3); - }; -} \ No newline at end of file diff --git a/dom/network/tests/unit/xpcshell.ini b/dom/network/tests/unit/xpcshell.ini index 84bb4c13869..a2b586d72a6 100644 --- a/dom/network/tests/unit/xpcshell.ini +++ b/dom/network/tests/unit/xpcshell.ini @@ -3,4 +3,3 @@ head = tail = [test_tcpsocket.js] -[test_multisend.js] \ No newline at end of file diff --git a/netwerk/base/src/ArrayBufferInputStream.cpp b/netwerk/base/src/ArrayBufferInputStream.cpp index 28c8403a9fd..044ab3e1a52 100644 --- a/netwerk/base/src/ArrayBufferInputStream.cpp +++ b/netwerk/base/src/ArrayBufferInputStream.cpp @@ -16,7 +16,6 @@ ArrayBufferInputStream::ArrayBufferInputStream() , mBuffer(nullptr) , mBufferLength(0) , mOffset(0) -, mPos(0) , mClosed(false) { } @@ -66,7 +65,7 @@ ArrayBufferInputStream::Available(uint64_t* aCount) if (mClosed) { return NS_BASE_STREAM_CLOSED; } - *aCount = mBufferLength - mPos; + *aCount = mBufferLength - mOffset; return NS_OK; } @@ -82,13 +81,13 @@ ArrayBufferInputStream::ReadSegments(nsWriteSegmentFun writer, void *closure, uint32_t aCount, uint32_t *result) { NS_ASSERTION(result, "null ptr"); - NS_ASSERTION(mBufferLength >= mPos, "bad stream state"); + NS_ASSERTION(mBufferLength >= mOffset, "bad stream state"); if (mClosed) { return NS_BASE_STREAM_CLOSED; } - uint32_t remaining = mBufferLength - mPos; + uint32_t remaining = mBufferLength - mOffset; if (!remaining) { *result = 0; return NS_OK; @@ -97,12 +96,12 @@ ArrayBufferInputStream::ReadSegments(nsWriteSegmentFun writer, void *closure, if (aCount > remaining) { aCount = remaining; } - nsresult rv = writer(this, closure, (char*)(mBuffer + mOffset), - mPos, aCount, result); + nsresult rv = writer(this, closure, reinterpret_cast(mBuffer + mOffset), + 0, aCount, result); if (NS_SUCCEEDED(rv)) { NS_ASSERTION(*result <= aCount, "writer should not write more than we asked it to write"); - mPos += *result; + mOffset += *result; } return NS_OK; diff --git a/netwerk/base/src/ArrayBufferInputStream.h b/netwerk/base/src/ArrayBufferInputStream.h index 0565ef9035b..21b0caa5284 100644 --- a/netwerk/base/src/ArrayBufferInputStream.h +++ b/netwerk/base/src/ArrayBufferInputStream.h @@ -33,7 +33,6 @@ private: uint8_t* mBuffer; uint32_t mBufferLength; uint32_t mOffset; - uint32_t mPos; bool mClosed; };