6
6
7
7
// We expect these to be defined in the global scope by runtest.py.
8
8
/* global __LOCATION__, _PROFILE_PATH, _SERVER_PORT, _SERVER_ADDR, _DISPLAY_RESULTS,
9
- _TEST_PREFIX */
9
+ _TEST_PREFIX, _HTTPD_PATH */
10
10
// Defined by xpcshell
11
11
/* global quit */
12
12
13
- /* import-globals-from ../../netwerk/test/httpserver/httpd.js */
14
13
/* eslint-disable mozilla/use-chromeutils-generateqi */
15
14
16
15
// Set up a protocol substituion so that we can load the httpd.js file.
17
16
let protocolHandler = Services . io
18
17
. getProtocolHandler ( "resource" )
19
18
. QueryInterface ( Ci . nsIResProtocolHandler ) ;
20
- let httpdJSPath = __LOCATION__ . parent ;
21
- let modulesURI = Services . io . newFileURI ( httpdJSPath ) ;
22
- protocolHandler . setSubstitution ( "mochitest-server" , modulesURI ) ;
19
+ let httpdJSPath = PathUtils . toFileURI ( _HTTPD_PATH ) ;
20
+ protocolHandler . setSubstitution (
21
+ "httpd-server" ,
22
+ Services . io . newURI ( httpdJSPath )
23
+ ) ;
24
+
25
+ const { HttpServer, dumpn, setDebuggingStatus } = ChromeUtils . import (
26
+ "resource://httpd-server/httpd.js"
27
+ ) ;
28
+
29
+ protocolHandler . setSubstitution (
30
+ "mochitest-server" ,
31
+ Services . io . newFileURI ( __LOCATION__ . parent )
32
+ ) ;
23
33
24
34
/* import-globals-from mochitestListingsUtils.js */
25
35
Services . scriptloader . loadSubScript (
26
36
"resource://mochitest-server/mochitestListingsUtils.js" ,
27
37
this
28
38
) ;
29
39
40
+ const CC = Components . Constructor ;
41
+
42
+ const FileInputStream = CC (
43
+ "@mozilla.org/network/file-input-stream;1" ,
44
+ "nsIFileInputStream" ,
45
+ "init"
46
+ ) ;
47
+ const ConverterInputStream = CC (
48
+ "@mozilla.org/intl/converter-input-stream;1" ,
49
+ "nsIConverterInputStream" ,
50
+ "init"
51
+ ) ;
52
+
30
53
// Disable automatic network detection, so tests work correctly when
31
54
// not connected to a network.
32
55
// eslint-disable-next-line mozilla/use-services
@@ -43,24 +66,21 @@ function serverStopped() {
43
66
_quitting = true ;
44
67
}
45
68
46
- // only run the "main" section if httpd.js was loaded ahead of us
47
- if ( this . nsHttpServer ) {
48
- //
49
- // SCRIPT CODE
50
- //
51
- runServer ( ) ;
52
-
53
- // We can only have gotten here if the /server/shutdown path was requested.
54
- if ( _quitting ) {
55
- dumpn ( "HTTP server stopped, all pending requests complete" ) ;
56
- quit ( 0 ) ;
57
- }
69
+ //
70
+ // SCRIPT CODE
71
+ //
72
+ runServer ( ) ;
58
73
59
- // Impossible as the stop callback should have been called, but to be safe...
60
- dumpn ( "TEST-UNEXPECTED-FAIL | failure to correctly shut down HTTP server" ) ;
61
- quit ( 1 ) ;
74
+ // We can only have gotten here if the /server/shutdown path was requested.
75
+ if ( _quitting ) {
76
+ dumpn ( "HTTP server stopped, all pending requests complete" ) ;
77
+ quit ( 0 ) ;
62
78
}
63
79
80
+ // Impossible as the stop callback should have been called, but to be safe...
81
+ dumpn ( "TEST-UNEXPECTED-FAIL | failure to correctly shut down HTTP server" ) ;
82
+ quit ( 1 ) ;
83
+
64
84
var serverBasePath ;
65
85
var displayResults = true ;
66
86
@@ -170,7 +190,7 @@ function runServer() {
170
190
171
191
/** Creates and returns an HTTP server configured to serve Mochitests. */
172
192
function createMochitestServer ( serverBasePath ) {
173
- var server = new nsHttpServer ( ) ;
193
+ var server = new HttpServer ( ) ;
174
194
175
195
server . registerDirectory ( "/" , serverBasePath ) ;
176
196
server . registerPathHandler ( "/server/shutdown" , serverShutdown ) ;
@@ -308,16 +328,13 @@ function serverDebug(metadata, response) {
308
328
if ( metadata . queryString === "0" ) {
309
329
// do this now so it gets logged with the old mode
310
330
dumpn ( "Server debug logs disabled." ) ;
311
- DEBUG = false ;
312
- DEBUG_TIMESTAMP = false ;
331
+ setDebuggingStatus ( false , false ) ;
313
332
mode = "disabled" ;
314
333
} else if ( metadata . queryString === "1" ) {
315
- DEBUG = true ;
316
- DEBUG_TIMESTAMP = false ;
334
+ setDebuggingStatus ( true , false ) ;
317
335
mode = "enabled" ;
318
336
} else if ( metadata . queryString === "2" ) {
319
- DEBUG = true ;
320
- DEBUG_TIMESTAMP = true ;
337
+ setDebuggingStatus ( true , true ) ;
321
338
mode = "enabled, with timestamps" ;
322
339
} else {
323
340
return ;
0 commit comments