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,115 @@
|
|
|
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 } = require('./networkTypes')
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents a partial cookie used to set cookies.
|
|
22
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-storage-setCookie.
|
|
23
|
+
* @class
|
|
24
|
+
*/
|
|
25
|
+
class PartialCookie {
|
|
26
|
+
#map = new Map()
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Represents a partial cookie.
|
|
30
|
+
* @class
|
|
31
|
+
* @param {string} name - The name of the cookie.
|
|
32
|
+
* @param {BytesValue} value - The value of the cookie as an instance of BytesValue.
|
|
33
|
+
* @param {string} domain - The domain of the cookie.
|
|
34
|
+
*/
|
|
35
|
+
constructor(name, value, domain) {
|
|
36
|
+
this.#map.set('name', name)
|
|
37
|
+
if (!(value instanceof BytesValue)) {
|
|
38
|
+
throw new Error(`Value must be an instance of BytesValue. Received:'${value}'`)
|
|
39
|
+
}
|
|
40
|
+
this.#map.set('value', Object.fromEntries(value.asMap()))
|
|
41
|
+
this.#map.set('domain', domain)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sets the path for the cookie.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} path - The path for the cookie.
|
|
48
|
+
* @returns {PartialCookie} - The updated PartialCookie instance for chaining.
|
|
49
|
+
*/
|
|
50
|
+
path(path) {
|
|
51
|
+
this.#map.set('path', path)
|
|
52
|
+
return this
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Sets the size of the cookie.
|
|
57
|
+
*
|
|
58
|
+
* @param {number} size - The size of the cookie.
|
|
59
|
+
* @returns {PartialCookie} - The updated PartialCookie instance for chaining.
|
|
60
|
+
*/
|
|
61
|
+
size(size) {
|
|
62
|
+
this.#map.set('size', size)
|
|
63
|
+
return this
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sets the `httpOnly` flag for the cookie.
|
|
68
|
+
*
|
|
69
|
+
* @param {boolean} httpOnly - The value to set for the `httpOnly` flag.
|
|
70
|
+
* @returns {PartialCookie} - The updated PartialCookie instance for chaining.
|
|
71
|
+
*/
|
|
72
|
+
httpOnly(httpOnly) {
|
|
73
|
+
this.#map.set('httpOnly', httpOnly)
|
|
74
|
+
return this
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Sets the secure flag for the cookie.
|
|
79
|
+
*
|
|
80
|
+
* @param {boolean} secure - Indicates whether the cookie should only be sent over secure connections.
|
|
81
|
+
* @returns {PartialCookie} - The updated PartialCookie instance for chaining.
|
|
82
|
+
*/
|
|
83
|
+
secure(secure) {
|
|
84
|
+
this.#map.set('secure', secure)
|
|
85
|
+
return this
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Sets the SameSite attribute for the cookie.
|
|
90
|
+
*
|
|
91
|
+
* @param {SameSite} sameSite - The SameSite attribute value for the cookie.
|
|
92
|
+
* @returns {PartialCookie} - The updated PartialCookie instance for chaining.
|
|
93
|
+
*/
|
|
94
|
+
sameSite(sameSite) {
|
|
95
|
+
this.#map.set('sameSite', sameSite)
|
|
96
|
+
return this
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Sets the expiry for the cookie.
|
|
101
|
+
*
|
|
102
|
+
* @param {number} expiry - The expiry time of the cookie.
|
|
103
|
+
* @returns {PartialCookie} - The updated PartialCookie instance for chaining.
|
|
104
|
+
*/
|
|
105
|
+
expiry(expiry) {
|
|
106
|
+
this.#map.set('expiry', expiry)
|
|
107
|
+
return this
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
asMap() {
|
|
111
|
+
return this.#map
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = { PartialCookie }
|
|
@@ -0,0 +1,102 @@
|
|
|
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 the types of partition descriptors.
|
|
20
|
+
* @enum {string}
|
|
21
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-storage-getCookies.
|
|
22
|
+
*/
|
|
23
|
+
const Type = {
|
|
24
|
+
CONTEXT: 'context',
|
|
25
|
+
STORAGE_KEY: 'storageKey',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Represents a partition descriptor.
|
|
30
|
+
* Described in https://w3c.github.io/webdriver-bidi/#command-storage-getCookies.
|
|
31
|
+
*/
|
|
32
|
+
class PartitionDescriptor {
|
|
33
|
+
/*eslint no-unused-private-class-members: "off"*/
|
|
34
|
+
#type
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Constructs a new PartitionDescriptor instance.
|
|
38
|
+
* @param {Type} type - The type of the partition.
|
|
39
|
+
*/
|
|
40
|
+
constructor(type) {
|
|
41
|
+
this.#type = type
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Represents a partition descriptor for a browsing context.
|
|
47
|
+
* @extends PartitionDescriptor
|
|
48
|
+
*/
|
|
49
|
+
class BrowsingContextPartitionDescriptor extends PartitionDescriptor {
|
|
50
|
+
#context = null
|
|
51
|
+
|
|
52
|
+
constructor(context) {
|
|
53
|
+
super(Type.CONTEXT)
|
|
54
|
+
this.#context = context
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
asMap() {
|
|
58
|
+
const map = new Map()
|
|
59
|
+
map.set('type', Type.CONTEXT)
|
|
60
|
+
map.set('context', this.#context)
|
|
61
|
+
return map
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Represents a partition descriptor for storage key.
|
|
67
|
+
* @extends PartitionDescriptor
|
|
68
|
+
*/
|
|
69
|
+
class StorageKeyPartitionDescriptor extends PartitionDescriptor {
|
|
70
|
+
#map = new Map()
|
|
71
|
+
|
|
72
|
+
constructor() {
|
|
73
|
+
super(Type.STORAGE_KEY)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Sets the user context for the partition descriptor.
|
|
78
|
+
* @param {any} userContext - The user context to set.
|
|
79
|
+
* @returns {PartitionDescriptor} - The updated partition descriptor instance for chaining.
|
|
80
|
+
*/
|
|
81
|
+
userContext(userContext) {
|
|
82
|
+
this.#map.set('userContext', userContext)
|
|
83
|
+
return this
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Sets the source origin for the partition descriptor.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} sourceOrigin - The source origin to set.
|
|
90
|
+
* @returns {PartitionDescriptor} - The updated PartitionDescriptor instance for chaining.
|
|
91
|
+
*/
|
|
92
|
+
sourceOrigin(sourceOrigin) {
|
|
93
|
+
this.#map.set('sourceOrigin', sourceOrigin)
|
|
94
|
+
return this
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
asMap() {
|
|
98
|
+
return this.#map
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = { BrowsingContextPartitionDescriptor, StorageKeyPartitionDescriptor }
|
|
@@ -0,0 +1,53 @@
|
|
|
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 partition key of cookie storage.
|
|
20
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey.
|
|
21
|
+
*/
|
|
22
|
+
class PartitionKey {
|
|
23
|
+
#userContext
|
|
24
|
+
#sourceOrigin
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a new PartitionKey object.
|
|
28
|
+
* @param {string} userContext - The user context.
|
|
29
|
+
* @param {string} sourceOrigin - The source origin.
|
|
30
|
+
*/
|
|
31
|
+
constructor(userContext, sourceOrigin) {
|
|
32
|
+
this.#userContext = userContext
|
|
33
|
+
this.#sourceOrigin = sourceOrigin
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets the user context.
|
|
38
|
+
* @returns {string} The user context.
|
|
39
|
+
*/
|
|
40
|
+
get userContext() {
|
|
41
|
+
return this.#userContext
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Gets the source origin.
|
|
46
|
+
* @returns {string} The source origin.
|
|
47
|
+
*/
|
|
48
|
+
get sourceOrigin() {
|
|
49
|
+
return this.#sourceOrigin
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = { PartitionKey }
|
package/bidi/protocolType.js
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Represents a primitive type.
|
|
20
|
+
* @enum
|
|
21
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-PrimitiveProtocolValue.
|
|
22
|
+
*/
|
|
18
23
|
const PrimitiveType = {
|
|
19
24
|
UNDEFINED: 'undefined',
|
|
20
25
|
NULL: 'null',
|
|
@@ -33,6 +38,11 @@ const PrimitiveType = {
|
|
|
33
38
|
},
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Represents a non-primitive type.
|
|
43
|
+
* @enum
|
|
44
|
+
* Described inhttps://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
|
|
45
|
+
*/
|
|
36
46
|
const NonPrimitiveType = {
|
|
37
47
|
ARRAY: 'array',
|
|
38
48
|
DATE: 'date',
|
|
@@ -51,6 +61,11 @@ const NonPrimitiveType = {
|
|
|
51
61
|
},
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Represents a remote value type.
|
|
66
|
+
* @enum
|
|
67
|
+
* Described inhttps://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
|
|
68
|
+
*/
|
|
54
69
|
const RemoteType = {
|
|
55
70
|
SYMBOL: 'symbol',
|
|
56
71
|
FUNCTION: 'function',
|
|
@@ -77,6 +92,11 @@ const RemoteType = {
|
|
|
77
92
|
},
|
|
78
93
|
}
|
|
79
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Represents a speacial number type.
|
|
97
|
+
* @enum
|
|
98
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-PrimitiveProtocolValue.
|
|
99
|
+
*/
|
|
80
100
|
const SpecialNumberType = {
|
|
81
101
|
NAN: 'NaN',
|
|
82
102
|
MINUS_ZERO: '-0',
|
package/bidi/protocolValue.js
CHANGED
|
@@ -19,11 +19,20 @@ const { PrimitiveType, NonPrimitiveType, RemoteType } = require('./protocolType'
|
|
|
19
19
|
|
|
20
20
|
const TYPE_CONSTANT = 'type'
|
|
21
21
|
const VALUE_CONSTANT = 'value'
|
|
22
|
+
/**
|
|
23
|
+
* Represents the types of remote reference.
|
|
24
|
+
* @enum {string}
|
|
25
|
+
*/
|
|
22
26
|
const RemoteReferenceType = {
|
|
23
27
|
HANDLE: 'handle',
|
|
24
28
|
SHARED_ID: 'sharedId',
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Represents a local value with a specified type and optional value.
|
|
33
|
+
* @class
|
|
34
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-LocalValue
|
|
35
|
+
*/
|
|
27
36
|
class LocalValue {
|
|
28
37
|
constructor(type, value = null) {
|
|
29
38
|
if (type === PrimitiveType.UNDEFINED || type === PrimitiveType.NULL) {
|
|
@@ -34,42 +43,97 @@ class LocalValue {
|
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new LocalValue object with a string value.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} value - The string value to be stored in the LocalValue object.
|
|
50
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
51
|
+
*/
|
|
37
52
|
static createStringValue(value) {
|
|
38
53
|
return new LocalValue(PrimitiveType.STRING, value)
|
|
39
54
|
}
|
|
40
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new LocalValue object with a number value.
|
|
58
|
+
*
|
|
59
|
+
* @param {number} value - The number value.
|
|
60
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
61
|
+
*/
|
|
41
62
|
static createNumberValue(value) {
|
|
42
63
|
return new LocalValue(PrimitiveType.NUMBER, value)
|
|
43
64
|
}
|
|
44
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new LocalValue object with a special number value.
|
|
68
|
+
*
|
|
69
|
+
* @param {number} value - The value of the special number.
|
|
70
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
71
|
+
*/
|
|
45
72
|
static createSpecialNumberValue(value) {
|
|
46
73
|
return new LocalValue(PrimitiveType.SPECIAL_NUMBER, value)
|
|
47
74
|
}
|
|
48
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new LocalValue object with an undefined value.
|
|
78
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
79
|
+
*/
|
|
49
80
|
static createUndefinedValue() {
|
|
50
81
|
return new LocalValue(PrimitiveType.UNDEFINED)
|
|
51
82
|
}
|
|
52
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new LocalValue object with a null value.
|
|
86
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
87
|
+
*/
|
|
53
88
|
static createNullValue() {
|
|
54
89
|
return new LocalValue(PrimitiveType.NULL)
|
|
55
90
|
}
|
|
56
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new LocalValue object with a boolean value.
|
|
94
|
+
*
|
|
95
|
+
* @param {boolean} value - The boolean value.
|
|
96
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
97
|
+
*/
|
|
57
98
|
static createBooleanValue(value) {
|
|
58
99
|
return new LocalValue(PrimitiveType.BOOLEAN, value)
|
|
59
100
|
}
|
|
60
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Creates a new LocalValue object with a BigInt value.
|
|
104
|
+
*
|
|
105
|
+
* @param {BigInt} value - The BigInt value.
|
|
106
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
107
|
+
*/
|
|
61
108
|
static createBigIntValue(value) {
|
|
62
109
|
return new LocalValue(PrimitiveType.BIGINT, value)
|
|
63
110
|
}
|
|
64
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new LocalValue object with an array.
|
|
114
|
+
*
|
|
115
|
+
* @param {Array} value - The array.
|
|
116
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
117
|
+
*/
|
|
65
118
|
static createArrayValue(value) {
|
|
66
119
|
return new LocalValue(NonPrimitiveType.ARRAY, value)
|
|
67
120
|
}
|
|
68
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Creates a new LocalValue object with date value.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} value - The date.
|
|
126
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
127
|
+
*/
|
|
69
128
|
static createDateValue(value) {
|
|
70
129
|
return new LocalValue(NonPrimitiveType.DATE, value)
|
|
71
130
|
}
|
|
72
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Creates a new LocalValue object of map value.
|
|
134
|
+
* @param {Map} map - The map.
|
|
135
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
136
|
+
*/
|
|
73
137
|
static createMapValue(map) {
|
|
74
138
|
let value = []
|
|
75
139
|
Object.entries(map).forEach((entry) => {
|
|
@@ -78,22 +142,45 @@ class LocalValue {
|
|
|
78
142
|
return new LocalValue(NonPrimitiveType.MAP, value)
|
|
79
143
|
}
|
|
80
144
|
|
|
81
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Creates a new LocalValue object from the passed object.
|
|
147
|
+
*
|
|
148
|
+
* @param {Object} map - The object.
|
|
149
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
150
|
+
*/
|
|
151
|
+
static createObjectValue(object) {
|
|
82
152
|
let value = []
|
|
83
|
-
Object.entries(
|
|
153
|
+
Object.entries(object).forEach((entry) => {
|
|
84
154
|
value.push(entry)
|
|
85
155
|
})
|
|
86
156
|
return new LocalValue(NonPrimitiveType.OBJECT, value)
|
|
87
157
|
}
|
|
88
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Creates a new LocalValue object of regular expression value.
|
|
161
|
+
*
|
|
162
|
+
* @param {string} value - The value of the regular expression.
|
|
163
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
164
|
+
*/
|
|
89
165
|
static createRegularExpressionValue(value) {
|
|
90
166
|
return new LocalValue(NonPrimitiveType.REGULAR_EXPRESSION, value)
|
|
91
167
|
}
|
|
92
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Creates a new LocalValue object with the specified value.
|
|
171
|
+
* @param {Set} value - The value to be set.
|
|
172
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
173
|
+
*/
|
|
93
174
|
static createSetValue(value) {
|
|
94
175
|
return new LocalValue(NonPrimitiveType.SET, value)
|
|
95
176
|
}
|
|
96
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Creates a new LocalValue object with the given channel value
|
|
180
|
+
*
|
|
181
|
+
* @param {ChannelValue} value - The channel value.
|
|
182
|
+
* @returns {LocalValue} - The created LocalValue object.
|
|
183
|
+
*/
|
|
97
184
|
static createChannelValue(value) {
|
|
98
185
|
return new LocalValue(NonPrimitiveType.CHANNEL, value)
|
|
99
186
|
}
|
|
@@ -109,6 +196,11 @@ class LocalValue {
|
|
|
109
196
|
}
|
|
110
197
|
}
|
|
111
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Represents a remote value.
|
|
201
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
|
|
202
|
+
* @class
|
|
203
|
+
*/
|
|
112
204
|
class RemoteValue {
|
|
113
205
|
constructor(remoteValue) {
|
|
114
206
|
this.type = null
|
|
@@ -159,38 +251,72 @@ class RemoteValue {
|
|
|
159
251
|
}
|
|
160
252
|
}
|
|
161
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Represents a reference value in the protocol.
|
|
256
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteReference.
|
|
257
|
+
*/
|
|
162
258
|
class ReferenceValue {
|
|
259
|
+
#handle
|
|
260
|
+
#sharedId
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Constructs a new ReferenceValue object.
|
|
264
|
+
* @param {string} handle - The handle value.
|
|
265
|
+
* @param {string} sharedId - The shared ID value.
|
|
266
|
+
*/
|
|
163
267
|
constructor(handle, sharedId) {
|
|
164
268
|
if (handle === RemoteReferenceType.HANDLE) {
|
|
165
|
-
this
|
|
269
|
+
this.#handle = sharedId
|
|
270
|
+
} else if (handle === RemoteReferenceType.SHARED_ID) {
|
|
271
|
+
this.#sharedId = sharedId
|
|
166
272
|
} else {
|
|
167
|
-
this
|
|
168
|
-
this
|
|
273
|
+
this.#handle = handle
|
|
274
|
+
this.#sharedId = sharedId
|
|
169
275
|
}
|
|
170
276
|
}
|
|
171
277
|
|
|
172
278
|
asMap() {
|
|
173
279
|
const toReturn = {}
|
|
174
|
-
if (this
|
|
175
|
-
toReturn[RemoteReferenceType.HANDLE] = this
|
|
280
|
+
if (this.#handle != null) {
|
|
281
|
+
toReturn[RemoteReferenceType.HANDLE] = this.#handle
|
|
176
282
|
}
|
|
177
283
|
|
|
178
|
-
if (this
|
|
179
|
-
toReturn[RemoteReferenceType.SHARED_ID] = this
|
|
284
|
+
if (this.#sharedId != null) {
|
|
285
|
+
toReturn[RemoteReferenceType.SHARED_ID] = this.#sharedId
|
|
180
286
|
}
|
|
181
287
|
|
|
182
288
|
return toReturn
|
|
183
289
|
}
|
|
184
290
|
}
|
|
185
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Represents a regular expression value.
|
|
294
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-LocalValue.
|
|
295
|
+
*/
|
|
186
296
|
class RegExpValue {
|
|
297
|
+
/**
|
|
298
|
+
* Constructs a new RegExpValue object.
|
|
299
|
+
* @param {string} pattern - The pattern of the regular expression.
|
|
300
|
+
* @param {string|null} [flags=null] - The flags of the regular expression.
|
|
301
|
+
*/
|
|
187
302
|
constructor(pattern, flags = null) {
|
|
188
303
|
this.pattern = pattern
|
|
189
304
|
this.flags = flags
|
|
190
305
|
}
|
|
191
306
|
}
|
|
192
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Represents serialization options.
|
|
310
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-SerializationOptions.
|
|
311
|
+
*/
|
|
193
312
|
class SerializationOptions {
|
|
313
|
+
/**
|
|
314
|
+
* Constructs a new instance of SerializationOptions.
|
|
315
|
+
* @param {number} [maxDomDepth=0] - The maximum depth to serialize the DOM.
|
|
316
|
+
* @param {number|null} [maxObjectDepth=null] - The maximum depth to serialize objects.
|
|
317
|
+
* @param {'none'|'open'|'all'} [includeShadowTree='none'] - The inclusion level of the shadow tree.
|
|
318
|
+
* @throws {Error} If the `includeShadowTree` value is not one of 'none', 'open', or 'all'.
|
|
319
|
+
*/
|
|
194
320
|
constructor(maxDomDepth = 0, maxObjectDepth = null, includeShadowTree = 'none') {
|
|
195
321
|
this._maxDomDepth = maxDomDepth
|
|
196
322
|
this._maxObjectDepth = maxObjectDepth
|
|
@@ -202,6 +328,11 @@ class SerializationOptions {
|
|
|
202
328
|
}
|
|
203
329
|
}
|
|
204
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Represents a channel value.
|
|
333
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-ChannelValue.
|
|
334
|
+
* @class
|
|
335
|
+
*/
|
|
205
336
|
class ChannelValue {
|
|
206
337
|
constructor(channel, options = undefined, resultOwnership = undefined) {
|
|
207
338
|
this.channel = channel
|