[mq]: overpatch.patch draft
authorValentin Gosu <valentin.gosu@gmail.com>
Fri, 20 May 2016 02:56:17 +0200
changeset 368992 0d86e9623e2e095ad1303c5c459201e017076df8
parent 368991 ad706c54a6a1f165f7b9225f802cfa4e31822eff
child 521419 71c262182bb54b073e942f4b6bfd331a9db54d9e
push id18689
push uservalentin.gosu@gmail.com
push dateFri, 20 May 2016 00:56:51 +0000
milestone49.0a1
[mq]: overpatch.patch MozReview-Commit-ID: 4Yu2Qj7DYQJ
netwerk/test/unit/test_alt-data_concurrent.js
netwerk/test/unit/test_alt-data_large.js
copy from netwerk/test/unit/test_alt-data_simple.js
copy to netwerk/test/unit/test_alt-data_concurrent.js
--- a/netwerk/test/unit/test_alt-data_simple.js
+++ b/netwerk/test/unit/test_alt-data_concurrent.js
@@ -61,41 +61,56 @@ function run_test()
 
   var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
   cc.preferAlternativeDataType(altContentType);
 
   chan.asyncOpen2(new ChannelListener(readServerContent, null));
   do_test_pending();
 }
 
+var altStream1 = null;
+
 function readServerContent(request, buffer)
 {
   var cc = request.QueryInterface(Ci.nsICacheInfoChannel);
 
   do_check_eq(buffer, responseContent);
   do_check_eq(cc.alternativeDataType, "");
 
-  var os = cc.openAlternativeOutputStream(altContentType);
-  os.write(altContent, altContent.length);
-  os.close();
+  altStream1 = cc.openAlternativeOutputStream(altContentType);
 
-  cacheFlushObserver = { observe: function() {
-    cacheFlushObserver = null;
+  // Open new channel
+  var chan2 = make_channel(URL);
+  var cc2 = chan.QueryInterface(Ci.nsICacheInfoChannel);
+  cc2.preferAlternativeDataType(altContentType);
+  chan2.asyncOpen2(new ChannelListener(readServerContent2, null));
+
+}
+
+function readServerContent2(request, buffer)
+{
+  var cc = request.QueryInterface(Ci.nsICacheInfoChannel);
 
-    var chan = make_channel(URL);
-    var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
-    cc.preferAlternativeDataType(altContentType);
+  do_check_eq(buffer, responseContent);
+  do_check_eq(cc.alternativeDataType, "");
+
+  // TODO: should this fail if there's another stream open?
+  //       in e10s this is hard to determine. will it fail asyncly?
+  var altStream2 = cc.openAlternativeOutputStream(altContentType);
 
-    chan.asyncOpen2(new ChannelListener(readAltContent, null));
-  }};
+  altStream1.write(altContent, altContent.length);
+  altStream1.close();
 
-  // we may need some gc() calls first here...
-  // check one of test_cache2-26-no-outputstream-open.js or test_cache2-30c-pinning-deferred-doom.js
-  // but the entry is inside the channel, so probably no need to...
-  do_execute_soon(() => Services.cache2.QueryInterface(Ci.nsICacheTesting).flush(cacheFlushObserver));
+  altStream2.write(altContent, altContent.length);
+  altStream2.close();
+
+  var chan = make_channel(URL);
+  var cc2 = chan.QueryInterface(Ci.nsICacheInfoChannel);
+  cc2.preferAlternativeDataType(altContentType);
+  chan.asyncOpen2(new ChannelListener(readAltContent, null));
 }
 
 function readAltContent(request, buffer)
 {
   var cc = request.QueryInterface(Ci.nsICacheInfoChannel);
 
   do_check_eq(servedNotModified, true);
   do_check_eq(cc.alternativeDataType, altContentType);
copy from netwerk/test/unit/test_alt-data_simple.js
copy to netwerk/test/unit/test_alt-data_large.js
--- a/netwerk/test/unit/test_alt-data_simple.js
+++ b/netwerk/test/unit/test_alt-data_large.js
@@ -9,28 +9,28 @@
  * - this time the alt data must arive
  */
 
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "URL", function() {
-  return "http://localhost:" + httpServer.identity.primaryPort + "/content";
+  return "http://localhost:" + httpServer.identity.primaryPort + "/content-large";
 });
 
 var httpServer = null;
 var cacheFlushObserver; // needs to be rooted
 
 function make_channel(url, callback, ctx) {
   return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
 }
 
-const responseContent = "response body";
-const altContent = "!@#$%^&*()";
+const responseContent = "a".repeat(1234567);
+const altContent = "B".repeat(1234567);
 const altContentType = "text/binary";
 
 var servedNotModified = false;
 
 function contentHandler(metadata, response)
 {
   response.setHeader("Content-Type", "text/plain");
   response.setHeader("Cache-Control", "no-cache");