selenium-webdriver 4.18.1 → 4.19.0
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.
- package/CHANGES.md +931 -743
- package/README.md +71 -72
- package/bidi/addInterceptParameters.js +39 -45
- package/bidi/argumentValue.js +1 -0
- package/bidi/browser.js +77 -0
- package/bidi/browsingContext.js +7 -7
- package/bidi/continueRequestParameters.js +83 -0
- package/bidi/continueResponseParameters.js +89 -0
- package/bidi/cookieFilter.js +79 -0
- package/bidi/index.js +25 -25
- package/bidi/input.js +20 -0
- package/bidi/interceptPhase.js +1 -1
- package/bidi/network.js +74 -23
- package/bidi/networkTypes.js +49 -17
- package/bidi/partialCookie.js +67 -0
- package/bidi/partitionDescriptor.js +69 -0
- package/bidi/partitionKey.js +36 -0
- package/bidi/protocolValue.js +11 -7
- package/bidi/provideResponseParameters.js +83 -0
- package/bidi/scriptManager.js +12 -4
- package/bidi/storage.js +171 -0
- package/bidi/urlPattern.js +1 -3
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/chromium.js +1 -0
- package/devtools/CDPConnection.js +1 -0
- package/devtools/networkinterceptor.js +1 -0
- package/http/util.js +1 -0
- package/lib/atoms/find-elements.js +25 -25
- package/lib/atoms/is-displayed.js +24 -97
- package/lib/capabilities.js +5 -5
- package/lib/http.js +3 -0
- package/lib/select.js +3 -3
- package/lib/virtual_authenticator.js +8 -8
- package/lib/webdriver.js +6 -1
- package/package.json +12 -10
- package/testing/index.js +5 -0
package/README.md
CHANGED
|
@@ -13,19 +13,18 @@ Selenium may be installed via npm with
|
|
|
13
13
|
You will need to download additional components to work with each of the major
|
|
14
14
|
browsers. The drivers for Chrome, Firefox, and Microsoft's IE and Edge web
|
|
15
15
|
browsers are all standalone executables that should be placed on your system
|
|
16
|
-
[PATH]. Apple's safaridriver (v10 and above) can be found at the
|
|
17
|
-
following path – /usr/bin/safaridriver. To enable automation on safari,
|
|
16
|
+
[PATH]. Apple's safaridriver (v10 and above) can be found at the
|
|
17
|
+
following path – /usr/bin/safaridriver. To enable automation on safari,
|
|
18
18
|
you need to run command `safaridriver --enable`.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| Safari | [safaridriver] |
|
|
20
|
+
| Browser | Component |
|
|
21
|
+
| :---------------- | :------------------------------- |
|
|
22
|
+
| Chrome | [chromedriver(.exe)][chrome] |
|
|
23
|
+
| Internet Explorer | [IEDriverServer.exe][release] |
|
|
24
|
+
| Edge | [MicrosoftWebDriver.msi][edge] |
|
|
25
|
+
| Firefox | [geckodriver(.exe)][geckodriver] |
|
|
26
|
+
| Opera | [operadriver(.exe)][operadriver] |
|
|
27
|
+
| Safari | [safaridriver] |
|
|
29
28
|
|
|
30
29
|
## Usage
|
|
31
30
|
|
|
@@ -33,18 +32,18 @@ The sample below and others are included in the `example` directory. You may
|
|
|
33
32
|
also find the tests for selenium-webdriver informative.
|
|
34
33
|
|
|
35
34
|
```javascript
|
|
36
|
-
const {Builder, Browser, By, Key, until} = require('selenium-webdriver')
|
|
35
|
+
const { Builder, Browser, By, Key, until } = require('selenium-webdriver')
|
|
37
36
|
|
|
38
|
-
(async function example() {
|
|
39
|
-
let driver = await new Builder().forBrowser(Browser.FIREFOX).build()
|
|
37
|
+
;(async function example() {
|
|
38
|
+
let driver = await new Builder().forBrowser(Browser.FIREFOX).build()
|
|
40
39
|
try {
|
|
41
|
-
await driver.get('https://www.google.com/ncr')
|
|
42
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
|
43
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
|
40
|
+
await driver.get('https://www.google.com/ncr')
|
|
41
|
+
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
|
42
|
+
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
|
44
43
|
} finally {
|
|
45
|
-
await driver.quit()
|
|
44
|
+
await driver.quit()
|
|
46
45
|
}
|
|
47
|
-
})()
|
|
46
|
+
})()
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
### Using the Builder API
|
|
@@ -55,15 +54,15 @@ the builder lets you set all options in one flow. When you call
|
|
|
55
54
|
`Builder#build()`, all options irrelevant to the selected browser are dropped:
|
|
56
55
|
|
|
57
56
|
```javascript
|
|
58
|
-
const webdriver = require('selenium-webdriver')
|
|
59
|
-
const chrome = require('selenium-webdriver/chrome')
|
|
60
|
-
const firefox = require('selenium-webdriver/firefox')
|
|
57
|
+
const webdriver = require('selenium-webdriver')
|
|
58
|
+
const chrome = require('selenium-webdriver/chrome')
|
|
59
|
+
const firefox = require('selenium-webdriver/firefox')
|
|
61
60
|
|
|
62
61
|
let driver = new webdriver.Builder()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
.forBrowser(webdriver.Browser.FIREFOX)
|
|
63
|
+
.setChromeOptions(/* ... */)
|
|
64
|
+
.setFirefoxOptions(/* ... */)
|
|
65
|
+
.build()
|
|
67
66
|
```
|
|
68
67
|
|
|
69
68
|
Why would you want to configure options irrelevant to the target browser? The
|
|
@@ -99,10 +98,11 @@ API:
|
|
|
99
98
|
|
|
100
99
|
```javascript
|
|
101
100
|
let driver = new webdriver.Builder()
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
.forBrowser(webdriver.Browser.FIREFOX)
|
|
102
|
+
.usingServer('http://localhost:4444/wd/hub')
|
|
103
|
+
.build()
|
|
105
104
|
```
|
|
105
|
+
|
|
106
106
|
Or change the Builder's configuration at runtime with the `SELENIUM_REMOTE_URL`
|
|
107
107
|
environment variable:
|
|
108
108
|
|
|
@@ -135,82 +135,83 @@ will also have "best effort" support. Releases older than the latest LTS,
|
|
|
135
135
|
_semver-major_ releases, and all unstable release branches (e.g. "v.Next")
|
|
136
136
|
are considered strictly unsupported.
|
|
137
137
|
|
|
138
|
-
For example, suppose the current LTS and stable releases are v14.20.0 and
|
|
138
|
+
For example, suppose the current LTS and stable releases are v14.20.0 and
|
|
139
|
+
v18.8.0,
|
|
139
140
|
respectively. Then a Selenium release would have the following support levels:
|
|
140
141
|
|
|
141
|
-
| Version
|
|
142
|
-
|
|
143
|
-
|
|
|
144
|
-
| 14.20.0
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
| >= 18.8.0
|
|
148
|
-
|
|
|
142
|
+
| Version | Support |
|
|
143
|
+
| :-------: | :-----------: |
|
|
144
|
+
| <= 14.19 | _unsupported_ |
|
|
145
|
+
| 14.20.0 | supported |
|
|
146
|
+
| 18.0-7 | best effort |
|
|
147
|
+
| 18.8.0 | supported |
|
|
148
|
+
| >= 18.8.0 | best effort |
|
|
149
|
+
| v.Next | _unsupported_ |
|
|
149
150
|
|
|
150
151
|
### Support Level Definitions
|
|
151
152
|
|
|
152
153
|
- _supported:_ A selenium-webdriver release will be API compatible with the
|
|
153
|
-
|
|
154
|
+
platform API, without the use of runtime flags.
|
|
154
155
|
|
|
155
156
|
- _best effort:_ Bugs will be investigated as time permits. API compatibility is
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
only guaranteed where required by a _supported_ release. This effectively
|
|
158
|
+
means the adoption of new JS features, such as ES2015 modules, will depend
|
|
159
|
+
on what is supported in Node's LTS.
|
|
159
160
|
|
|
160
161
|
- _unsupported:_ Bug submissions will be closed as will-not-fix and API
|
|
161
|
-
|
|
162
|
+
compatibility is not guaranteed.
|
|
162
163
|
|
|
163
164
|
### Projected Support Schedule
|
|
164
165
|
|
|
165
166
|
If Node releases a new [LTS] each October and a new major version every 6
|
|
166
167
|
months, the support window for selenium-webdriver will be roughly:
|
|
167
168
|
|
|
168
|
-
|
|
|
169
|
-
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
169
|
+
| Release | Status | END-OF-LIFE |
|
|
170
|
+
| :-----: | :-------------: | :---------: |
|
|
171
|
+
| v14.x | Maintenance LTS | 2023-04-30 |
|
|
172
|
+
| v16.x | Active LTS | 2023-09-11 |
|
|
173
|
+
| v18.x | Current | 2025-04-30 |
|
|
174
|
+
| v19.x | Pending | 2023-06-01 |
|
|
175
|
+
| v20 | Pending | 2026-04-30 |
|
|
175
176
|
|
|
176
177
|
## Issues
|
|
177
178
|
|
|
178
179
|
Please report any issues using the [Selenium issue tracker][issues]. When using
|
|
179
180
|
the issue tracker
|
|
180
181
|
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
- **Do** include a detailed description of the problem.
|
|
183
|
+
- **Do** include a link to a [gist](http://gist.github.com/) with any
|
|
184
|
+
interesting stack traces/logs (you may also attach these directly to the bug
|
|
185
|
+
report).
|
|
186
|
+
- **Do** include a [reduced test case][reduction]. Reporting "unable to find
|
|
187
|
+
element on the page" is _not_ a valid report - there's nothing for us to
|
|
188
|
+
look into. Expect your bug report to be closed if you do not provide enough
|
|
189
|
+
information for us to investigate.
|
|
190
|
+
- **Do not** use the issue tracker to submit basic help requests. All help
|
|
191
|
+
inquiries should be directed to the [user forum][users] or #selenium IRC
|
|
192
|
+
channel.
|
|
193
|
+
- **Do not** post empty "I see this too" or "Any updates?" comments. These
|
|
194
|
+
provide no additional information and clutter the log.
|
|
195
|
+
- **Do not** report regressions on closed bugs as they are not actively
|
|
196
|
+
monitored for updates (especially bugs that are >6 months old). Please open a
|
|
197
|
+
new issue and reference the original bug in your report.
|
|
197
198
|
|
|
198
199
|
## License
|
|
199
200
|
|
|
200
201
|
Licensed to the Software Freedom Conservancy (SFC) under one
|
|
201
|
-
or more contributor license agreements.
|
|
202
|
+
or more contributor license agreements. See the NOTICE file
|
|
202
203
|
distributed with this work for additional information
|
|
203
|
-
regarding copyright ownership.
|
|
204
|
+
regarding copyright ownership. The SFC licenses this file
|
|
204
205
|
to you under the Apache License, Version 2.0 (the
|
|
205
206
|
"License"); you may not use this file except in compliance
|
|
206
|
-
with the License.
|
|
207
|
+
with the License. You may obtain a copy of the License at
|
|
207
208
|
|
|
208
209
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
209
210
|
|
|
210
211
|
Unless required by applicable law or agreed to in writing,
|
|
211
212
|
software distributed under the License is distributed on an
|
|
212
213
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
213
|
-
KIND, either express or implied.
|
|
214
|
+
KIND, either express or implied. See the License for the
|
|
214
215
|
specific language governing permissions and limitations
|
|
215
216
|
under the License.
|
|
216
217
|
|
|
@@ -223,9 +224,7 @@ under the License.
|
|
|
223
224
|
[edge]: http://go.microsoft.com/fwlink/?LinkId=619687
|
|
224
225
|
[geckodriver]: https://github.com/mozilla/geckodriver/releases/
|
|
225
226
|
[reduction]: http://www.webkit.org/quality/reduction.html
|
|
226
|
-
|
|
227
227
|
[release]: https://www.selenium.dev/downloads/
|
|
228
|
-
|
|
229
228
|
[users]: https://groups.google.com/forum/#!forum/selenium-users
|
|
230
229
|
[safaridriver]: https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html#//apple_ref/doc/uid/TP40014305-CH11-DontLinkElementID_28
|
|
231
230
|
[operadriver]: https://github.com/operasoftware/operachromiumdriver/releases
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
const {UrlPattern} = require(
|
|
18
|
+
const { UrlPattern } = require('./urlPattern')
|
|
19
19
|
|
|
20
20
|
class AddInterceptParameters {
|
|
21
21
|
#phases = []
|
|
@@ -23,64 +23,58 @@ class AddInterceptParameters {
|
|
|
23
23
|
|
|
24
24
|
constructor(phases) {
|
|
25
25
|
if (phases instanceof Array) {
|
|
26
|
-
phases.forEach(phase => this.#phases.push(phase))
|
|
26
|
+
phases.forEach((phase) => this.#phases.push(phase))
|
|
27
27
|
} else {
|
|
28
28
|
this.#phases.push(phases)
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
throw new Error(`Pattern must be an instance of UrlPattern. Received: '${pattern})'`)
|
|
36
|
-
}
|
|
37
|
-
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
38
|
-
return this
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
urlPatterns(patterns)
|
|
42
|
-
{
|
|
43
|
-
patterns.forEach(pattern => {
|
|
44
|
-
if (!pattern instanceof UrlPattern) {
|
|
45
|
-
throw new Error(`Pattern must be an instance of UrlPattern. Received:'${pattern}'`)
|
|
46
|
-
}
|
|
47
|
-
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
48
|
-
})
|
|
49
|
-
return this
|
|
32
|
+
urlPattern(pattern) {
|
|
33
|
+
if (!(pattern instanceof UrlPattern)) {
|
|
34
|
+
throw new Error(`Pattern must be an instance of UrlPattern. Received: '${pattern})'`)
|
|
50
35
|
}
|
|
36
|
+
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
37
|
+
return this
|
|
38
|
+
}
|
|
51
39
|
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
if (!pattern instanceof
|
|
55
|
-
throw new Error(`Pattern must be an instance of
|
|
40
|
+
urlPatterns(patterns) {
|
|
41
|
+
patterns.forEach((pattern) => {
|
|
42
|
+
if (!(pattern instanceof UrlPattern)) {
|
|
43
|
+
throw new Error(`Pattern must be an instance of UrlPattern. Received:'${pattern}'`)
|
|
56
44
|
}
|
|
45
|
+
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
46
|
+
})
|
|
47
|
+
return this
|
|
48
|
+
}
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
urlStringPatterns(patterns)
|
|
63
|
-
{
|
|
64
|
-
patterns.forEach(pattern => {
|
|
65
|
-
if (!pattern instanceof String) {
|
|
66
|
-
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
|
|
67
|
-
}
|
|
68
|
-
this.#urlPatterns.push({'type': 'string', 'pattern': pattern})
|
|
69
|
-
})
|
|
70
|
-
return this
|
|
50
|
+
urlStringPattern(pattern) {
|
|
51
|
+
if (!(pattern instanceof String)) {
|
|
52
|
+
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
|
|
71
53
|
}
|
|
72
54
|
|
|
55
|
+
this.#urlPatterns.push({ type: 'string', pattern: pattern })
|
|
56
|
+
return this
|
|
57
|
+
}
|
|
73
58
|
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (this.#urlPatterns.length > 0) {
|
|
79
|
-
map.set('urlPatterns', this.#urlPatterns)
|
|
59
|
+
urlStringPatterns(patterns) {
|
|
60
|
+
patterns.forEach((pattern) => {
|
|
61
|
+
if (!(pattern instanceof String)) {
|
|
62
|
+
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
|
|
80
63
|
}
|
|
64
|
+
this.#urlPatterns.push({ type: 'string', pattern: pattern })
|
|
65
|
+
})
|
|
66
|
+
return this
|
|
67
|
+
}
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
asMap() {
|
|
70
|
+
const map = new Map()
|
|
71
|
+
map.set('phases', this.#phases)
|
|
72
|
+
if (this.#urlPatterns.length > 0) {
|
|
73
|
+
map.set('urlPatterns', this.#urlPatterns)
|
|
83
74
|
}
|
|
75
|
+
|
|
76
|
+
return map
|
|
84
77
|
}
|
|
78
|
+
}
|
|
85
79
|
|
|
86
|
-
|
|
80
|
+
module.exports = { AddInterceptParameters }
|
package/bidi/argumentValue.js
CHANGED
package/bidi/browser.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
class Browser {
|
|
19
|
+
constructor(driver) {
|
|
20
|
+
this._driver = driver
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async init() {
|
|
24
|
+
if (!(await this._driver.getCapabilities()).get('webSocketUrl')) {
|
|
25
|
+
throw Error('WebDriver instance must support BiDi protocol')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.bidi = await this._driver.getBidi()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async createUserContext() {
|
|
32
|
+
const command = {
|
|
33
|
+
method: 'browser.createUserContext',
|
|
34
|
+
params: {},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let response = await this.bidi.send(command)
|
|
38
|
+
|
|
39
|
+
return response.result.userContext
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getUserContexts() {
|
|
43
|
+
const command = {
|
|
44
|
+
method: 'browser.getUserContexts',
|
|
45
|
+
params: {},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let response = await this.bidi.send(command)
|
|
49
|
+
|
|
50
|
+
let userContexts = []
|
|
51
|
+
|
|
52
|
+
let userContextsArray = response.result.userContexts
|
|
53
|
+
|
|
54
|
+
for (let userContextJson of userContextsArray) {
|
|
55
|
+
userContexts.push(userContextJson.userContext)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return userContexts
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async removeUserContext(userContext) {
|
|
62
|
+
const command = {
|
|
63
|
+
method: 'browser.removeUserContext',
|
|
64
|
+
params: { userContext: userContext },
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
await this.bidi.send(command)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function getBrowserInstance(driver) {
|
|
72
|
+
let instance = new Browser(driver)
|
|
73
|
+
await instance.init()
|
|
74
|
+
return instance
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = getBrowserInstance
|
package/bidi/browsingContext.js
CHANGED
|
@@ -71,6 +71,13 @@ class BrowsingContext {
|
|
|
71
71
|
this._driver = driver
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @returns id
|
|
76
|
+
*/
|
|
77
|
+
get id() {
|
|
78
|
+
return this._id
|
|
79
|
+
}
|
|
80
|
+
|
|
74
81
|
async init({ browsingContextId, type, referenceContext }) {
|
|
75
82
|
if (!(await this._driver.getCapabilities()).get('webSocketUrl')) {
|
|
76
83
|
throw Error('WebDriver instance must support BiDi protocol')
|
|
@@ -101,13 +108,6 @@ class BrowsingContext {
|
|
|
101
108
|
return await this.bidi.send(params)
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
/**
|
|
105
|
-
* @returns id
|
|
106
|
-
*/
|
|
107
|
-
get id() {
|
|
108
|
-
return this._id
|
|
109
|
-
}
|
|
110
|
-
|
|
111
111
|
/**
|
|
112
112
|
* @param url the url to navigate to
|
|
113
113
|
* @param readinessState type of readiness state: "none" / "interactive" / "complete"
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
const { BytesValue, Header } = require('./networkTypes')
|
|
19
|
+
|
|
20
|
+
class ContinueRequestParameters {
|
|
21
|
+
#map = new Map()
|
|
22
|
+
|
|
23
|
+
constructor(request) {
|
|
24
|
+
this.#map.set('request', request)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body(value) {
|
|
28
|
+
if (!(value instanceof BytesValue)) {
|
|
29
|
+
throw new Error(`Value must be an instance of BytesValue. Received: '${value})'`)
|
|
30
|
+
}
|
|
31
|
+
this.#map.set('body', Object.fromEntries(value.asMap()))
|
|
32
|
+
return this
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
cookies(cookieHeaders) {
|
|
36
|
+
const cookies = []
|
|
37
|
+
cookieHeaders.forEach((header) => {
|
|
38
|
+
if (!(header instanceof Header)) {
|
|
39
|
+
throw new Error(`CookieHeader must be an instance of Header. Received:'${header}'`)
|
|
40
|
+
}
|
|
41
|
+
cookies.push(Object.fromEntries(header.asMap()))
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
this.#map.set('cookies', cookies)
|
|
45
|
+
return this
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
headers(headers) {
|
|
49
|
+
const headerList = []
|
|
50
|
+
headers.forEach((header) => {
|
|
51
|
+
if (!(header instanceof Header)) {
|
|
52
|
+
throw new Error(`Header value must be an instance of Header. Received:'${header}'`)
|
|
53
|
+
}
|
|
54
|
+
headerList.push(Object.fromEntries(header.asMap()))
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
this.#map.set('headers', headerList)
|
|
58
|
+
return this
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
method(method) {
|
|
62
|
+
if (typeof method !== 'string') {
|
|
63
|
+
throw new Error(`Http method must be a string. Received: '${method})'`)
|
|
64
|
+
}
|
|
65
|
+
this.#map.set('method', method)
|
|
66
|
+
return this
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
url(url) {
|
|
70
|
+
if (typeof url !== 'string') {
|
|
71
|
+
throw new Error(`Url must be a string. Received:'${url}'`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.#map.set('url', url)
|
|
75
|
+
return this
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
asMap() {
|
|
79
|
+
return this.#map
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = { ContinueRequestParameters }
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
const { Header } = require('./networkTypes')
|
|
19
|
+
|
|
20
|
+
class ContinueResponseParameters {
|
|
21
|
+
#map = new Map()
|
|
22
|
+
|
|
23
|
+
constructor(request) {
|
|
24
|
+
this.#map.set('request', request)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
cookies(cookieHeaders) {
|
|
28
|
+
const cookies = []
|
|
29
|
+
cookieHeaders.forEach((header) => {
|
|
30
|
+
if (!(header instanceof Header)) {
|
|
31
|
+
throw new Error(`CookieHeader must be an instance of Header. Received:'${header}'`)
|
|
32
|
+
}
|
|
33
|
+
cookies.push(Object.fromEntries(header.asMap()))
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
this.#map.set('cookies', cookies)
|
|
37
|
+
return this
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
credentials(username, password) {
|
|
41
|
+
if (typeof username !== 'string') {
|
|
42
|
+
throw new Error(`Username must be a string. Received:'${username}'`)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (typeof password !== 'string') {
|
|
46
|
+
throw new Error(`Password must be a string. Received:'${password}'`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.#map.set('credentials', { type: 'password', username: username, password: password })
|
|
50
|
+
|
|
51
|
+
return this
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
headers(headers) {
|
|
55
|
+
const headerList = []
|
|
56
|
+
headers.forEach((header) => {
|
|
57
|
+
if (!(header instanceof Header)) {
|
|
58
|
+
throw new Error(`Header value must be an instance of Header. Received:'${header}'`)
|
|
59
|
+
}
|
|
60
|
+
headerList.push(Object.fromEntries(header.asMap()))
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
this.#map.set('headers', headerList)
|
|
64
|
+
return this
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
reasonPhrase(reasonPhrase) {
|
|
68
|
+
if (typeof reasonPhrase !== 'string') {
|
|
69
|
+
throw new Error(`Reason phrase must be a string. Received: '${reasonPhrase})'`)
|
|
70
|
+
}
|
|
71
|
+
this.#map.set('reasonPhrase', reasonPhrase)
|
|
72
|
+
return this
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
statusCode(statusCode) {
|
|
76
|
+
if (!Number.isInteger(statusCode)) {
|
|
77
|
+
throw new Error(`Status must be an integer. Received:'${statusCode}'`)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.#map.set('statusCode', statusCode)
|
|
81
|
+
return this
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
asMap() {
|
|
85
|
+
return this.#map
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = { ContinueResponseParameters }
|