1
1
var hasModule = typeof Module === 'object' && Module ;
2
2
3
- /**
4
- * @param {number= } port
5
- */
6
- function reportResultToServer ( result , port ) {
7
- port = port || 8888 ;
3
+ var reportingURL = 'http://localhost:8888/' ;
4
+
5
+ function reportResultToServer ( result ) {
8
6
if ( reportResultToServer . reported ) {
9
7
// Only report one result per test, even if the test misbehaves and tries to report more.
10
8
reportErrorToServer ( `excessive reported results, sending ${ result } , test will fail` ) ;
@@ -14,7 +12,7 @@ function reportResultToServer(result, port) {
14
12
out ( `RESULT: ${ result } ` ) ;
15
13
} else {
16
14
let doFetch = typeof origFetch != 'undefined' ? origFetch : fetch ;
17
- doFetch ( `http://localhost: ${ port } /report_result?${ encodeURIComponent ( result ) } ` ) . then ( ( ) => {
15
+ doFetch ( `${ reportingURL } /report_result?${ encodeURIComponent ( result ) } ` ) . then ( ( ) => {
18
16
if ( typeof window === 'object' && window && hasModule && ! Module [ 'pageThrewException' ] ) {
19
17
/* for easy debugging, don't close window on failure */
20
18
window . close ( ) ;
@@ -24,26 +22,24 @@ function reportResultToServer(result, port) {
24
22
}
25
23
26
24
function sendFileToServer ( filename , contents ) {
27
- fetch ( `http://localhost:8888 /?file=${ encodeURIComponent ( filename ) } ` , { method : "POST" , body : contents } ) ;
25
+ fetch ( `${ reportingURL } /?file=${ encodeURIComponent ( filename ) } ` , { method : "POST" , body : contents } ) ;
28
26
}
29
27
30
- /**
31
- * @param {number= } port
32
- */
33
- function maybeReportResultToServer ( result , port ) {
34
- if ( reportResultToServer . reported ) return ;
35
- reportResultToServer ( result , port ) ;
28
+ function maybeReportResultToServer ( result ) {
29
+ if ( ! reportResultToServer . reported ) {
30
+ reportResultToServer ( result ) ;
31
+ }
36
32
}
37
33
38
34
function reportErrorToServer ( message ) {
39
35
if ( typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE ) {
40
36
err ( message ) ;
41
37
} else {
42
- fetch ( `http://localhost:8888 ?stderr=${ encodeURIComponent ( message ) } ` ) ;
38
+ fetch ( `${ reportingURL } ?stderr=${ encodeURIComponent ( message ) } ` ) ;
43
39
}
44
40
}
45
41
46
- function report_error ( e ) {
42
+ function reportError ( e ) {
47
43
// MINIMAL_RUNTIME doesn't handle exit or call the below onExit handler
48
44
// so we detect the exit by parsing the uncaught exception message.
49
45
var message = e . message || e ;
@@ -68,9 +64,9 @@ function report_error(e) {
68
64
69
65
if ( typeof window === 'object' && window ) {
70
66
window . addEventListener ( 'error' , event => {
71
- report_error ( event . error || event )
67
+ reportError ( event . error || event )
72
68
} ) ;
73
- window . addEventListener ( 'unhandledrejection' , event => report_error ( event . reason ) ) ;
69
+ window . addEventListener ( 'unhandledrejection' , event => reportError ( event . reason ) ) ;
74
70
}
75
71
76
72
if ( hasModule ) {
0 commit comments