selenium-webdriver 4.18.1 → 4.20.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 +946 -743
- package/README.md +71 -72
- package/bidi/addInterceptParameters.js +65 -45
- package/bidi/argumentValue.js +1 -0
- package/bidi/browser.js +94 -0
- package/bidi/browsingContext.js +214 -32
- package/bidi/browsingContextInspector.js +51 -0
- package/bidi/browsingContextTypes.js +31 -0
- package/bidi/captureScreenshotParameters.js +96 -0
- package/bidi/clipRectangle.js +127 -0
- package/bidi/continueRequestParameters.js +122 -0
- package/bidi/continueResponseParameters.js +129 -0
- package/bidi/cookieFilter.js +139 -0
- package/bidi/createContextParameters.js +73 -0
- package/bidi/evaluateResult.js +17 -0
- package/bidi/index.js +25 -26
- package/bidi/input.js +47 -3
- package/bidi/interceptPhase.js +5 -1
- package/bidi/logEntries.js +66 -0
- package/bidi/network.js +176 -23
- package/bidi/networkTypes.js +394 -17
- package/bidi/partialCookie.js +115 -0
- package/bidi/partitionDescriptor.js +102 -0
- package/bidi/partitionKey.js +53 -0
- package/bidi/protocolType.js +20 -0
- package/bidi/protocolValue.js +140 -9
- package/bidi/provideResponseParameters.js +123 -0
- package/bidi/realmInfo.js +27 -0
- package/bidi/resultOwnership.js +4 -0
- package/bidi/scriptManager.js +131 -5
- package/bidi/scriptTypes.js +36 -0
- package/bidi/storage.js +201 -0
- package/bidi/urlPattern.js +36 -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 +13 -9
- package/common/driverFinder.js +36 -4
- package/common/seleniumManager.js +7 -39
- package/devtools/CDPConnection.js +1 -0
- package/devtools/networkinterceptor.js +1 -0
- package/eslint.config.js +107 -0
- package/firefox.js +20 -6
- package/http/index.js +6 -6
- package/http/util.js +1 -0
- package/ie.js +8 -4
- package/index.js +11 -0
- package/io/exec.js +1 -1
- package/io/index.js +3 -2
- package/io/zip.js +1 -1
- package/lib/atoms/find-elements.js +26 -26
- package/lib/atoms/is-displayed.js +24 -97
- package/lib/capabilities.js +5 -5
- package/lib/http.js +8 -4
- package/lib/input.js +0 -1
- package/lib/pinnedScript.js +1 -1
- package/lib/select.js +8 -8
- package/lib/until.js +3 -3
- package/lib/util.js +1 -0
- package/lib/virtual_authenticator.js +8 -8
- package/lib/webdriver.js +8 -3
- package/net/index.js +1 -1
- package/net/portprober.js +1 -1
- package/package.json +21 -13
- package/remote/index.js +1 -1
- package/remote/util.js +2 -2
- package/safari.js +3 -3
- package/testing/index.js +17 -8
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Represents a clip rectangle.
|
|
20
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-browsingContext-captureScreenshot.
|
|
21
|
+
*/
|
|
22
|
+
class ClipRectangle {
|
|
23
|
+
clipType
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new ClipRectangle object.
|
|
27
|
+
* @param {string} type - The type of the clip rectangle.
|
|
28
|
+
*/
|
|
29
|
+
constructor(type) {
|
|
30
|
+
this.clipType = type
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Gets the type of the clip rectangle.
|
|
35
|
+
* @returns {string} The type of the clip rectangle.
|
|
36
|
+
*/
|
|
37
|
+
get type() {
|
|
38
|
+
return this.clipType
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
asMap() {}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Represents a clip rectangle for an element.
|
|
46
|
+
* @extends ClipRectangle
|
|
47
|
+
*/
|
|
48
|
+
class ElementClipRectangle extends ClipRectangle {
|
|
49
|
+
#sharedId
|
|
50
|
+
#handleId
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Constructs a new ElementClipRectangle instance.
|
|
54
|
+
* @param {string} sharedId - The shared ID of the element.
|
|
55
|
+
* @param {string} [handleId] - The handle ID of the element (optional).
|
|
56
|
+
*/
|
|
57
|
+
constructor(sharedId, handleId = undefined) {
|
|
58
|
+
super('element')
|
|
59
|
+
this.#sharedId = sharedId
|
|
60
|
+
|
|
61
|
+
if (handleId !== undefined) {
|
|
62
|
+
this.#handleId = handleId
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Converts the ElementClipRectangle instance to a map.
|
|
68
|
+
* @returns {Map} - The converted map.
|
|
69
|
+
*/
|
|
70
|
+
asMap() {
|
|
71
|
+
const map = new Map()
|
|
72
|
+
map.set('type', super.type)
|
|
73
|
+
|
|
74
|
+
const sharedReference = new Map()
|
|
75
|
+
sharedReference.set('sharedId', this.#sharedId)
|
|
76
|
+
if (this.#handleId !== undefined) {
|
|
77
|
+
sharedReference.set('handleId', this.#handleId)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
map.set('element', Object.fromEntries(sharedReference))
|
|
81
|
+
|
|
82
|
+
return map
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Represents a box-shaped clip rectangle.
|
|
88
|
+
* @extends ClipRectangle
|
|
89
|
+
*/
|
|
90
|
+
class BoxClipRectangle extends ClipRectangle {
|
|
91
|
+
#x
|
|
92
|
+
#y
|
|
93
|
+
#width
|
|
94
|
+
#height
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Constructs a new BoxClipRectangle object.
|
|
98
|
+
* @param {number} x - The x-coordinate of the top-left corner of the rectangle.
|
|
99
|
+
* @param {number} y - The y-coordinate of the top-left corner of the rectangle.
|
|
100
|
+
* @param {number} width - The width of the rectangle.
|
|
101
|
+
* @param {number} height - The height of the rectangle.
|
|
102
|
+
*/
|
|
103
|
+
constructor(x, y, width, height) {
|
|
104
|
+
super('box')
|
|
105
|
+
this.#x = x
|
|
106
|
+
this.#y = y
|
|
107
|
+
this.#width = width
|
|
108
|
+
this.#height = height
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Converts the BoxClipRectangle object to a Map.
|
|
113
|
+
* @returns {Map<string, any>} - The Map representation of the BoxClipRectangle object.
|
|
114
|
+
*/
|
|
115
|
+
asMap() {
|
|
116
|
+
const map = new Map()
|
|
117
|
+
map.set('type', super.type)
|
|
118
|
+
map.set('x', this.#x)
|
|
119
|
+
map.set('y', this.#y)
|
|
120
|
+
map.set('width', this.#width)
|
|
121
|
+
map.set('height', this.#height)
|
|
122
|
+
|
|
123
|
+
return map
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
module.exports = { BoxClipRectangle, ElementClipRectangle }
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
/**
|
|
21
|
+
* Represents the parameters for a continue request command.
|
|
22
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-network-continueRequest.
|
|
23
|
+
*/
|
|
24
|
+
class ContinueRequestParameters {
|
|
25
|
+
#map = new Map()
|
|
26
|
+
|
|
27
|
+
constructor(request) {
|
|
28
|
+
this.#map.set('request', request)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sets the body value for the request.
|
|
33
|
+
*
|
|
34
|
+
* @param {BytesValue} value - The value to set as the body. Must be an instance of BytesValue.
|
|
35
|
+
* @returns {ContinueRequestParameters} - The current instance of the ContinueRequestParameters for chaining.
|
|
36
|
+
* @throws {Error} - If the value is not an instance of BytesValue.
|
|
37
|
+
*/
|
|
38
|
+
body(value) {
|
|
39
|
+
if (!(value instanceof BytesValue)) {
|
|
40
|
+
throw new Error(`Value must be an instance of BytesValue. Received: '${value})'`)
|
|
41
|
+
}
|
|
42
|
+
this.#map.set('body', Object.fromEntries(value.asMap()))
|
|
43
|
+
return this
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sets the cookies for the request.
|
|
48
|
+
*
|
|
49
|
+
* @param {Header[]} cookieHeaders - An array of cookie headers.
|
|
50
|
+
* @returns {continueRequestParameters} - The current instance of the ContinueRequestParameters for chaining.
|
|
51
|
+
* @throws {Error} - If a cookie header is not an instance of Header.
|
|
52
|
+
*/
|
|
53
|
+
cookies(cookieHeaders) {
|
|
54
|
+
const cookies = []
|
|
55
|
+
cookieHeaders.forEach((header) => {
|
|
56
|
+
if (!(header instanceof Header)) {
|
|
57
|
+
throw new Error(`CookieHeader must be an instance of Header. Received:'${header}'`)
|
|
58
|
+
}
|
|
59
|
+
cookies.push(Object.fromEntries(header.asMap()))
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
this.#map.set('cookies', cookies)
|
|
63
|
+
return this
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sets the headers for the request.
|
|
68
|
+
*
|
|
69
|
+
* @param {Header[]} headers - An array of Header objects.
|
|
70
|
+
* @returns {ContinueRequestParameters} - The current instance of the ContinueRequestParameters for chaining.
|
|
71
|
+
* @throws {Error} - If the header value is not an instance of Header.
|
|
72
|
+
*/
|
|
73
|
+
headers(headers) {
|
|
74
|
+
const headerList = []
|
|
75
|
+
headers.forEach((header) => {
|
|
76
|
+
if (!(header instanceof Header)) {
|
|
77
|
+
throw new Error(`Header value must be an instance of Header. Received:'${header}'`)
|
|
78
|
+
}
|
|
79
|
+
headerList.push(Object.fromEntries(header.asMap()))
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
this.#map.set('headers', headerList)
|
|
83
|
+
return this
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Sets the HTTP method for the request.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} method - The HTTP method to be set.
|
|
90
|
+
* @returns {ContinueRequestParameters} - The updated `continueRequestParameters` object.
|
|
91
|
+
* @throws {Error} - If the method parameter is not a string.
|
|
92
|
+
*/
|
|
93
|
+
method(method) {
|
|
94
|
+
if (typeof method !== 'string') {
|
|
95
|
+
throw new Error(`Http method must be a string. Received: '${method})'`)
|
|
96
|
+
}
|
|
97
|
+
this.#map.set('method', method)
|
|
98
|
+
return this
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Sets the URL for the request.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} url - The URL to set for the request.
|
|
105
|
+
* @returns {ContinueRequestParameters} - The current instance of the ContinueRequestParameters for chaining.
|
|
106
|
+
* @throws {Error} - If the url parameter is not a string.
|
|
107
|
+
*/
|
|
108
|
+
url(url) {
|
|
109
|
+
if (typeof url !== 'string') {
|
|
110
|
+
throw new Error(`Url must be a string. Received:'${url}'`)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.#map.set('url', url)
|
|
114
|
+
return this
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
asMap() {
|
|
118
|
+
return this.#map
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = { ContinueRequestParameters }
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
/**
|
|
21
|
+
* Represents the parameters for a continue response.
|
|
22
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-network-continueResponse.
|
|
23
|
+
*/
|
|
24
|
+
class ContinueResponseParameters {
|
|
25
|
+
#map = new Map()
|
|
26
|
+
|
|
27
|
+
constructor(request) {
|
|
28
|
+
this.#map.set('request', request)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sets the cookies for the response.
|
|
33
|
+
*
|
|
34
|
+
* @param {Header[]} cookieHeaders - The array of cookie headers.
|
|
35
|
+
* @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.
|
|
36
|
+
* @throws {Error} - If the cookieHeader is not an instance of Header.
|
|
37
|
+
*/
|
|
38
|
+
cookies(cookieHeaders) {
|
|
39
|
+
const cookies = []
|
|
40
|
+
cookieHeaders.forEach((header) => {
|
|
41
|
+
if (!(header instanceof Header)) {
|
|
42
|
+
throw new Error(`CookieHeader must be an instance of Header. Received:'${header}'`)
|
|
43
|
+
}
|
|
44
|
+
cookies.push(Object.fromEntries(header.asMap()))
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
this.#map.set('cookies', cookies)
|
|
48
|
+
return this
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets the credentials for authentication.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} username - The username for authentication.
|
|
55
|
+
* @param {string} password - The password for authentication.
|
|
56
|
+
* @returns {ContinueResponseParameters} The current instance of the ContinueResponseParameters for chaining.
|
|
57
|
+
* @throws {Error} If username or password is not a string.
|
|
58
|
+
*/
|
|
59
|
+
credentials(username, password) {
|
|
60
|
+
if (typeof username !== 'string') {
|
|
61
|
+
throw new Error(`Username must be a string. Received:'${username}'`)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof password !== 'string') {
|
|
65
|
+
throw new Error(`Password must be a string. Received:'${password}'`)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.#map.set('credentials', { type: 'password', username: username, password: password })
|
|
69
|
+
|
|
70
|
+
return this
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sets the headers for the response.
|
|
75
|
+
*
|
|
76
|
+
* @param {Header[]} headers - An array of Header objects representing the headers.
|
|
77
|
+
* @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.
|
|
78
|
+
* @throws {Error} - If the header value is not an instance of Header.
|
|
79
|
+
*/
|
|
80
|
+
headers(headers) {
|
|
81
|
+
const headerList = []
|
|
82
|
+
headers.forEach((header) => {
|
|
83
|
+
if (!(header instanceof Header)) {
|
|
84
|
+
throw new Error(`Header value must be an instance of Header. Received:'${header}'`)
|
|
85
|
+
}
|
|
86
|
+
headerList.push(Object.fromEntries(header.asMap()))
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
this.#map.set('headers', headerList)
|
|
90
|
+
return this
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Sets the reason phrase for the response.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} reasonPhrase - The reason phrase for the response.
|
|
97
|
+
* @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.
|
|
98
|
+
* @throws {Error} - If the reason phrase is not a string.
|
|
99
|
+
*/
|
|
100
|
+
reasonPhrase(reasonPhrase) {
|
|
101
|
+
if (typeof reasonPhrase !== 'string') {
|
|
102
|
+
throw new Error(`Reason phrase must be a string. Received: '${reasonPhrase})'`)
|
|
103
|
+
}
|
|
104
|
+
this.#map.set('reasonPhrase', reasonPhrase)
|
|
105
|
+
return this
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Sets the status code for the response.
|
|
110
|
+
*
|
|
111
|
+
* @param {number} statusCode - The status code to set.
|
|
112
|
+
* @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.
|
|
113
|
+
* @throws {Error} - If the `statusCode` parameter is not an integer.
|
|
114
|
+
*/
|
|
115
|
+
statusCode(statusCode) {
|
|
116
|
+
if (!Number.isInteger(statusCode)) {
|
|
117
|
+
throw new Error(`Status must be an integer. Received:'${statusCode}'`)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.#map.set('statusCode', statusCode)
|
|
121
|
+
return this
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
asMap() {
|
|
125
|
+
return this.#map
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { ContinueResponseParameters }
|
|
@@ -0,0 +1,139 @@
|
|
|
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 { SameSite, BytesValue } = require('./networkTypes')
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents a filter for fetching cookies.
|
|
22
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-storage-getCookies
|
|
23
|
+
*/
|
|
24
|
+
class CookieFilter {
|
|
25
|
+
#map = new Map()
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Sets the name of the cookie.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} name - The name of the cookie.
|
|
31
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
32
|
+
*/
|
|
33
|
+
name(name) {
|
|
34
|
+
this.#map.set('name', name)
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets the value of the cookie.
|
|
40
|
+
*
|
|
41
|
+
* @param {BytesValue} value - The value to be set. Must be an instance of BytesValue.
|
|
42
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
43
|
+
* @throws {Error} - If the value is not an instance of BytesValue.
|
|
44
|
+
*/
|
|
45
|
+
value(value) {
|
|
46
|
+
if (!(value instanceof BytesValue)) {
|
|
47
|
+
throw new Error(`Value must be an instance of BytesValue. Received:'${value}'`)
|
|
48
|
+
}
|
|
49
|
+
this.#map.set('value', Object.fromEntries(value.asMap()))
|
|
50
|
+
return this
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Sets the domain for the cookie.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} domain - The domain to set.
|
|
57
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
58
|
+
*/
|
|
59
|
+
domain(domain) {
|
|
60
|
+
this.#map.set('domain', domain)
|
|
61
|
+
return this
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Sets the url path for the cookie to be fetched.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} path - The url path for the cookie to be fetched.
|
|
68
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
69
|
+
*/
|
|
70
|
+
path(path) {
|
|
71
|
+
this.#map.set('path', path)
|
|
72
|
+
return this
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Sets the size of the cookie to be fetched.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} size - The size of the cookie.
|
|
79
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
80
|
+
*/
|
|
81
|
+
size(size) {
|
|
82
|
+
this.#map.set('size', size)
|
|
83
|
+
return this
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Sets the `httpOnly` flag for the cookie filter.
|
|
88
|
+
*
|
|
89
|
+
* @param {boolean} httpOnly - The value to set for the `httpOnly` flag.
|
|
90
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
91
|
+
*/
|
|
92
|
+
httpOnly(httpOnly) {
|
|
93
|
+
this.#map.set('httpOnly', httpOnly)
|
|
94
|
+
return this
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Sets the flag to fetch secure cookies.
|
|
99
|
+
*
|
|
100
|
+
* @param {boolean} secure - Whether the cookie fetched should be secure only or not.
|
|
101
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
102
|
+
*/
|
|
103
|
+
secure(secure) {
|
|
104
|
+
this.#map.set('secure', secure)
|
|
105
|
+
return this
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Sets the SameSite attribute for the cookie.
|
|
110
|
+
*
|
|
111
|
+
* @param {SameSite} sameSite - The SameSite value to be set for the cookie.
|
|
112
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
113
|
+
* @throws {Error} - If the provided sameSite value is not an instance of SameSite.
|
|
114
|
+
*/
|
|
115
|
+
sameSite(sameSite) {
|
|
116
|
+
if (!(sameSite instanceof SameSite)) {
|
|
117
|
+
throw new Error(`Params must be a value in SameSite. Received:'${sameSite}'`)
|
|
118
|
+
}
|
|
119
|
+
this.#map.set('sameSite', sameSite)
|
|
120
|
+
return this
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sets the expiry value.
|
|
125
|
+
*
|
|
126
|
+
* @param {number} expiry - The expiry value.
|
|
127
|
+
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
|
|
128
|
+
*/
|
|
129
|
+
expiry(expiry) {
|
|
130
|
+
this.#map.set('expiry', expiry)
|
|
131
|
+
return this
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
asMap() {
|
|
135
|
+
return this.#map
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
module.exports = { CookieFilter }
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Represents a set of parameters for creating a context.
|
|
20
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-browsingContext-create.
|
|
21
|
+
*/
|
|
22
|
+
class CreateContextParameters {
|
|
23
|
+
#map = new Map()
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sets the reference context.
|
|
27
|
+
* @param {string} id - The ID of the reference context.
|
|
28
|
+
* @returns {CreateContextParameters} - The updated instance of CreateContextParameters for chaining.
|
|
29
|
+
* @throws {Error} - If the provided ID is not a string.
|
|
30
|
+
*/
|
|
31
|
+
referenceContext(id) {
|
|
32
|
+
if (typeof id !== 'string') {
|
|
33
|
+
throw new Error(`ReferenceContext must be string. Received:'${id}'`)
|
|
34
|
+
}
|
|
35
|
+
this.#map.set('referenceContext', id)
|
|
36
|
+
return this
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sets the background parameter.
|
|
41
|
+
*
|
|
42
|
+
* @param {boolean} background - The background value to set.
|
|
43
|
+
* @returns {CreateContextParameters} - The updated instance of CreateContextParameters for chaining.
|
|
44
|
+
* @throws {Error} - If the background parameter is not a boolean.
|
|
45
|
+
*/
|
|
46
|
+
background(background) {
|
|
47
|
+
if (typeof background !== 'boolean') {
|
|
48
|
+
throw new Error(`Background must be boolean. Received:'${background}'`)
|
|
49
|
+
}
|
|
50
|
+
this.#map.set('background', background)
|
|
51
|
+
return this
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Sets the user context.
|
|
56
|
+
* @param {string} userContext - The user context to set.
|
|
57
|
+
* @returns {CreateContextParameters} - The updated instance of CreateContextParameters for chaining.
|
|
58
|
+
* @throws {Error} - If the userContext parameter is not a string.
|
|
59
|
+
*/
|
|
60
|
+
userContext(userContext) {
|
|
61
|
+
if (typeof userContext !== 'string') {
|
|
62
|
+
throw new Error(`UserContext must be string. Received:'${userContext}'`)
|
|
63
|
+
}
|
|
64
|
+
this.#map.set('userContext', userContext)
|
|
65
|
+
return this
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
asMap() {
|
|
69
|
+
return this.#map
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = { CreateContextParameters }
|
package/bidi/evaluateResult.js
CHANGED
|
@@ -15,11 +15,20 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Represents the type of script evaluation result.
|
|
20
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-EvaluateResult.
|
|
21
|
+
* @enum {string}
|
|
22
|
+
*/
|
|
18
23
|
const EvaluateResultType = {
|
|
19
24
|
SUCCESS: 'success',
|
|
20
25
|
EXCEPTION: 'exception',
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Represents a successful evaluation result.
|
|
30
|
+
* @class
|
|
31
|
+
*/
|
|
23
32
|
class EvaluateResultSuccess {
|
|
24
33
|
constructor(realmId, value) {
|
|
25
34
|
this.resultType = EvaluateResultType.SUCCESS
|
|
@@ -28,6 +37,10 @@ class EvaluateResultSuccess {
|
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Represents an exception that occurred during evaluation of a result.
|
|
42
|
+
* @class
|
|
43
|
+
*/
|
|
31
44
|
class EvaluateResultException {
|
|
32
45
|
constructor(realmId, exceptionDetails) {
|
|
33
46
|
this.resultType = EvaluateResultType.EXCEPTION
|
|
@@ -36,6 +49,10 @@ class EvaluateResultException {
|
|
|
36
49
|
}
|
|
37
50
|
}
|
|
38
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Represents details of an exception.
|
|
54
|
+
* @class
|
|
55
|
+
*/
|
|
39
56
|
class ExceptionDetails {
|
|
40
57
|
constructor(exceptionDetails) {
|
|
41
58
|
this.columnNumber = 'columnNumber' in exceptionDetails ? exceptionDetails['columnNumber'] : null
|