Bug 1335645 - Part 3 - Stop server at the end of the test draft
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 27 Feb 2017 19:07:58 +0100
changeset 490139 55ff502b13f7deda0f03586ffb15a4133bea0c95
parent 487063 24931c1b6d9e5c0b1e496a2428f2012428715956
child 490140 216349aeef2b6f3b2e83c78cd2adb5687b71708e
push id47011
push uservalentin.gosu@gmail.com
push dateMon, 27 Feb 2017 18:38:56 +0000
bugs1335645
milestone54.0a1
Bug 1335645 - Part 3 - Stop server at the end of the test MozReview-Commit-ID: E3iFR25vayR
netwerk/test/unit/test_bug561042.js
--- a/netwerk/test/unit/test_bug561042.js
+++ b/netwerk/test/unit/test_bug561042.js
@@ -1,8 +1,14 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 
 const SERVER_PORT = 8080;
 const baseURL = "http://localhost:" + SERVER_PORT + "/";
 
 var cookie = "";
 for (let i =0; i < 10000; i++) {
@@ -13,23 +19,23 @@ var listener = {
   onStartRequest: function (request, ctx) {
   },
 
   onDataAvailable: function (request, ctx, stream) {
   },
 
   onStopRequest: function (request, ctx, status) {
       do_check_eq(status, Components.results.NS_OK);
-      do_test_finished();
+      server.stop(do_test_finished);
   },
 
 };
 
+var server = new HttpServer();
 function run_test() {
-    var server = new HttpServer();
     server.start(SERVER_PORT);
     server.registerPathHandler('/', function(metadata, response) {
         response.setStatusLine(metadata.httpVersion, 200, "OK");
         response.setHeader("Set-Cookie", "BigCookie=" + cookie, false);
         response.write("Hello world");
     });
     var chan = NetUtil.newChannel({uri: baseURL, loadUsingSystemPrincipal: true})
                       .QueryInterface(Components.interfaces.nsIHttpChannel);