Back out 3aa8e0293d5f for causing perma-orange on xpcshell debug. a=bustage
authorDan Witte <dwitte@mozilla.com>
Fri, 12 Nov 2010 10:13:34 -0800
changeset 57412 81f4de31f19e0aeb2343b07b4c7398805c147606
parent 57411 0525032a59a37de7f8b4cec557b7056d16c8c726
child 57413 b22e3d33e8b1b60d13f01ab1a1d36546f62cbf22
push id16912
push userdwitte@mozilla.com
push dateFri, 12 Nov 2010 18:14:09 +0000
treeherdermozilla-central@81f4de31f19e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
milestone2.0b8pre
backs out3aa8e0293d5feae8cd397811a0e8e520ff238c50
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out 3aa8e0293d5f for causing perma-orange on xpcshell debug. a=bustage
netwerk/test/unit/test_bug596443.js
--- a/netwerk/test/unit/test_bug596443.js
+++ b/netwerk/test/unit/test_bug596443.js
@@ -1,108 +1,100 @@
 do_load_httpd_js();
 var httpserver = new nsHttpServer();
 
 function getCacheService() {
     return Components.classes["@mozilla.org/network/cache-service;1"]
             .getService(Components.interfaces.nsICacheService);
 }
 
-function setupChannel(suffix, xRequest, flags) {
+function setupChannel(suffix, flags) {
     var ios = Components.classes["@mozilla.org/network/io-service;1"]
             .getService(Ci.nsIIOService);
     var chan = ios.newChannel("http://localhost:4444" + suffix, "", null);
     if (flags)
         chan.loadFlags |= flags;
-
-    var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
-    httpChan.setRequestHeader("x-request", xRequest, false);
-        
-    return httpChan;
+    return chan;
 }
 
-function Listener(response, finalResponse, chainedHandler) {
+function Listener(response, finalResponse) {
     this._response = response;
     this._finalResponse = finalResponse;
-    this._chainedHandler = chainedHandler;
 }
 Listener.prototype = {
     _response: null,
     _buffer: null,
     _finalResponse: false,
-    _chainedHandler: undefined,
 
     QueryInterface: function(iid) {
         if (iid.equals(Components.interfaces.nsIStreamListener) ||
             iid.equals(Components.interfaces.nsIRequestObserver) ||
             iid.equals(Components.interfaces.nsISupports))
           return this;
         throw Components.results.NS_ERROR_NO_INTERFACE;
     },
 
     onStartRequest: function (request, ctx) {
         this._buffer = "";
     },
     onDataAvailable: function (request, ctx, stream, offset, count) {
         this._buffer = this._buffer.concat(read_stream(stream, count));
     },
     onStopRequest: function (request, ctx, status) {
-        do_check_eq(this._buffer, this._response);
+        var expected = "Response"+this._response;
+        do_check_eq(this._buffer, expected);
         if (this._finalResponse)
             do_timeout(10, function() {
                         httpserver.stop(do_test_finished);
                     });
-        if (this._chainedHandler != undefined)
-            do_timeout(10, handlers[this._chainedHandler]);
     }
 };
 
 function run_test() {
     httpserver.registerPathHandler("/bug596443", handler);
     httpserver.start(4444);
 
     // make sure we have a profile so we can use the disk-cache
     do_get_profile();
 
     // clear cache
     getCacheService().evictEntries(
             Components.interfaces.nsICache.STORE_ANYWHERE);
 
-    var ch0 = setupChannel("/bug596443", "Response0", Ci.nsIRequest.LOAD_BYPASS_CACHE);
-    ch0.asyncOpen(new Listener("Response0", false), null);
+    var ch0 = setupChannel("/bug596443", Ci.nsIRequest.LOAD_BYPASS_CACHE);
+    ch0.asyncOpen(new Listener(0), null);
 
-    var ch1 = setupChannel("/bug596443", "Response1", Ci.nsIRequest.LOAD_BYPASS_CACHE);
-    ch1.asyncOpen(new Listener("Response1", false, 0), null);
+    var ch1 = setupChannel("/bug596443", Ci.nsIRequest.LOAD_BYPASS_CACHE);
+    ch1.asyncOpen(new Listener(1), null);
 
-    var ch2 = setupChannel("/bug596443", "Should not be used");
-    ch2.asyncOpen(new Listener("Response1", true), null); // Note param: we expect this to come from cache
+    var ch2 = setupChannel("/bug596443");
+    ch2.asyncOpen(new Listener(1, true), null); // Note param: we expect this to come from cache
 
     do_test_pending();
 }
 
-// Sequence is as follows:
-//   we trigger the handler for the second request
-//   Necko will call CacheEntryAvailable, making the third request finish
-//   before finishing, handler for second req triggers handler for first req
-// 
 function triggerHandlers() {
-    do_timeout(100, handlers[1]);
+    do_timeout(100, function() {
+        do_timeout(100, initialHandlers[1]);
+        do_timeout(100, initialHandlers[0]);
+    });
 }
 
-var handlers = [];
+var initialHandlers = [];
+var handlerNo = 0;
 function handler(metadata, response) {
     var func = function(body) {
         return function() {
             response.setStatusLine(metadata.httpVersion, 200, "Ok");
             response.setHeader("Content-Type", "text/plain", false);
             response.setHeader("Content-Length", "" + body.length, false);
             response.setHeader("Cache-Control", "max-age=600", false);
             response.bodyOutputStream.write(body, body.length);
             response.finish();
          }};
 
     response.processAsync();
-    var request = metadata.getHeader("x-request");
-    handlers.push(func(request));
+    initialHandlers[handlerNo] = func("Response"+handlerNo);
+    handlerNo++;
 
-    if (handlers.length > 1)
+    if (handlerNo > 1)
         triggerHandlers();
 }