Backed out changeset d8c4ca787e39 (bug 865652) for xpcshell failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 26 Apr 2013 11:30:40 -0400
changeset 129946 10c026f436ed4503950c0c1331132e6580d41aeb
parent 129945 d4e57a4a2fcd8b6edcb3cf12e2a00d2629e39f2f
child 129947 d168bdf3730ad9e5637b7d2260ed6a746a1c924d
push id1552
push userttaubert@mozilla.com
push dateSat, 27 Apr 2013 15:33:29 +0000
treeherderfx-team@40dafc376794 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs865652
milestone23.0a1
backs outd8c4ca787e3926ef543331a7e7d22f4bce10c3bb
Backed out changeset d8c4ca787e39 (bug 865652) for xpcshell failures.
dom/network/tests/unit/test_multisend.js
dom/network/tests/unit/xpcshell.ini
netwerk/base/src/ArrayBufferInputStream.cpp
netwerk/base/src/ArrayBufferInputStream.h
deleted file mode 100644
--- 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
--- a/dom/network/tests/unit/xpcshell.ini
+++ b/dom/network/tests/unit/xpcshell.ini
@@ -1,6 +1,5 @@
 [DEFAULT]
 head =
 tail =
 
 [test_tcpsocket.js]
-[test_multisend.js]
\ No newline at end of file
--- a/netwerk/base/src/ArrayBufferInputStream.cpp
+++ b/netwerk/base/src/ArrayBufferInputStream.cpp
@@ -11,17 +11,16 @@
 NS_IMPL_ISUPPORTS2(ArrayBufferInputStream, nsIArrayBufferInputStream, nsIInputStream);
 
 ArrayBufferInputStream::ArrayBufferInputStream()
 : mRt(nullptr)
 , mArrayBuffer(JSVAL_VOID)
 , mBuffer(nullptr)
 , mBufferLength(0)
 , mOffset(0)
-, mPos(0)
 , mClosed(false)
 {
 }
 
 ArrayBufferInputStream::~ArrayBufferInputStream()
 {
   if (mRt) {
     JS_RemoveValueRootRT(mRt, &mArrayBuffer);
@@ -61,53 +60,53 @@ ArrayBufferInputStream::Close()
 }
 
 NS_IMETHODIMP
 ArrayBufferInputStream::Available(uint64_t* aCount)
 {
   if (mClosed) {
     return NS_BASE_STREAM_CLOSED;
   }
-  *aCount = mBufferLength - mPos;
+  *aCount = mBufferLength - mOffset;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ArrayBufferInputStream::Read(char* aBuf, uint32_t aCount, uint32_t *aReadCount)
 {
   return ReadSegments(NS_CopySegmentToBuffer, aBuf, aCount, aReadCount);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 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;
   }
 
   if (aCount > remaining) {
     aCount = remaining;
   }
-  nsresult rv = writer(this, closure, (char*)(mBuffer + mOffset),
-                       mPos, aCount, result);
+  nsresult rv = writer(this, closure, reinterpret_cast<char*>(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;
 }
 
 NS_IMETHODIMP
 ArrayBufferInputStream::IsNonBlocking(bool *aNonBlocking)
 {
--- a/netwerk/base/src/ArrayBufferInputStream.h
+++ b/netwerk/base/src/ArrayBufferInputStream.h
@@ -28,13 +28,12 @@ public:
   NS_DECL_NSIINPUTSTREAM
 
 private:
   JSRuntime* mRt;
   jsval mArrayBuffer;
   uint8_t* mBuffer;
   uint32_t mBufferLength;
   uint32_t mOffset;
-  uint32_t mPos;
   bool mClosed;
 };
 
 #endif // ArrayBufferInputStream_h