18
18
'use strict' ;
19
19
20
20
const AdmZip = require ( 'adm-zip' ) ,
21
- AdmConstants = require ( 'adm-zip/util/constants' ) ,
22
21
fs = require ( 'fs' ) ,
23
22
path = require ( 'path' ) ,
24
23
url = require ( 'url' ) ,
@@ -36,36 +35,69 @@ const httpUtil = require('../http/util'),
36
35
37
36
38
37
/**
39
- * Configuration options for a DriverService instance.
38
+ * A record object that defines the configuration options for a DriverService
39
+ * instance.
40
40
*
41
- * - `loopback` - Whether the service should only be accessed on this host's
42
- * loopback address.
43
- * - `hostname` - The host name to access the server on. If this option is
44
- * specified, the `loopback` option will be ignored.
45
- * - `port` - The port to start the server on (must be > 0). If the port is
46
- * provided as a promise, the service will wait for the promise to resolve
47
- * before starting.
48
- * - `args` - The arguments to pass to the service. If a promise is provided,
49
- * the service will wait for it to resolve before starting.
50
- * - `path` - The base path on the server for the WebDriver wire protocol
51
- * (e.g. '/wd/hub'). Defaults to '/'.
52
- * - `env` - The environment variables that should be visible to the server
53
- * process. Defaults to inheriting the current process's environment.
54
- * - `stdio` - IO configuration for the spawned server process. For more
55
- * information, refer to the documentation of `child_process.spawn`.
41
+ * @record
42
+ */
43
+ function ServiceOptions ( ) { }
44
+
45
+ /**
46
+ * Whether the service should only be accessed on this host's loopback address.
56
47
*
57
- * @typedef {{
58
- * loopback: (boolean|undefined),
59
- * hostname: (string|undefined),
60
- * port: (number|!promise.Promise<number>),
61
- * args: !(Array<string>|promise.Promise<!Array<string>>),
62
- * path: (string|undefined|null),
63
- * env: (Object<string, string>|undefined),
64
- * stdio: (string|!Array<string|number|!stream.Stream|null|undefined>|
65
- * undefined)
66
- * }}
48
+ * @type {(boolean|undefined) }
49
+ */
50
+ ServiceOptions . prototype . loopback ;
51
+
52
+ /**
53
+ * The host name to access the server on. If this option is specified, the
54
+ * {@link #loopback} option will be ignored.
55
+ *
56
+ * @type {(string|undefined) }
57
+ */
58
+ ServiceOptions . prototype . hostname ;
59
+
60
+ /**
61
+ * The port to start the server on (must be > 0). If the port is provided as a
62
+ * promise, the service will wait for the promise to resolve before starting.
63
+ *
64
+ * @type {(number|!promise.Promise<number>) }
65
+ */
66
+ ServiceOptions . prototype . port ;
67
+
68
+ /**
69
+ * The arguments to pass to the service. If a promise is provided, the service
70
+ * will wait for it to resolve before starting.
71
+ *
72
+ * @type {!(Array<string>|promise.Promise<!Array<string>>) }
73
+ */
74
+ ServiceOptions . prototype . args ;
75
+
76
+ /**
77
+ * The base path on the server for the WebDriver wire protocol (e.g. '/wd/hub').
78
+ * Defaults to '/'.
79
+ *
80
+ * @type {(string|undefined|null) }
81
+ */
82
+ ServiceOptions . prototype . path ;
83
+
84
+ /**
85
+ * The environment variables that should be visible to the server process.
86
+ * Defaults to inheriting the current process's environment.
87
+ *
88
+ * @type {(Object<string, string>|undefined) }
89
+ */
90
+ ServiceOptions . prototype . env ;
91
+
92
+ /**
93
+ * IO configuration for the spawned server process. For more information, refer
94
+ * to the documentation of `child_process.spawn`.
95
+ *
96
+ * @type {(string|!Array<string|number|!stream.Stream|null|undefined>|
97
+ * undefined)}
98
+ * @see https://nodejs.org/dist/latest-v4.x/docs/api/child_process.html#child_process_options_stdio
67
99
*/
68
- var ServiceOptions ;
100
+ ServiceOptions . prototype . stdio ;
69
101
70
102
71
103
/**
@@ -358,7 +390,8 @@ class FileDetector extends input.FileDetector {
358
390
359
391
var zip = new AdmZip ( ) ;
360
392
zip . addLocalFile ( filePath ) ;
361
- zip . getEntries ( ) [ 0 ] . header . method = AdmConstants . STORED ;
393
+ // Stored compression, see https://en.wikipedia.org/wiki/Zip_(file_format)
394
+ zip . getEntries ( ) [ 0 ] . header . method = 0 ;
362
395
363
396
var command = new cmd . Command ( cmd . Name . UPLOAD_FILE )
364
397
. setParameter ( 'file' , zip . toBuffer ( ) . toString ( 'base64' ) ) ;
@@ -379,3 +412,4 @@ class FileDetector extends input.FileDetector {
379
412
exports . DriverService = DriverService ;
380
413
exports . FileDetector = FileDetector ;
381
414
exports . SeleniumServer = SeleniumServer ;
415
+ exports . ServiceOptions = ServiceOptions ; // Exported for API docs.
0 commit comments