Bug 1499917 - Read entire length of expected string from the stream r=michal
authorValentin Gosu <valentin.gosu@gmail.com>
Fri, 19 Oct 2018 18:00:50 +0000
changeset 490543 106c2a54ae6a95718cbb8bfb7a9453e1fefa5027
parent 490542 655818c009b19ac39ac6b69f2e76473976fdaaeb
child 490544 bbe0e551c44db6dffda2bb64e2e6a6715e5f7347
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersmichal
bugs1499917
milestone64.0a1
Bug 1499917 - Read entire length of expected string from the stream r=michal The test ocasionally fails out in e10s mode, because stream.available() might not return the entire string length (it's async). So the child process needs to wait for all of the bytes to be read. Differential Revision: https://phabricator.services.mozilla.com/D9274
netwerk/test/unit/test_alt-data_simple.js
--- a/netwerk/test/unit/test_alt-data_simple.js
+++ b/netwerk/test/unit/test_alt-data_simple.js
@@ -150,17 +150,19 @@ function readAltContent(request, buffer)
   Assert.equal(servedNotModified, true);
   Assert.equal(cc.alternativeDataType, altContentType);
   Assert.equal(buffer, altContent);
   check_has_alt_data_in_index(true);
 
   cc.getOriginalInputStream({
     onInputStreamReady: function(aInputStream) {
       executeSoon(function() {
-        let originalData = read_stream(aInputStream, aInputStream.available());
+        // We expect the async stream length to match the expected content.
+        // If the test times out, it's probably because of this.
+        let originalData = read_stream(aInputStream, responseContent.length);
         Assert.equal(originalData, responseContent);
         requestAgain();
       });
     }
   });
 }
 
 function requestAgain()