selenium-webdriver 4.0.0-alpha.3 → 4.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGES.md +9 -2
  2. package/README.md +2 -4
  3. package/chrome.js +19 -527
  4. package/chromium.js +762 -0
  5. package/edge.js +97 -58
  6. package/firefox.js +23 -5
  7. package/http/index.js +4 -0
  8. package/io/index.js +1 -1
  9. package/lib/actions.js +1 -1
  10. package/lib/atoms/get-attribute.js +1 -2
  11. package/lib/atoms/is-displayed.js +5 -6
  12. package/lib/atoms/make-atoms-module.js +17 -0
  13. package/lib/capabilities.js +17 -4
  14. package/lib/command.js +1 -0
  15. package/lib/http.js +8 -3
  16. package/lib/input.js +6 -6
  17. package/lib/logging.js +1 -1
  18. package/lib/webdriver.js +33 -3
  19. package/net/portprober.js +1 -1
  20. package/package.json +8 -9
  21. package/BUILD.bazel +0 -88
  22. package/example/chrome_android.js +0 -42
  23. package/example/chrome_mobile_emulation.js +0 -42
  24. package/example/firefox_channels.js +0 -77
  25. package/example/google_search.js +0 -50
  26. package/example/google_search_test.js +0 -72
  27. package/example/headless.js +0 -55
  28. package/example/logging.js +0 -68
  29. package/jasmine.json +0 -11
  30. package/lib/atoms/BUILD.bazel +0 -28
  31. package/lib/test/bootstrap_jasmine.js +0 -28
  32. package/lib/test/build.js +0 -156
  33. package/lib/test/data/actions/click.html +0 -24
  34. package/lib/test/data/actions/drag.html +0 -77
  35. package/lib/test/data/actions/record_click.html +0 -21
  36. package/lib/test/data/chrome/download.html +0 -2
  37. package/lib/test/data/firefox/webextension.xpi +0 -0
  38. package/lib/test/fileserver.js +0 -337
  39. package/lib/test/httpserver.js +0 -120
  40. package/lib/test/index.js +0 -87
  41. package/lib/test/resources.js +0 -40
  42. package/test/actions_test.js +0 -206
  43. package/test/builder_test.js +0 -106
  44. package/test/chrome/devtools_test.js +0 -93
  45. package/test/chrome/options_test.js +0 -121
  46. package/test/chrome/service_test.js +0 -45
  47. package/test/cookie_test.js +0 -210
  48. package/test/element_finding_test.js +0 -431
  49. package/test/execute_script_test.js +0 -355
  50. package/test/fingerprint_test.js +0 -63
  51. package/test/firefox_test.js +0 -233
  52. package/test/frame_test.js +0 -45
  53. package/test/http/http_test.js +0 -229
  54. package/test/http/util_test.js +0 -178
  55. package/test/io/io_test.js +0 -364
  56. package/test/io/zip_test.js +0 -126
  57. package/test/lib/by_test.js +0 -160
  58. package/test/lib/capabilities_test.js +0 -129
  59. package/test/lib/error_test.js +0 -333
  60. package/test/lib/http_test.js +0 -576
  61. package/test/lib/input_test.js +0 -1379
  62. package/test/lib/logging_test.js +0 -272
  63. package/test/lib/promise_test.js +0 -674
  64. package/test/lib/testutil.js +0 -90
  65. package/test/lib/until_test.js +0 -478
  66. package/test/lib/webdriver_test.js +0 -1692
  67. package/test/logging_test.js +0 -160
  68. package/test/net/index_test.js +0 -60
  69. package/test/net/portprober_test.js +0 -128
  70. package/test/page_loading_test.js +0 -156
  71. package/test/proxy_test.js +0 -167
  72. package/test/rect_test.js +0 -51
  73. package/test/remote_test.js +0 -98
  74. package/test/safari_test.js +0 -44
  75. package/test/stale_element_test.js +0 -60
  76. package/test/upload_test.js +0 -78
  77. package/test/window_test.js +0 -168
  78. package/testing/index.js +0 -498
  79. package/tools/init_jasmine.js +0 -7
@@ -1,28 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- 'use strict';
19
-
20
- /**
21
- * @fileoverview Defines necessary adapaters for jasmine to have an equivalent
22
- * API to mocha.
23
- */
24
-
25
- global.after = global.afterAll;
26
- global.before = global.beforeAll;
27
-
28
- global.jasmine.DEFAULT_TIMEOUT_INTERVAL = 120 * 1000;
package/lib/test/build.js DELETED
@@ -1,156 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- 'use strict';
19
-
20
- const fs = require('fs');
21
- const path = require('path');
22
- const {spawn} = require('child_process');
23
-
24
-
25
- const PROJECT_ROOT = path.normalize(path.join(__dirname, '../../../../..'));
26
- const WORKSPACE_FILE = path.join(PROJECT_ROOT, 'WORKSPACE');
27
-
28
- function isDevMode() {
29
- return fs.existsSync(WORKSPACE_FILE)
30
- }
31
-
32
-
33
- function checkIsDevMode() {
34
- if (!isDevMode()) {
35
- throw Error('Cannot execute build; not running in dev mode');
36
- }
37
- }
38
-
39
-
40
- /**
41
- * Targets that have been previously built.
42
- * @type {!Object}
43
- */
44
- var builtTargets = {};
45
-
46
-
47
- /**
48
- * @param {!Array.<string>} targets The targets to build.
49
- * @throws {Error} If not running in dev mode.
50
- * @constructor
51
- */
52
- var Build = function(targets) {
53
- checkIsDevMode();
54
- this.targets_ = targets;
55
- };
56
-
57
-
58
- /** @private {boolean} */
59
- Build.prototype.cacheResults_ = false;
60
-
61
-
62
- /**
63
- * Configures this build to only execute if it has not previously been
64
- * run during the life of the current process.
65
- * @return {!Build} A self reference.
66
- */
67
- Build.prototype.onlyOnce = function() {
68
- this.cacheResults_ = true;
69
- return this;
70
- };
71
-
72
-
73
- /**
74
- * Executes the build.
75
- * @return {!Promise} A promise that will be resolved when
76
- * the build has completed.
77
- * @throws {Error} If no targets were specified.
78
- */
79
- Build.prototype.go = function() {
80
- var targets = this.targets_;
81
- if (!targets.length) {
82
- throw Error('No targets specified');
83
- }
84
-
85
- // Filter out cached results.
86
- if (this.cacheResults_) {
87
- targets = targets.filter(function(target) {
88
- return !builtTargets.hasOwnProperty(target);
89
- });
90
-
91
- if (!targets.length) {
92
- return Promise.resolve();
93
- }
94
- }
95
-
96
- console.log('\nBuilding', targets.join(' '), '...');
97
-
98
- var cmd, args = targets;
99
- if (process.platform === 'win32') {
100
- cmd = 'cmd.exe';
101
- args.unshift('/c', path.join(projectRoot, 'go.bat'));
102
- } else {
103
- cmd = path.join(projectRoot, 'go');
104
- }
105
-
106
- return new Promise((resolve, reject) => {
107
- spawn(cmd, args, {
108
- cwd: projectRoot,
109
- env: process.env,
110
- stdio: ['ignore', process.stdout, process.stderr]
111
- }).on('exit', function(code, signal) {
112
- if (code === 0) {
113
- targets.forEach(function(target) {
114
- builtTargets[target] = 1;
115
- });
116
- return resolve();
117
- }
118
-
119
- var msg = 'Unable to build artifacts';
120
- if (code) { // May be null.
121
- msg += '; code=' + code;
122
- }
123
- if (signal) {
124
- msg += '; signal=' + signal;
125
- }
126
-
127
- reject(Error(msg));
128
- });
129
- });
130
- };
131
-
132
-
133
- // PUBLIC API
134
-
135
- exports.isDevMode = isDevMode;
136
-
137
-
138
- /**
139
- * Creates a build of the listed targets.
140
- * @param {...string} var_args The targets to build.
141
- * @return {!Build} The new build.
142
- * @throws {Error} If not running in dev mode.
143
- */
144
- exports.of = function(var_args) {
145
- var targets = Array.prototype.slice.call(arguments, 0);
146
- return new Build(targets);
147
- };
148
-
149
-
150
- /**
151
- * @return {string} Absolute path of the project's root directory.
152
- * @throws {Error} If not running in dev mode.
153
- */
154
- exports.projectRoot = function() {
155
- return PROJECT_ROOT;
156
- };
@@ -1,24 +0,0 @@
1
- <!DOCTYPE html>
2
- <style>
3
- body {
4
- margin: 0;
5
- padding: 0;
6
- }
7
- #box {
8
- background: red;
9
- position: absolute;
10
- top: 0;
11
- left: 0;
12
- width: 100px;
13
- height: 100px;
14
- }
15
- #box.green { background: green; }
16
- #box.blue { background: blue; }
17
- </style>
18
- <body>
19
- <div id="box" onclick="setColor('green');" ondblclick="setColor('blue');"></div>
20
- <script>
21
- function setColor(c) {
22
- document.getElementById('box').className = c;
23
- }
24
- </script>
@@ -1,77 +0,0 @@
1
- <!DOCTYPE html>
2
- <style>
3
- body {
4
- margin: 0;
5
- padding: 0;
6
- }
7
- div {
8
- position: absolute;
9
- width: 50px;
10
- height: 50px;
11
- left: 0;
12
- top: 0;
13
- }
14
- #TR { left: 206px; }
15
- #BL { top: 206px; }
16
- #BR { left: 206px; top: 206px; }
17
- #container {
18
- width: 256px;
19
- height: 256px;
20
- left: 0;
21
- top: 0;
22
- border: 1px solid black;
23
- }
24
- #slide {
25
- background: silver;
26
- z-index: 1;
27
- }
28
- </style>
29
- <body>
30
- <div id="container">
31
- <div id="slide"></div>
32
- <div id="TR"></div>
33
- <div id="BR"></div>
34
- <div id="BL"></div>
35
- </div>
36
- <script>
37
- let offset;
38
- let mouseDown = false;
39
- let slide = document.getElementById('slide');
40
- slide.addEventListener('mousedown', function(e) {
41
- mouseDown = true;
42
-
43
- let bbox = slide.getBoundingClientRect();
44
- offset = {
45
- x: e.clientX - bbox.left,
46
- y: e.clientY - bbox.top
47
- };
48
- });
49
-
50
- let container = document.getElementById('container');
51
-
52
- let slideBox = slide.getBoundingClientRect();
53
- let containerBox = container.getBoundingClientRect();
54
- let maxLeft = containerBox.width - slideBox.width - 2;
55
- let maxTop = containerBox.height - slideBox.height - 2;
56
-
57
- container.addEventListener('mousemove', function(e) {
58
- if (!mouseDown) return;
59
-
60
- let bbox = slide.getBoundingClientRect();
61
- let newLeft = e.clientX - offset.x;
62
- newLeft = Math.max(newLeft, 0);
63
- newLeft = Math.min(newLeft, maxLeft);
64
-
65
- let newTop = e.clientY - offset.y;
66
- newTop = Math.max(newTop, 0);
67
- newTop = Math.min(newTop, maxTop);
68
-
69
- slide.style.top = `${newTop}px`;
70
- slide.style.left = `${newLeft}px`;
71
- });
72
-
73
- document.body.addEventListener('mouseup', function() {
74
- mouseDown = false;
75
- });
76
- </script>
77
- </body>
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <style>
3
- body {
4
- margin: 0;
5
- padding: 0;
6
- }
7
- div {
8
- position: absolute;
9
- top: 0;
10
- left: 0;
11
- width: 500px;
12
- height: 500px;
13
- background: green;
14
- }
15
- </style>
16
- <div></div>
17
- <script>
18
- var clicks = [];
19
- document.querySelector('div')
20
- .addEventListener('click', e => clicks.push([e.clientX, e.clientY]));
21
- </script>
@@ -1,2 +0,0 @@
1
- <!DOCTYPE html>
2
- <h1>Hello, world!</h1>
@@ -1,337 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- 'use strict';
19
-
20
- const fs = require('fs');
21
- const http = require('http');
22
- const path = require('path');
23
- const url = require('url');
24
-
25
- const express = require('express');
26
- const multer = require('multer');
27
- const serveIndex = require('serve-index');
28
-
29
- const {isDevMode} = require('./build');
30
- const resources = require('./resources');
31
- const {Server} = require('./httpserver');
32
-
33
- const WEB_ROOT = '/common';
34
- const DATA_ROOT = '/data';
35
- const JS_ROOT = '/javascript';
36
-
37
- const baseDirectory = resources.locate('common/src/web');
38
- const dataDirectory = path.join(__dirname, 'data');
39
- const jsDirectory = resources.locate('javascript');
40
-
41
- const Pages = (function() {
42
- var pages = {};
43
- function addPage(page, path) {
44
- pages.__defineGetter__(page, function() {
45
- return exports.whereIs(path);
46
- });
47
- }
48
-
49
- addPage('ajaxyPage', 'ajaxy_page.html');
50
- addPage('alertsPage', 'alerts.html');
51
- addPage('bodyTypingPage', 'bodyTypingTest.html');
52
- addPage('booleanAttributes', 'booleanAttributes.html');
53
- addPage('childPage', 'child/childPage.html');
54
- addPage('chinesePage', 'cn-test.html');
55
- addPage('clickJacker', 'click_jacker.html');
56
- addPage('clickEventPage', 'clickEventPage.html');
57
- addPage('clicksPage', 'clicks.html');
58
- addPage('colorPage', 'colorPage.html');
59
- addPage('deletingFrame', 'deletingFrame.htm');
60
- addPage('draggableLists', 'draggableLists.html');
61
- addPage('dragAndDropPage', 'dragAndDropTest.html');
62
- addPage('droppableItems', 'droppableItems.html');
63
- addPage('documentWrite', 'document_write_in_onload.html');
64
- addPage('dynamicallyModifiedPage', 'dynamicallyModifiedPage.html');
65
- addPage('dynamicPage', 'dynamic.html');
66
- addPage('echoPage', 'echo');
67
- addPage('errorsPage', 'errors.html');
68
- addPage('xhtmlFormPage', 'xhtmlFormPage.xhtml');
69
- addPage('formPage', 'formPage.html');
70
- addPage('formSelectionPage', 'formSelectionPage.html');
71
- addPage('framesetPage', 'frameset.html');
72
- addPage('grandchildPage', 'child/grandchild/grandchildPage.html');
73
- addPage('html5Page', 'html5Page.html');
74
- addPage('html5OfflinePage', 'html5/offline.html');
75
- addPage('iframePage', 'iframes.html');
76
- addPage('javascriptEnhancedForm', 'javascriptEnhancedForm.html');
77
- addPage('javascriptPage', 'javascriptPage.html');
78
- addPage('linkedImage', 'linked_image.html');
79
- addPage('longContentPage', 'longContentPage.html');
80
- addPage('macbethPage', 'macbeth.html');
81
- addPage('mapVisibilityPage', 'map_visibility.html');
82
- addPage('metaRedirectPage', 'meta-redirect.html');
83
- addPage('missedJsReferencePage', 'missedJsReference.html');
84
- addPage('mouseTrackerPage', 'mousePositionTracker.html');
85
- addPage('nestedPage', 'nestedElements.html');
86
- addPage('readOnlyPage', 'readOnlyPage.html');
87
- addPage('rectanglesPage', 'rectangles.html');
88
- addPage('redirectPage', 'redirect');
89
- addPage('resultPage', 'resultPage.html');
90
- addPage('richTextPage', 'rich_text.html');
91
- addPage('selectableItemsPage', 'selectableItems.html');
92
- addPage('selectPage', 'selectPage.html');
93
- addPage('simpleTestPage', 'simpleTest.html');
94
- addPage('simpleXmlDocument', 'simple.xml');
95
- addPage('sleepingPage', 'sleep');
96
- addPage('slowIframes', 'slow_loading_iframes.html');
97
- addPage('slowLoadingAlertPage', 'slowLoadingAlert.html');
98
- addPage('svgPage', 'svgPiechart.xhtml');
99
- addPage('tables', 'tables.html');
100
- addPage('underscorePage', 'underscore.html');
101
- addPage('unicodeLtrPage', 'utf8/unicode_ltr.html');
102
- addPage('uploadPage', 'upload.html');
103
- addPage('veryLargeCanvas', 'veryLargeCanvas.html');
104
- addPage('xhtmlTestPage', 'xhtmlTest.html');
105
-
106
- return pages;
107
- })();
108
-
109
-
110
- const Path = {
111
- BASIC_AUTH: WEB_ROOT + '/basicAuth',
112
- ECHO: WEB_ROOT + '/echo',
113
- GENERATED: WEB_ROOT + '/generated',
114
- MANIFEST: WEB_ROOT + '/manifest',
115
- REDIRECT: WEB_ROOT + '/redirect',
116
- PAGE: WEB_ROOT + '/page',
117
- SLEEP: WEB_ROOT + '/sleep',
118
- UPLOAD: WEB_ROOT + '/upload'
119
- };
120
-
121
- var app = express();
122
-
123
- app.get('/', sendIndex)
124
- .get('/favicon.ico', function(req, res) {
125
- res.writeHead(204);
126
- res.end();
127
- })
128
- .use(JS_ROOT, serveIndex(jsDirectory), express.static(jsDirectory))
129
- .post(Path.UPLOAD, handleUpload)
130
- .use(WEB_ROOT, serveIndex(baseDirectory), express.static(baseDirectory))
131
- .use(DATA_ROOT, serveIndex(dataDirectory), express.static(dataDirectory))
132
- .get(Path.ECHO, sendEcho)
133
- .get(Path.PAGE, sendInifinitePage)
134
- .get(Path.PAGE + '/*', sendInifinitePage)
135
- .get(Path.REDIRECT, redirectToResultPage)
136
- .get(Path.SLEEP, sendDelayedResponse)
137
-
138
- if (isDevMode()) {
139
- var closureDir = resources.locate('third_party/closure/goog');
140
- app.use('/third_party/closure/goog',
141
- serveIndex(closureDir), express.static(closureDir));
142
- }
143
- var server = new Server(app);
144
-
145
-
146
- function redirectToResultPage(_, response) {
147
- response.writeHead(303, {
148
- Location: Pages.resultPage
149
- });
150
- return response.end();
151
- }
152
-
153
-
154
- function sendInifinitePage(request, response) {
155
- var pathname = url.parse(request.url).pathname;
156
- var lastIndex = pathname.lastIndexOf('/');
157
- var pageNumber =
158
- (lastIndex == -1 ? 'Unknown' : pathname.substring(lastIndex + 1));
159
- var body = [
160
- '<!DOCTYPE html>',
161
- '<title>Page', pageNumber, '</title>',
162
- 'Page number <span id="pageNumber">', pageNumber, '</span>',
163
- '<p><a href="../xhtmlTest.html" target="_top">top</a>'
164
- ].join('');
165
- response.writeHead(200, {
166
- 'Content-Length': Buffer.byteLength(body, 'utf8'),
167
- 'Content-Type': 'text/html; charset=utf-8'
168
- });
169
- response.end(body);
170
- }
171
-
172
-
173
- function sendDelayedResponse(request, response) {
174
- var duration = 0;
175
- var query = url.parse(request.url).query || '';
176
- var match = query.match(/\btime=(\d+)/);
177
- if (match) {
178
- duration = parseInt(match[1], 10);
179
- }
180
-
181
- setTimeout(function() {
182
- var body = [
183
- '<!DOCTYPE html>',
184
- '<title>Done</title>',
185
- '<body>Slept for ', duration, 's</body>'
186
- ].join('');
187
- response.writeHead(200, {
188
- 'Content-Length': Buffer.byteLength(body, 'utf8'),
189
- 'Content-Type': 'text/html; charset=utf-8',
190
- 'Cache-Control': 'no-cache',
191
- 'Pragma': 'no-cache',
192
- 'Expires': 0
193
- });
194
- response.end(body);
195
- }, duration * 1000);
196
- }
197
-
198
-
199
- function handleUpload(request, response) {
200
- let upload = multer({storage: multer.memoryStorage()}).any();
201
- upload(request, response, function(err) {
202
- if (err) {
203
- response.writeHead(500);
204
- response.end(err + '');
205
- } else {
206
- response.writeHead(200);
207
- response.write(request.files[0].buffer);
208
- response.end('<script>window.top.window.onUploadDone();</script>');
209
- }
210
- });
211
- }
212
-
213
-
214
- function sendEcho(request, response) {
215
- if (request.query['html']) {
216
- const html = request.query['html'];
217
- if (html) {
218
- response.writeHead(200, {
219
- 'Content-Length': Buffer.byteLength(html, 'utf8'),
220
- 'Content-Type': 'text/html; charset=utf-8'
221
- });
222
- response.end(html);
223
- return;
224
- }
225
- }
226
-
227
- var body = [
228
- '<!DOCTYPE html>',
229
- '<title>Echo</title>',
230
- '<div class="request">',
231
- request.method, ' ', request.url, ' ', 'HTTP/', request.httpVersion,
232
- '</div>'
233
- ];
234
- for (var name in request.headers) {
235
- body.push('<div class="header ', name , '">',
236
- name, ': ', request.headers[name], '</div>');
237
- }
238
- body = body.join('');
239
- response.writeHead(200, {
240
- 'Content-Length': Buffer.byteLength(body, 'utf8'),
241
- 'Content-Type': 'text/html; charset=utf-8'
242
- });
243
- response.end(body);
244
- }
245
-
246
-
247
- /**
248
- * Responds to a request for the file server's main index.
249
- * @param {!http.ServerRequest} request The request object.
250
- * @param {!http.ServerResponse} response The response object.
251
- */
252
- function sendIndex(request, response) {
253
- var pathname = url.parse(request.url).pathname;
254
-
255
- var host = request.headers.host;
256
- if (!host) {
257
- host = server.host();
258
- }
259
-
260
- var requestUrl = ['http://' + host + pathname].join('');
261
-
262
- function createListEntry(path) {
263
- var url = requestUrl + path;
264
- return ['<li><a href="', url, '">', path, '</a>'].join('');
265
- }
266
-
267
- var data = ['<!DOCTYPE html><h1>/</h1><hr/><ul>',
268
- createListEntry('common'),
269
- createListEntry('data')];
270
- if (isDevMode()) {
271
- data.push(createListEntry('javascript'));
272
- }
273
- data.push('</ul>');
274
- data = data.join('');
275
-
276
- response.writeHead(200, {
277
- 'Content-Type': 'text/html; charset=UTF-8',
278
- 'Content-Length': Buffer.byteLength(data, 'utf8')
279
- });
280
- response.end(data);
281
- }
282
-
283
-
284
- // PUBLIC application
285
-
286
-
287
- /**
288
- * Starts the server on the specified port.
289
- * @param {number=} opt_port The port to use, or 0 for any free port.
290
- * @return {!Promise<Host>} A promise that will resolve
291
- * with the server host when it has fully started.
292
- */
293
- exports.start = server.start.bind(server);
294
-
295
-
296
- /**
297
- * Stops the server.
298
- * @return {!Promise} A promise that will resolve when the
299
- * server has closed all connections.
300
- */
301
- exports.stop = server.stop.bind(server);
302
-
303
-
304
- /**
305
- * Formats a URL for this server.
306
- * @param {string=} opt_pathname The desired pathname on the server.
307
- * @return {string} The formatted URL.
308
- * @throws {Error} If the server is not running.
309
- */
310
- exports.url = server.url.bind(server);
311
-
312
-
313
- /**
314
- * Builds the URL for a file in the //common/src/web directory of the
315
- * Selenium client.
316
- * @param {string} filePath A path relative to //common/src/web to compute a
317
- * URL for.
318
- * @return {string} The formatted URL.
319
- * @throws {Error} If the server is not running.
320
- */
321
- exports.whereIs = function(filePath) {
322
- filePath = filePath.replace(/\\/g, '/');
323
- if (!filePath.startsWith('/')) {
324
- filePath = `${WEB_ROOT}/${filePath}`;
325
- }
326
- return server.url(filePath);
327
- };
328
-
329
-
330
- exports.Pages = Pages;
331
-
332
-
333
- if (require.main === module) {
334
- server.start(2310).then(function() {
335
- console.log('Server running at ' + server.url());
336
- });
337
- }