selenium-webdriver 4.48.0 → 4.50.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.
Files changed (52) hide show
  1. package/CHANGES.md +26 -0
  2. package/bidi/generated/bluetooth.d.ts +199 -37
  3. package/bidi/generated/bluetooth.js +212 -106
  4. package/bidi/generated/browser.d.ts +81 -28
  5. package/bidi/generated/browser.js +97 -69
  6. package/bidi/generated/browsing_context.d.ts +274 -87
  7. package/bidi/generated/browsing_context.js +328 -241
  8. package/bidi/generated/common.d.ts +105 -21
  9. package/bidi/generated/common.js +64 -15
  10. package/bidi/generated/digital_credentials.d.ts +41 -0
  11. package/bidi/generated/digital_credentials.js +54 -0
  12. package/bidi/generated/emulation.d.ts +354 -58
  13. package/bidi/generated/emulation.js +262 -101
  14. package/bidi/generated/input.d.ts +63 -35
  15. package/bidi/generated/input.js +77 -51
  16. package/bidi/generated/log.d.ts +39 -18
  17. package/bidi/generated/log.js +23 -43
  18. package/bidi/generated/network.d.ts +248 -76
  19. package/bidi/generated/network.js +247 -181
  20. package/bidi/generated/permissions.d.ts +22 -4
  21. package/bidi/generated/permissions.js +31 -17
  22. package/bidi/generated/script.d.ts +166 -70
  23. package/bidi/generated/script.js +203 -116
  24. package/bidi/generated/session.d.ts +76 -36
  25. package/bidi/generated/session.js +81 -48
  26. package/bidi/generated/speculation.d.ts +15 -5
  27. package/bidi/generated/speculation.js +20 -16
  28. package/bidi/generated/storage.d.ts +41 -17
  29. package/bidi/generated/storage.js +58 -40
  30. package/bidi/generated/user_agent_client_hints.d.ts +25 -13
  31. package/bidi/generated/user_agent_client_hints.js +29 -18
  32. package/bidi/generated/webextension.d.ts +24 -10
  33. package/bidi/generated/webextension.js +39 -25
  34. package/bidi/serialization/enum.js +6 -3
  35. package/bidi/serialization/record.js +34 -29
  36. package/bin/linux-arm64/selenium-manager +0 -0
  37. package/bin/{linux → linux-x86_64}/selenium-manager +0 -0
  38. package/bin/macos/selenium-manager +0 -0
  39. package/bin/selenium-manager-THIRD-PARTY-NOTICES.txt +327 -51
  40. package/bin/selenium-manager.cdx.json +491 -491
  41. package/bin/windows/selenium-manager.exe +0 -0
  42. package/chromium.js +1 -1
  43. package/common/seleniumManager.js +2 -2
  44. package/eslint.config.js +2 -1
  45. package/example/chrome_mobile_emulation.js +1 -1
  46. package/firefox.js +7 -104
  47. package/index.js +8 -0
  48. package/lib/atoms/find-elements.js +14 -2
  49. package/package.json +10 -10
  50. package/remote/index.js +12 -3
  51. package/remote/util.js +5 -5
  52. package/testing/index.js +84 -1
@@ -1,11 +1,14 @@
1
- import type { EmptyResult, Extensible } from './common.js';
2
- export type WebExtensionCommand = WebExtensionInstall | WebExtensionUninstall;
3
- export type WebExtensionResult = WebExtensionInstallResult | WebExtensionUninstallResult;
1
+ import type { EmptyResult } from './common.js';
2
+ import './common.js';
3
+ import { Domain } from '../domain.js';
4
4
  export type WebExtensionExtension = string;
5
5
  export interface WebExtensionInstall {
6
6
  method: "webExtension.install";
7
7
  params: WebExtensionInstallParameters;
8
8
  }
9
+ export interface WebExtensionInstallParameters {
10
+ extensionData: WebExtensionExtensionData;
11
+ }
9
12
  export type WebExtensionExtensionData = WebExtensionExtensionArchivePath | WebExtensionExtensionBase64Encoded | WebExtensionExtensionPath;
10
13
  export interface WebExtensionExtensionPath {
11
14
  type: "path";
@@ -30,14 +33,25 @@ export interface WebExtensionUninstallParameters {
30
33
  extension: WebExtensionExtension;
31
34
  }
32
35
  export type WebExtensionUninstallResult = EmptyResult;
33
- export type WebExtensionInstallParameters = WebExtensionInstallParametersExtension & {
34
- extensionData: WebExtensionExtensionData;
35
- };
36
- export type WebExtensionInstallParametersExtension = Extensible;
37
- export declare class WebExtension {
38
- private readonly bidi;
39
- private constructor();
36
+ /**
37
+ * This is an unsupported API. No compatibility guarantees are provided.
38
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
39
+ * evolves, this API will change or be removed without prior notice.
40
+ */
41
+ export declare class WebExtension extends Domain {
40
42
  static create(driver: unknown): Promise<WebExtension>;
43
+ /**
44
+ * @param {WebExtensionInstallParameters} params
45
+ * @param {WebExtensionExtensionData} params.extensionData
46
+ * @returns {Promise<WebExtensionInstallResult>}
47
+ * @see https://w3c.github.io/webdriver-bidi/#command-webExtension-install
48
+ */
41
49
  install(params: WebExtensionInstallParameters): Promise<WebExtensionInstallResult>;
50
+ /**
51
+ * @param {WebExtensionUninstallParameters} params
52
+ * @param {WebExtensionExtension} params.extension
53
+ * @returns {Promise<void>}
54
+ * @see https://w3c.github.io/webdriver-bidi/#command-webExtension-uninstall
55
+ */
42
56
  uninstall(params: WebExtensionUninstallParameters): Promise<void>;
43
57
  }
@@ -17,37 +17,51 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.WebExtension = void 0;
20
+ require("./common.js");
21
+ const record_js_1 = require("../serialization/record.js");
22
+ const union_js_1 = require("../serialization/union.js");
23
+ const domain_js_1 = require("../domain.js");
24
+ (0, record_js_1.defineAlias)('webExtension.Extension', { "primitive": "string" });
25
+ const WebExtensionInstall = (0, record_js_1.defineRecord)('webExtension.Install', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "webExtension.install" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "webExtension.InstallParameters" } }]);
26
+ const WebExtensionInstallParameters = (0, record_js_1.defineRecord)('webExtension.InstallParameters', [{ "name": "extensionData", "wire": "extensionData", "required": true, "type": { "ref": "webExtension.ExtensionData" } }]);
27
+ const WebExtensionExtensionDataUnion = (0, union_js_1.defineUnion)('webExtension.ExtensionData', { "by": "type", "variants": [{ "value": "archivePath", "ref": "webExtension.ExtensionArchivePath" }, { "value": "base64", "ref": "webExtension.ExtensionBase64Encoded" }, { "value": "path", "ref": "webExtension.ExtensionPath" }] }, { "objectOnly": true });
28
+ const WebExtensionExtensionPath = (0, record_js_1.defineRecord)('webExtension.ExtensionPath', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "path" } }, { "name": "path", "wire": "path", "required": true, "type": { "primitive": "string" } }]);
29
+ const WebExtensionExtensionArchivePath = (0, record_js_1.defineRecord)('webExtension.ExtensionArchivePath', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "archivePath" } }, { "name": "path", "wire": "path", "required": true, "type": { "primitive": "string" } }]);
30
+ const WebExtensionExtensionBase64Encoded = (0, record_js_1.defineRecord)('webExtension.ExtensionBase64Encoded', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "base64" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
31
+ const WebExtensionInstallResult = (0, record_js_1.defineRecord)('webExtension.InstallResult', [{ "name": "extension", "wire": "extension", "required": true, "type": { "ref": "webExtension.Extension" } }]);
32
+ const WebExtensionUninstall = (0, record_js_1.defineRecord)('webExtension.Uninstall', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "webExtension.uninstall" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "webExtension.UninstallParameters" } }]);
33
+ const WebExtensionUninstallParameters = (0, record_js_1.defineRecord)('webExtension.UninstallParameters', [{ "name": "extension", "wire": "extension", "required": true, "type": { "ref": "webExtension.Extension" } }]);
34
+ (0, record_js_1.defineAlias)('webExtension.UninstallResult', { "ref": "EmptyResult" });
20
35
  // --- Implementation ---
21
- class WebExtension {
22
- constructor(bidi) {
23
- this.bidi = bidi;
24
- }
36
+ /**
37
+ * This is an unsupported API. No compatibility guarantees are provided.
38
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
39
+ * evolves, this API will change or be removed without prior notice.
40
+ */
41
+ class WebExtension extends domain_js_1.Domain {
25
42
  static async create(driver) {
26
- const caps = await driver.getCapabilities();
27
- if (!caps.get('webSocketUrl')) {
28
- throw new Error('WebDriver instance must support BiDi protocol');
29
- }
30
- const bidi = await driver.getBidi();
31
- return new WebExtension(bidi);
43
+ return new WebExtension(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
32
44
  }
45
+ /**
46
+ * @param {WebExtensionInstallParameters} params
47
+ * @param {WebExtensionExtensionData} params.extensionData
48
+ * @returns {Promise<WebExtensionInstallResult>}
49
+ * @see https://w3c.github.io/webdriver-bidi/#command-webExtension-install
50
+ */
33
51
  async install(params) {
34
- const response = await this.bidi.send({
35
- method: 'webExtension.install',
36
- params: params,
37
- });
38
- if (response['type'] === 'error') {
39
- throw new Error(`${response['error']}: ${response['message']}`);
40
- }
41
- return response.result;
52
+ const validatedParams = new WebExtensionInstallParameters(params);
53
+ const result = await this.send('webExtension.install', validatedParams);
54
+ return WebExtensionInstallResult.fromWire(result);
42
55
  }
56
+ /**
57
+ * @param {WebExtensionUninstallParameters} params
58
+ * @param {WebExtensionExtension} params.extension
59
+ * @returns {Promise<void>}
60
+ * @see https://w3c.github.io/webdriver-bidi/#command-webExtension-uninstall
61
+ */
43
62
  async uninstall(params) {
44
- const response = await this.bidi.send({
45
- method: 'webExtension.uninstall',
46
- params: params,
47
- });
48
- if (response['type'] === 'error') {
49
- throw new Error(`${response['error']}: ${response['message']}`);
50
- }
63
+ const validatedParams = new WebExtensionUninstallParameters(params);
64
+ await this.send('webExtension.uninstall', validatedParams);
51
65
  }
52
66
  }
53
67
  exports.WebExtension = WebExtension;
@@ -18,10 +18,13 @@
18
18
  const { register } = require('./registry')
19
19
 
20
20
  /**
21
- * Registers a schema `enum` — a closed set of string values a field may hold.
21
+ * Registers a schema `enum` — a closed set of string, number, or boolean values a
22
+ * field may hold (e.g. emulation.MediaFeaturesGrid, CSS's `grid` media feature, is
23
+ * spec'd as the integer 0 or 1, not a string; the schema projector's literalPrimitive()
24
+ * recognizes a boolean-literal choice the same way).
22
25
  * @param {string} name Schema type name, e.g. 'network.InterceptPhase'.
23
- * @param {string[]} values The enum's valid values.
24
- * @returns {{kind: 'enum', values: string[], includes: function(unknown): boolean}}
26
+ * @param {Array<string|number|boolean>} values The enum's valid values.
27
+ * @returns {{kind: 'enum', values: Array<string|number|boolean>, includes: function(unknown): boolean}}
25
28
  * The registered entry, used by validateValue() to check a ref'd value's
26
29
  * membership; also returned so a generator can build a discoverable constant from it.
27
30
  */
@@ -20,14 +20,14 @@ const { register, resolve } = require('./registry')
20
20
  class ValidationError extends Error {}
21
21
 
22
22
  // Validates a *present* value against a resolved type node, and returns the value to
23
- // assign for it — usually the same value, but for a nested ref-to-record/union parsed
24
- // inbound (fromWire()/build() results, not the raw wire object) and for list/map/inline
25
- // record values (a fresh, deeply-frozen copy, so validity can't be corrupted after the
26
- // fact by mutating an array or object a caller still holds a reference to).
27
- // Outbound nested refs deliberately keep the caller's own value instead of the
28
- // newly-constructed instance — the nested `new referenced.RecordClass(value)` /
29
- // `referenced.build(value)` call below exists only to validate, matching the
30
- // constructor's existing outbound behavior of trusting the caller's own object shape.
23
+ // assign for it — usually the same value, but for a nested ref-to-record/union (the
24
+ // freshly constructed/parsed instance — fromWire()/build() inbound, `new RecordClass(value)`/
25
+ // build() outbound, not the caller's raw value) and for list/map/inline record values (a
26
+ // fresh, deeply-frozen copy, so validity can't be corrupted after the fact by mutating an
27
+ // array or object a caller still holds a reference to). Outbound needs the constructed
28
+ // instance, symmetric with inbound, so a typed parent's toJSON() cascades into a nested
29
+ // record's own toJSON() — converting *its* fields to their declared wire names too, not
30
+ // just the parent's own fields — when the whole instance is serialized for the wire.
31
31
  // `direction` only affects how a nested ref-to-record/union is itself validated/parsed.
32
32
  function validateValue(typeNode, value, path, direction) {
33
33
  if (value === null) {
@@ -125,23 +125,24 @@ function validateValue(typeNode, value, path, direction) {
125
125
  throw new ValidationError(`${path}: expected an object, got ${typeof value}`)
126
126
  }
127
127
  // Recurse through the same-direction path so a nested field gets the same
128
- // tolerance (inbound) or strictness (outbound) as its parent. Inbound returns
129
- // the parsed instance itself, so a typed parent record ends up with a typed
130
- // nested value instead of the raw wire object; outbound only validates this
131
- // way (the caller's own value is what gets kept, see the note above).
128
+ // tolerance (inbound) or strictness (outbound) as its parent, and — both
129
+ // directions alike — ends up holding the typed instance, not the raw value:
130
+ // inbound so a typed parent record has a typed nested value instead of the
131
+ // raw wire object; outbound so the parent's own toJSON() cascades into this
132
+ // nested instance's toJSON() too, converting its fields to their wire names.
132
133
  if (direction === 'inbound') {
133
134
  return referenced.RecordClass.fromWire(value)
134
135
  }
135
- new referenced.RecordClass(value)
136
- return value
136
+ return new referenced.RecordClass(value)
137
137
  }
138
138
 
139
139
  if (referenced.kind === 'union') {
140
+ // build()/fromWire() already return the resolved variant's own instance —
141
+ // same reasoning as the record branch above applies to it symmetrically.
140
142
  if (direction === 'inbound') {
141
143
  return referenced.fromWire(value)
142
144
  }
143
- referenced.build(value)
144
- return value
145
+ return referenced.build(value)
145
146
  }
146
147
 
147
148
  if (referenced.kind === 'alias') {
@@ -220,33 +221,37 @@ function defineRecord(name, fields, options = {}) {
220
221
 
221
222
  class Record {
222
223
  // Outbound: strict. Any value that doesn't match its declared shape is an error here.
224
+ // Reads `data` by JS-facing field name (field.name), not the wire key (field.wire) —
225
+ // a caller builds params using the same property names the generated TS interface
226
+ // declares (e.g. `prefersColorScheme`), never the raw spec key (`prefers-color-scheme`);
227
+ // toJSON() below is what maps back to field.wire for the actual wire send.
223
228
  constructor(data) {
224
229
  if (typeof data !== 'object' || data === null || Array.isArray(data)) {
225
230
  throw new ValidationError(`${name}: expected an object`)
226
231
  }
227
232
 
228
233
  for (const field of fields) {
229
- if (!Object.hasOwn(data, field.wire)) {
234
+ if (!Object.hasOwn(data, field.name)) {
230
235
  if (field.required) {
231
- throw new ValidationError(`${name}.${field.wire}: required field is missing`)
236
+ throw new ValidationError(`${name}.${field.name}: required field is missing`)
232
237
  }
233
238
  continue
234
239
  }
235
- const value = data[field.wire]
236
- this[field.name] = validateValue(field.type, value, `${name}.${field.wire}`, 'outbound')
240
+ const value = data[field.name]
241
+ this[field.name] = validateValue(field.type, value, `${name}.${field.name}`, 'outbound')
237
242
  }
238
243
 
239
- for (const wireKey of Object.keys(data)) {
240
- if (byWire.has(wireKey)) continue
244
+ for (const key of Object.keys(data)) {
245
+ if (byName.has(key)) continue
241
246
  if (!extensible) {
242
- throw new ValidationError(`${name}: unknown property "${wireKey}"`)
247
+ throw new ValidationError(`${name}: unknown property "${key}"`)
243
248
  }
244
- // Object.defineProperty, not `this[wireKey] = ...`: wireKey is caller-supplied
245
- // and a literal "__proto__" key assigned via bracket notation hijacks this
246
- // instance's actual prototype instead of becoming a field (CWE-1321).
247
- // defineProperty always creates a genuine own data property, regardless of name.
248
- Object.defineProperty(this, wireKey, {
249
- value: data[wireKey], // vendor extras reach the wire on an extensible type
249
+ // Object.defineProperty, not `this[key] = ...`: key is caller-supplied and a
250
+ // literal "__proto__" key assigned via bracket notation hijacks this instance's
251
+ // actual prototype instead of becoming a field (CWE-1321). defineProperty always
252
+ // creates a genuine own data property, regardless of name.
253
+ Object.defineProperty(this, key, {
254
+ value: data[key], // vendor extras have no separate wire name — this key is both
250
255
  enumerable: true,
251
256
  writable: true,
252
257
  configurable: true,
Binary file
Binary file