selenium-webdriver 4.17.0 → 4.18.1
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 +240 -196
- package/bidi/addInterceptParameters.js +86 -0
- package/bidi/browsingContext.js +144 -37
- package/bidi/browsingContextInspector.js +13 -40
- package/bidi/evaluateResult.js +4 -10
- package/bidi/filterBy.js +2 -6
- package/bidi/index.js +31 -29
- package/bidi/input.js +1 -4
- package/bidi/interceptPhase.js +24 -0
- package/bidi/logInspector.js +15 -20
- package/bidi/network.js +178 -0
- package/bidi/networkInspector.js +8 -2
- package/bidi/networkTypes.js +22 -49
- package/bidi/protocolType.js +3 -9
- package/bidi/protocolValue.js +6 -25
- package/bidi/realmInfo.js +2 -10
- package/bidi/scriptManager.js +20 -59
- package/bidi/urlPattern.js +58 -0
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/chrome.js +1 -8
- package/chromium.js +27 -109
- package/common/driverFinder.js +1 -1
- package/common/seleniumManager.js +9 -18
- package/devtools/CDPConnection.js +1 -3
- package/edge.js +1 -3
- package/example/chrome_android.js +2 -5
- package/example/chrome_mobile_emulation.js +2 -4
- package/example/google_search.js +1 -3
- package/example/headless.js +4 -10
- package/example/logging.js +3 -9
- package/firefox.js +55 -109
- package/http/index.js +7 -10
- package/ie.js +5 -15
- package/index.js +7 -29
- package/io/exec.js +1 -2
- package/io/index.js +3 -3
- package/io/zip.js +8 -30
- package/lib/by.js +2 -9
- package/lib/capabilities.js +3 -9
- package/lib/command.js +3 -3
- package/lib/error.js +2 -9
- package/lib/http.js +34 -131
- package/lib/input.js +10 -34
- package/lib/logging.js +3 -11
- package/lib/promise.js +2 -7
- package/lib/select.js +3 -9
- package/lib/until.js +28 -49
- package/lib/util.js +1 -4
- package/lib/virtual_authenticator.js +4 -22
- package/lib/webdriver.js +118 -297
- package/lib/webelement.js +1 -5
- package/net/index.js +1 -4
- package/package.json +2 -1
- package/remote/index.js +9 -24
- package/remote/util.js +6 -19
- package/safari.js +3 -8
- package/testing/index.js +6 -11
package/bidi/logInspector.js
CHANGED
|
@@ -19,15 +19,15 @@ const { FilterBy } = require('./filterBy')
|
|
|
19
19
|
const { ConsoleLogEntry, JavascriptLogEntry, GenericLogEntry } = require('./logEntries')
|
|
20
20
|
|
|
21
21
|
const LOG = {
|
|
22
|
-
TYPE_CONSOLE
|
|
23
|
-
TYPE_JS_LOGS
|
|
22
|
+
TYPE_CONSOLE: 'console',
|
|
23
|
+
TYPE_JS_LOGS: 'javascript',
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
class LogInspector {
|
|
27
27
|
bidi
|
|
28
28
|
ws
|
|
29
29
|
|
|
30
|
-
constructor
|
|
30
|
+
constructor(driver, browsingContextIds) {
|
|
31
31
|
this._driver = driver
|
|
32
32
|
this._browsingContextIds = browsingContextIds
|
|
33
33
|
this.listener = {}
|
|
@@ -37,7 +37,7 @@ class LogInspector {
|
|
|
37
37
|
* Subscribe to log event
|
|
38
38
|
* @returns {Promise<void>}
|
|
39
39
|
*/
|
|
40
|
-
async init
|
|
40
|
+
async init() {
|
|
41
41
|
this.bidi = await this._driver.getBidi()
|
|
42
42
|
await this.bidi.subscribe('log.entryAdded', this._browsingContextIds)
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ class LogInspector {
|
|
|
45
45
|
/**
|
|
46
46
|
* @param kind
|
|
47
47
|
*/
|
|
48
|
-
logListener
|
|
48
|
+
logListener(kind) {
|
|
49
49
|
if (!(kind in this.listener)) {
|
|
50
50
|
this.listener[kind] = []
|
|
51
51
|
}
|
|
@@ -76,7 +76,7 @@ class LogInspector {
|
|
|
76
76
|
params.method,
|
|
77
77
|
params.realm,
|
|
78
78
|
params.args,
|
|
79
|
-
params.stackTrace
|
|
79
|
+
params.stackTrace,
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
if (filterBy !== undefined) {
|
|
@@ -113,7 +113,7 @@ class LogInspector {
|
|
|
113
113
|
params.text,
|
|
114
114
|
params.timestamp,
|
|
115
115
|
params.type,
|
|
116
|
-
params.stackTrace
|
|
116
|
+
params.stackTrace,
|
|
117
117
|
)
|
|
118
118
|
|
|
119
119
|
if (filterBy !== undefined) {
|
|
@@ -135,9 +135,7 @@ class LogInspector {
|
|
|
135
135
|
*/
|
|
136
136
|
async onJavascriptException(callback) {
|
|
137
137
|
this.ws = await this.bidi.socket
|
|
138
|
-
let enabled =
|
|
139
|
-
LOG.TYPE_JS_EXCEPTION in this.listener ||
|
|
140
|
-
this.logListener(LOG.TYPE_JS_EXCEPTION)
|
|
138
|
+
let enabled = LOG.TYPE_JS_EXCEPTION in this.listener || this.logListener(LOG.TYPE_JS_EXCEPTION)
|
|
141
139
|
this.listener[LOG.TYPE_JS_EXCEPTION].push(callback)
|
|
142
140
|
|
|
143
141
|
if (enabled) {
|
|
@@ -152,7 +150,7 @@ class LogInspector {
|
|
|
152
150
|
params.text,
|
|
153
151
|
params.timestamp,
|
|
154
152
|
params.type,
|
|
155
|
-
params.stackTrace
|
|
153
|
+
params.stackTrace,
|
|
156
154
|
)
|
|
157
155
|
|
|
158
156
|
this.listener[LOG.TYPE_JS_EXCEPTION].forEach((listener) => {
|
|
@@ -183,7 +181,7 @@ class LogInspector {
|
|
|
183
181
|
params.text,
|
|
184
182
|
params.timestamp,
|
|
185
183
|
params.type,
|
|
186
|
-
params.stackTrace
|
|
184
|
+
params.stackTrace,
|
|
187
185
|
)
|
|
188
186
|
|
|
189
187
|
if (filterBy !== undefined) {
|
|
@@ -206,7 +204,7 @@ class LogInspector {
|
|
|
206
204
|
params.method,
|
|
207
205
|
params.realm,
|
|
208
206
|
params.args,
|
|
209
|
-
params.stackTrace
|
|
207
|
+
params.stackTrace,
|
|
210
208
|
)
|
|
211
209
|
|
|
212
210
|
if (filterBy !== undefined) {
|
|
@@ -220,16 +218,13 @@ class LogInspector {
|
|
|
220
218
|
return
|
|
221
219
|
}
|
|
222
220
|
|
|
223
|
-
if (
|
|
224
|
-
params !== undefined &&
|
|
225
|
-
!['console', 'javascript'].includes(params?.type)
|
|
226
|
-
) {
|
|
221
|
+
if (params !== undefined && !['console', 'javascript'].includes(params?.type)) {
|
|
227
222
|
let genericEntry = new GenericLogEntry(
|
|
228
223
|
params.level,
|
|
229
224
|
params.text,
|
|
230
225
|
params.timestamp,
|
|
231
226
|
params.type,
|
|
232
|
-
params.stackTrace
|
|
227
|
+
params.stackTrace,
|
|
233
228
|
)
|
|
234
229
|
|
|
235
230
|
if (filterBy !== undefined) {
|
|
@@ -248,7 +243,7 @@ class LogInspector {
|
|
|
248
243
|
* Unsubscribe to log event
|
|
249
244
|
* @returns {Promise<void>}
|
|
250
245
|
*/
|
|
251
|
-
async close
|
|
246
|
+
async close() {
|
|
252
247
|
await this.bidi.unsubscribe('log.entryAdded', this._browsingContextIds)
|
|
253
248
|
}
|
|
254
249
|
}
|
|
@@ -259,7 +254,7 @@ class LogInspector {
|
|
|
259
254
|
* @param browsingContextIds
|
|
260
255
|
* @returns {Promise<LogInspector>}
|
|
261
256
|
*/
|
|
262
|
-
async function getLogInspectorInstance
|
|
257
|
+
async function getLogInspectorInstance(driver, browsingContextIds) {
|
|
263
258
|
let instance = new LogInspector(driver, browsingContextIds)
|
|
264
259
|
await instance.init()
|
|
265
260
|
return instance
|
package/bidi/network.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
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 { BeforeRequestSent, ResponseStarted, FetchError} = require('./networkTypes')
|
|
19
|
+
const {AddInterceptParameters} = require("./addInterceptParameters");
|
|
20
|
+
|
|
21
|
+
class Network {
|
|
22
|
+
constructor(driver, browsingContextIds) {
|
|
23
|
+
this._driver = driver
|
|
24
|
+
this._browsingContextIds = browsingContextIds
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async init() {
|
|
28
|
+
this.bidi = await this._driver.getBidi()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async beforeRequestSent(callback) {
|
|
32
|
+
await this.subscribeAndHandleEvent('network.beforeRequestSent', callback)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async responseStarted(callback) {
|
|
36
|
+
await this.subscribeAndHandleEvent('network.responseStarted', callback)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async responseCompleted(callback) {
|
|
40
|
+
await this.subscribeAndHandleEvent('network.responseCompleted', callback)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async authRequired(callback) {
|
|
44
|
+
await this.subscribeAndHandleEvent('network.authRequired', callback)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async fetchError(callback) {
|
|
48
|
+
await this.subscribeAndHandleEvent('network.fetchError', callback)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async subscribeAndHandleEvent(eventType, callback) {
|
|
52
|
+
if (this._browsingContextIds != null) {
|
|
53
|
+
await this.bidi.subscribe(eventType, this._browsingContextIds)
|
|
54
|
+
} else {
|
|
55
|
+
await this.bidi.subscribe(eventType)
|
|
56
|
+
}
|
|
57
|
+
await this._on(callback)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async _on(callback) {
|
|
61
|
+
this.ws = await this.bidi.socket
|
|
62
|
+
this.ws.on('message', (event) => {
|
|
63
|
+
const { params } = JSON.parse(Buffer.from(event.toString()))
|
|
64
|
+
if (params) {
|
|
65
|
+
let response = null
|
|
66
|
+
if ('initiator' in params) {
|
|
67
|
+
response = new BeforeRequestSent(
|
|
68
|
+
params.context,
|
|
69
|
+
params.navigation,
|
|
70
|
+
params.redirectCount,
|
|
71
|
+
params.request,
|
|
72
|
+
params.timestamp,
|
|
73
|
+
params.initiator,
|
|
74
|
+
)
|
|
75
|
+
} else if ('response' in params) {
|
|
76
|
+
response = new ResponseStarted(
|
|
77
|
+
params.context,
|
|
78
|
+
params.navigation,
|
|
79
|
+
params.redirectCount,
|
|
80
|
+
params.request,
|
|
81
|
+
params.timestamp,
|
|
82
|
+
params.response,
|
|
83
|
+
)
|
|
84
|
+
} else if ('errorText' in params) {
|
|
85
|
+
response = new FetchError(
|
|
86
|
+
params.context,
|
|
87
|
+
params.navigation,
|
|
88
|
+
params.redirectCount,
|
|
89
|
+
params.request,
|
|
90
|
+
params.timestamp,
|
|
91
|
+
params.errorText,
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
callback(response)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async addIntercept(params) {
|
|
100
|
+
|
|
101
|
+
if (!params instanceof AddInterceptParameters) {
|
|
102
|
+
throw new Error(`Params must be an instance of AddInterceptParamenters. Received:'${params}'`)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const command = {
|
|
106
|
+
method: 'network.addIntercept',
|
|
107
|
+
params: Object.fromEntries(params.asMap())
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let response = await this.bidi.send(command)
|
|
111
|
+
|
|
112
|
+
return response.result.intercept
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async removeIntercept(interceptId) {
|
|
116
|
+
const command = {
|
|
117
|
+
method: 'network.removeIntercept',
|
|
118
|
+
params: {intercept: interceptId},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
await this.bidi.send(command)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async continueWithAuth(requestId, username, password) {
|
|
125
|
+
const command = {
|
|
126
|
+
method: 'network.continueWithAuth',
|
|
127
|
+
params: {
|
|
128
|
+
request: requestId.toString(),
|
|
129
|
+
action: 'provideCredentials',
|
|
130
|
+
credentials: {
|
|
131
|
+
type: 'password',
|
|
132
|
+
username: username,
|
|
133
|
+
password: password
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
await this.bidi.send(command)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async continueWithAuthNoCredentials(requestId) {
|
|
141
|
+
const command = {
|
|
142
|
+
method: 'network.continueWithAuth',
|
|
143
|
+
params: {
|
|
144
|
+
request: requestId.toString(),
|
|
145
|
+
action: 'default'
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
await this.bidi.send(command)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async cancelAuth(requestId) {
|
|
152
|
+
const command = {
|
|
153
|
+
method: 'network.continueWithAuth',
|
|
154
|
+
params: {
|
|
155
|
+
request: requestId.toString(),
|
|
156
|
+
action: 'cancel'
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
await this.bidi.send(command)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async close() {
|
|
163
|
+
await this.bidi.unsubscribe(
|
|
164
|
+
'network.beforeRequestSent',
|
|
165
|
+
'network.responseStarted',
|
|
166
|
+
'network.responseCompleted',
|
|
167
|
+
'network.authRequired')
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function getNetworkInstance(driver, browsingContextIds = null) {
|
|
173
|
+
let instance = new Network(driver, browsingContextIds)
|
|
174
|
+
await instance.init()
|
|
175
|
+
return instance
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
module.exports = getNetworkInstance
|
package/bidi/networkInspector.js
CHANGED
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
const { BeforeRequestSent, ResponseStarted } = require('./networkTypes')
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated
|
|
22
|
+
* in favor of using the `Network` class from `bidi/network.js`
|
|
23
|
+
* Inspector is specific to listening to events.
|
|
24
|
+
* Goal is to club commands and events under one class called Network.
|
|
25
|
+
*/
|
|
20
26
|
class NetworkInspector {
|
|
21
27
|
constructor(driver, browsingContextIds) {
|
|
22
28
|
this._driver = driver
|
|
@@ -65,7 +71,7 @@ class NetworkInspector {
|
|
|
65
71
|
params.redirectCount,
|
|
66
72
|
params.request,
|
|
67
73
|
params.timestamp,
|
|
68
|
-
params.initiator
|
|
74
|
+
params.initiator,
|
|
69
75
|
)
|
|
70
76
|
} else if ('response' in params) {
|
|
71
77
|
response = new ResponseStarted(
|
|
@@ -74,7 +80,7 @@ class NetworkInspector {
|
|
|
74
80
|
params.redirectCount,
|
|
75
81
|
params.request,
|
|
76
82
|
params.timestamp,
|
|
77
|
-
params.response
|
|
83
|
+
params.response,
|
|
78
84
|
)
|
|
79
85
|
}
|
|
80
86
|
callback(response)
|
package/bidi/networkTypes.js
CHANGED
|
@@ -38,18 +38,7 @@ class Header {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
class Cookie {
|
|
41
|
-
constructor(
|
|
42
|
-
name,
|
|
43
|
-
value,
|
|
44
|
-
binaryValue,
|
|
45
|
-
domain,
|
|
46
|
-
path,
|
|
47
|
-
expires,
|
|
48
|
-
size,
|
|
49
|
-
httpOnly,
|
|
50
|
-
secure,
|
|
51
|
-
sameSite
|
|
52
|
-
) {
|
|
41
|
+
constructor(name, value, binaryValue, domain, path, expires, size, httpOnly, secure, sameSite) {
|
|
53
42
|
this._name = name
|
|
54
43
|
this._value = value
|
|
55
44
|
this._binaryValue = binaryValue
|
|
@@ -118,7 +107,7 @@ class FetchTimingInfo {
|
|
|
118
107
|
tlsStart,
|
|
119
108
|
requestStart,
|
|
120
109
|
responseStart,
|
|
121
|
-
responseEnd
|
|
110
|
+
responseEnd,
|
|
122
111
|
) {
|
|
123
112
|
this._originTime = originTime
|
|
124
113
|
this._requestTime = requestTime
|
|
@@ -189,16 +178,7 @@ class FetchTimingInfo {
|
|
|
189
178
|
}
|
|
190
179
|
|
|
191
180
|
class RequestData {
|
|
192
|
-
constructor(
|
|
193
|
-
request,
|
|
194
|
-
url,
|
|
195
|
-
method,
|
|
196
|
-
headers,
|
|
197
|
-
cookies,
|
|
198
|
-
headersSize,
|
|
199
|
-
bodySize,
|
|
200
|
-
timings
|
|
201
|
-
) {
|
|
181
|
+
constructor(request, url, method, headers, cookies, headersSize, bodySize, timings) {
|
|
202
182
|
this._request = request
|
|
203
183
|
this._url = url
|
|
204
184
|
this._method = method
|
|
@@ -224,20 +204,7 @@ class RequestData {
|
|
|
224
204
|
let binaryValue = 'binaryValue' in cookie ? cookie.binaryValue : null
|
|
225
205
|
let expires = 'expires' in cookie ? cookie.expires : null
|
|
226
206
|
|
|
227
|
-
this._cookies.push(
|
|
228
|
-
new Cookie(
|
|
229
|
-
name,
|
|
230
|
-
value,
|
|
231
|
-
binaryValue,
|
|
232
|
-
domain,
|
|
233
|
-
path,
|
|
234
|
-
expires,
|
|
235
|
-
size,
|
|
236
|
-
httpOnly,
|
|
237
|
-
secure,
|
|
238
|
-
sameSite
|
|
239
|
-
)
|
|
240
|
-
)
|
|
207
|
+
this._cookies.push(new Cookie(name, value, binaryValue, domain, path, expires, size, httpOnly, secure, sameSite))
|
|
241
208
|
})
|
|
242
209
|
this._headersSize = headersSize
|
|
243
210
|
this._bodySize = bodySize
|
|
@@ -254,7 +221,7 @@ class RequestData {
|
|
|
254
221
|
timings.tlsStart,
|
|
255
222
|
timings.requestStart,
|
|
256
223
|
timings.responseStart,
|
|
257
|
-
timings.responseEnd
|
|
224
|
+
timings.responseEnd,
|
|
258
225
|
)
|
|
259
226
|
}
|
|
260
227
|
|
|
@@ -296,12 +263,7 @@ class BaseParameters {
|
|
|
296
263
|
this._id = id
|
|
297
264
|
this._navigation =
|
|
298
265
|
navigation != null
|
|
299
|
-
? new NavigationInfo(
|
|
300
|
-
navigation.context,
|
|
301
|
-
navigation.navigation,
|
|
302
|
-
navigation.timestamp,
|
|
303
|
-
navigation.url
|
|
304
|
-
)
|
|
266
|
+
? new NavigationInfo(navigation.context, navigation.navigation, navigation.timestamp, navigation.url)
|
|
305
267
|
: null
|
|
306
268
|
this._redirectCount = redirectCount
|
|
307
269
|
this._request = new RequestData(
|
|
@@ -312,7 +274,7 @@ class BaseParameters {
|
|
|
312
274
|
request.cookies,
|
|
313
275
|
request.headersSize,
|
|
314
276
|
request.bodySize,
|
|
315
|
-
request.timings
|
|
277
|
+
request.timings,
|
|
316
278
|
)
|
|
317
279
|
this._timestamp = timestamp
|
|
318
280
|
}
|
|
@@ -376,7 +338,7 @@ class BeforeRequestSent extends BaseParameters {
|
|
|
376
338
|
initiator.columnNumber,
|
|
377
339
|
initiator.lineNumber,
|
|
378
340
|
initiator.stackTrace,
|
|
379
|
-
initiator.request
|
|
341
|
+
initiator.request,
|
|
380
342
|
)
|
|
381
343
|
}
|
|
382
344
|
|
|
@@ -385,6 +347,17 @@ class BeforeRequestSent extends BaseParameters {
|
|
|
385
347
|
}
|
|
386
348
|
}
|
|
387
349
|
|
|
350
|
+
class FetchError extends BaseParameters {
|
|
351
|
+
constructor(id, navigation, redirectCount, request, timestamp, errorText) {
|
|
352
|
+
super(id, navigation, redirectCount, request, timestamp)
|
|
353
|
+
this._errorText = errorText
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
get errorText() {
|
|
357
|
+
return this._errorText
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
388
361
|
class ResponseData {
|
|
389
362
|
constructor(
|
|
390
363
|
url,
|
|
@@ -397,7 +370,7 @@ class ResponseData {
|
|
|
397
370
|
bytesReceived,
|
|
398
371
|
headersSize,
|
|
399
372
|
bodySize,
|
|
400
|
-
content
|
|
373
|
+
content,
|
|
401
374
|
) {
|
|
402
375
|
this._url = url
|
|
403
376
|
this._protocol = protocol
|
|
@@ -471,7 +444,7 @@ class ResponseStarted extends BaseParameters {
|
|
|
471
444
|
response.bytesReceived,
|
|
472
445
|
response.headerSize,
|
|
473
446
|
response.bodySize,
|
|
474
|
-
response.content
|
|
447
|
+
response.content,
|
|
475
448
|
)
|
|
476
449
|
}
|
|
477
450
|
|
|
@@ -480,4 +453,4 @@ class ResponseStarted extends BaseParameters {
|
|
|
480
453
|
}
|
|
481
454
|
}
|
|
482
455
|
|
|
483
|
-
module.exports = { BeforeRequestSent, ResponseStarted }
|
|
456
|
+
module.exports = { BeforeRequestSent, ResponseStarted, FetchError }
|
package/bidi/protocolType.js
CHANGED
|
@@ -27,9 +27,7 @@ const PrimitiveType = {
|
|
|
27
27
|
findByName(name) {
|
|
28
28
|
return (
|
|
29
29
|
Object.values(this).find((type) => {
|
|
30
|
-
return (
|
|
31
|
-
typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
32
|
-
)
|
|
30
|
+
return typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
33
31
|
}) || null
|
|
34
32
|
)
|
|
35
33
|
},
|
|
@@ -47,9 +45,7 @@ const NonPrimitiveType = {
|
|
|
47
45
|
findByName(name) {
|
|
48
46
|
return (
|
|
49
47
|
Object.values(this).find((type) => {
|
|
50
|
-
return (
|
|
51
|
-
typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
52
|
-
)
|
|
48
|
+
return typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
53
49
|
}) || null
|
|
54
50
|
)
|
|
55
51
|
},
|
|
@@ -75,9 +71,7 @@ const RemoteType = {
|
|
|
75
71
|
findByName(name) {
|
|
76
72
|
return (
|
|
77
73
|
Object.values(this).find((type) => {
|
|
78
|
-
return (
|
|
79
|
-
typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
80
|
-
)
|
|
74
|
+
return typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
81
75
|
}) || null
|
|
82
76
|
)
|
|
83
77
|
},
|
package/bidi/protocolValue.js
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
const {
|
|
19
|
-
PrimitiveType,
|
|
20
|
-
NonPrimitiveType,
|
|
21
|
-
RemoteType,
|
|
22
|
-
} = require('./protocolType')
|
|
18
|
+
const { PrimitiveType, NonPrimitiveType, RemoteType } = require('./protocolType')
|
|
23
19
|
|
|
24
20
|
const TYPE_CONSTANT = 'type'
|
|
25
21
|
const VALUE_CONSTANT = 'value'
|
|
@@ -106,12 +102,7 @@ class LocalValue {
|
|
|
106
102
|
let toReturn = {}
|
|
107
103
|
toReturn[TYPE_CONSTANT] = this.type
|
|
108
104
|
|
|
109
|
-
if (
|
|
110
|
-
!(
|
|
111
|
-
this.type === PrimitiveType.NULL ||
|
|
112
|
-
this.type === PrimitiveType.UNDEFINED
|
|
113
|
-
)
|
|
114
|
-
) {
|
|
105
|
+
if (!(this.type === PrimitiveType.NULL || this.type === PrimitiveType.UNDEFINED)) {
|
|
115
106
|
toReturn[VALUE_CONSTANT] = this.value
|
|
116
107
|
}
|
|
117
108
|
return toReturn
|
|
@@ -200,18 +191,12 @@ class RegExpValue {
|
|
|
200
191
|
}
|
|
201
192
|
|
|
202
193
|
class SerializationOptions {
|
|
203
|
-
constructor(
|
|
204
|
-
maxDomDepth = 0,
|
|
205
|
-
maxObjectDepth = null,
|
|
206
|
-
includeShadowTree = 'none'
|
|
207
|
-
) {
|
|
194
|
+
constructor(maxDomDepth = 0, maxObjectDepth = null, includeShadowTree = 'none') {
|
|
208
195
|
this._maxDomDepth = maxDomDepth
|
|
209
196
|
this._maxObjectDepth = maxObjectDepth
|
|
210
197
|
|
|
211
198
|
if (['none', 'open', 'all'].includes(includeShadowTree)) {
|
|
212
|
-
throw Error(
|
|
213
|
-
`Valid types are 'none', 'open', and 'all'. Received: ${includeShadowTree}`
|
|
214
|
-
)
|
|
199
|
+
throw Error(`Valid types are 'none', 'open', and 'all'. Received: ${includeShadowTree}`)
|
|
215
200
|
}
|
|
216
201
|
this._includeShadowTree = includeShadowTree
|
|
217
202
|
}
|
|
@@ -225,9 +210,7 @@ class ChannelValue {
|
|
|
225
210
|
if (options instanceof SerializationOptions) {
|
|
226
211
|
this.options = options
|
|
227
212
|
} else {
|
|
228
|
-
throw Error(
|
|
229
|
-
`Pass in SerializationOptions object. Received: ${options} `
|
|
230
|
-
)
|
|
213
|
+
throw Error(`Pass in SerializationOptions object. Received: ${options} `)
|
|
231
214
|
}
|
|
232
215
|
}
|
|
233
216
|
|
|
@@ -235,9 +218,7 @@ class ChannelValue {
|
|
|
235
218
|
if (['root', 'none'].includes(resultOwnership)) {
|
|
236
219
|
this.resultOwnership = resultOwnership
|
|
237
220
|
} else {
|
|
238
|
-
throw Error(
|
|
239
|
-
`Valid types are 'root' and 'none. Received: ${resultOwnership}`
|
|
240
|
-
)
|
|
221
|
+
throw Error(`Valid types are 'root' and 'none. Received: ${resultOwnership}`)
|
|
241
222
|
}
|
|
242
223
|
}
|
|
243
224
|
}
|
package/bidi/realmInfo.js
CHANGED
|
@@ -28,9 +28,7 @@ const RealmType = {
|
|
|
28
28
|
findByName(name) {
|
|
29
29
|
return (
|
|
30
30
|
Object.values(this).find((type) => {
|
|
31
|
-
return (
|
|
32
|
-
typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
33
|
-
)
|
|
31
|
+
return typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
|
|
34
32
|
}) || null
|
|
35
33
|
)
|
|
36
34
|
},
|
|
@@ -72,13 +70,7 @@ class RealmInfo {
|
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
if (realmType === RealmType.WINDOW) {
|
|
75
|
-
return new WindowRealmInfo(
|
|
76
|
-
realmId,
|
|
77
|
-
origin,
|
|
78
|
-
realmType,
|
|
79
|
-
browsingContext,
|
|
80
|
-
sandbox
|
|
81
|
-
)
|
|
73
|
+
return new WindowRealmInfo(realmId, origin, realmType, browsingContext, sandbox)
|
|
82
74
|
}
|
|
83
75
|
|
|
84
76
|
return new RealmInfo(realmId, origin, realmType)
|