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
@@ -17,66 +17,99 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Session = void 0;
20
+ require("./browser.js");
21
+ require("./browsing_context.js");
22
+ require("./common.js");
23
+ const record_js_1 = require("../serialization/record.js");
24
+ const enum_js_1 = require("../serialization/enum.js");
25
+ const union_js_1 = require("../serialization/union.js");
26
+ const domain_js_1 = require("../domain.js");
27
+ const SessionCapabilitiesRequest = (0, record_js_1.defineRecord)('session.CapabilitiesRequest', [{ "name": "alwaysMatch", "wire": "alwaysMatch", "required": false, "type": { "ref": "session.CapabilityRequest" } }, { "name": "firstMatch", "wire": "firstMatch", "required": false, "type": { "list": { "ref": "session.CapabilityRequest" } } }]);
28
+ const SessionCapabilityRequest = (0, record_js_1.defineRecord)('session.CapabilityRequest', [{ "name": "acceptInsecureCerts", "wire": "acceptInsecureCerts", "required": false, "type": { "primitive": "boolean" } }, { "name": "browserName", "wire": "browserName", "required": false, "type": { "primitive": "string" } }, { "name": "browserVersion", "wire": "browserVersion", "required": false, "type": { "primitive": "string" } }, { "name": "platformName", "wire": "platformName", "required": false, "type": { "primitive": "string" } }, { "name": "proxy", "wire": "proxy", "required": false, "type": { "ref": "session.ProxyConfiguration" } }, { "name": "unhandledPromptBehavior", "wire": "unhandledPromptBehavior", "required": false, "type": { "ref": "session.UserPromptHandler" } }], { "extensible": true });
29
+ const SessionProxyConfigurationUnion = (0, union_js_1.defineUnion)('session.ProxyConfiguration', { "by": "proxyType", "variants": [{ "value": "autodetect", "ref": "session.AutodetectProxyConfiguration" }, { "value": "direct", "ref": "session.DirectProxyConfiguration" }, { "value": "manual", "ref": "session.ManualProxyConfiguration" }, { "value": "pac", "ref": "session.PacProxyConfiguration" }, { "value": "system", "ref": "session.SystemProxyConfiguration" }] }, { "objectOnly": true });
30
+ const SessionAutodetectProxyConfiguration = (0, record_js_1.defineRecord)('session.AutodetectProxyConfiguration', [{ "name": "proxyType", "wire": "proxyType", "required": true, "type": { "const": "autodetect" } }], { "extensible": true });
31
+ const SessionDirectProxyConfiguration = (0, record_js_1.defineRecord)('session.DirectProxyConfiguration', [{ "name": "proxyType", "wire": "proxyType", "required": true, "type": { "const": "direct" } }], { "extensible": true });
32
+ const SessionManualProxyConfiguration = (0, record_js_1.defineRecord)('session.ManualProxyConfiguration', [{ "name": "proxyType", "wire": "proxyType", "required": true, "type": { "const": "manual" } }, { "name": "httpProxy", "wire": "httpProxy", "required": false, "type": { "primitive": "string" } }, { "name": "sslProxy", "wire": "sslProxy", "required": false, "type": { "primitive": "string" } }, { "name": "socksProxy", "wire": "socksProxy", "required": true, "type": { "primitive": "string" } }, { "name": "socksVersion", "wire": "socksVersion", "required": true, "type": { "primitive": "integer" } }, { "name": "noProxy", "wire": "noProxy", "required": false, "type": { "list": { "primitive": "string" } } }], { "extensible": true });
33
+ const SessionSocksProxyConfiguration = (0, record_js_1.defineRecord)('session.SocksProxyConfiguration', [{ "name": "socksProxy", "wire": "socksProxy", "required": true, "type": { "primitive": "string" } }, { "name": "socksVersion", "wire": "socksVersion", "required": true, "type": { "primitive": "integer" } }]);
34
+ const SessionPacProxyConfiguration = (0, record_js_1.defineRecord)('session.PacProxyConfiguration', [{ "name": "proxyType", "wire": "proxyType", "required": true, "type": { "const": "pac" } }, { "name": "proxyAutoconfigUrl", "wire": "proxyAutoconfigUrl", "required": true, "type": { "primitive": "string" } }], { "extensible": true });
35
+ const SessionSystemProxyConfiguration = (0, record_js_1.defineRecord)('session.SystemProxyConfiguration', [{ "name": "proxyType", "wire": "proxyType", "required": true, "type": { "const": "system" } }], { "extensible": true });
36
+ const SessionUserPromptHandler = (0, record_js_1.defineRecord)('session.UserPromptHandler', [{ "name": "alert", "wire": "alert", "required": false, "type": { "ref": "session.UserPromptHandlerType" } }, { "name": "beforeUnload", "wire": "beforeUnload", "required": false, "type": { "ref": "session.UserPromptHandlerType" } }, { "name": "confirm", "wire": "confirm", "required": false, "type": { "ref": "session.UserPromptHandlerType" } }, { "name": "default", "wire": "default", "required": false, "type": { "ref": "session.UserPromptHandlerType" } }, { "name": "file", "wire": "file", "required": false, "type": { "ref": "session.UserPromptHandlerType" } }, { "name": "prompt", "wire": "prompt", "required": false, "type": { "ref": "session.UserPromptHandlerType" } }]);
37
+ const SessionUserPromptHandlerTypeEnum = (0, enum_js_1.defineEnum)('session.UserPromptHandlerType', ["accept", "dismiss", "ignore"]);
38
+ (0, record_js_1.defineAlias)('session.Subscription', { "primitive": "string" });
39
+ const SessionSubscribeParameters = (0, record_js_1.defineRecord)('session.SubscribeParameters', [{ "name": "events", "wire": "events", "required": true, "type": { "list": { "primitive": "string" } } }, { "name": "contexts", "wire": "contexts", "required": false, "type": { "list": { "ref": "browsingContext.BrowsingContext" } } }, { "name": "userContexts", "wire": "userContexts", "required": false, "type": { "list": { "ref": "browser.UserContext" } } }]);
40
+ const SessionUnsubscribeByIdRequest = (0, record_js_1.defineRecord)('session.UnsubscribeByIDRequest', [{ "name": "subscriptions", "wire": "subscriptions", "required": true, "type": { "list": { "ref": "session.Subscription" } } }]);
41
+ const SessionUnsubscribeByAttributesRequest = (0, record_js_1.defineRecord)('session.UnsubscribeByAttributesRequest', [{ "name": "events", "wire": "events", "required": true, "type": { "list": { "primitive": "string" } } }]);
42
+ const SessionStatus = (0, record_js_1.defineRecord)('session.Status', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "session.status" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "EmptyParams" } }]);
43
+ const SessionStatusResult = (0, record_js_1.defineRecord)('session.StatusResult', [{ "name": "ready", "wire": "ready", "required": true, "type": { "primitive": "boolean" } }, { "name": "message", "wire": "message", "required": true, "type": { "primitive": "string" } }]);
44
+ const SessionNew = (0, record_js_1.defineRecord)('session.New', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "session.new" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "session.NewParameters" } }]);
45
+ const SessionNewParameters = (0, record_js_1.defineRecord)('session.NewParameters', [{ "name": "capabilities", "wire": "capabilities", "required": true, "type": { "ref": "session.CapabilitiesRequest" } }]);
46
+ const SessionNewResult = (0, record_js_1.defineRecord)('session.NewResult', [{ "name": "sessionId", "wire": "sessionId", "required": true, "type": { "primitive": "string" } }, { "name": "capabilities", "wire": "capabilities", "required": true, "type": { "ref": "session.NewResultCapabilities" } }]);
47
+ const SessionEnd = (0, record_js_1.defineRecord)('session.End', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "session.end" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "EmptyParams" } }]);
48
+ (0, record_js_1.defineAlias)('session.EndResult', { "ref": "EmptyResult" });
49
+ const SessionSubscribe = (0, record_js_1.defineRecord)('session.Subscribe', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "session.subscribe" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "session.SubscribeParameters" } }]);
50
+ const SessionSubscribeResult = (0, record_js_1.defineRecord)('session.SubscribeResult', [{ "name": "subscription", "wire": "subscription", "required": true, "type": { "ref": "session.Subscription" } }]);
51
+ const SessionUnsubscribe = (0, record_js_1.defineRecord)('session.Unsubscribe', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "session.unsubscribe" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "session.UnsubscribeParameters" } }]);
52
+ const SessionUnsubscribeParametersUnion = (0, union_js_1.defineUnion)('session.UnsubscribeParameters', { "ordered": [{ "ref": "session.UnsubscribeByAttributesRequest", "requires": ["events"] }, { "ref": "session.UnsubscribeByIDRequest", "requires": ["subscriptions"] }] }, { "objectOnly": true });
53
+ (0, record_js_1.defineAlias)('session.UnsubscribeResult', { "ref": "EmptyResult" });
54
+ const SessionNewResultCapabilities = (0, record_js_1.defineRecord)('session.NewResultCapabilities', [{ "name": "acceptInsecureCerts", "wire": "acceptInsecureCerts", "required": true, "type": { "primitive": "boolean" } }, { "name": "browserName", "wire": "browserName", "required": true, "type": { "primitive": "string" } }, { "name": "browserVersion", "wire": "browserVersion", "required": true, "type": { "primitive": "string" } }, { "name": "platformName", "wire": "platformName", "required": true, "type": { "primitive": "string" } }, { "name": "setWindowRect", "wire": "setWindowRect", "required": true, "type": { "primitive": "boolean" } }, { "name": "userAgent", "wire": "userAgent", "required": true, "type": { "primitive": "string" } }, { "name": "proxy", "wire": "proxy", "required": false, "type": { "ref": "session.ProxyConfiguration" } }, { "name": "unhandledPromptBehavior", "wire": "unhandledPromptBehavior", "required": false, "type": { "ref": "session.UserPromptHandler" } }, { "name": "webSocketUrl", "wire": "webSocketUrl", "required": false, "type": { "primitive": "string" } }], { "extensible": true });
20
55
  // --- Implementation ---
21
- class Session {
22
- constructor(bidi) {
23
- this.bidi = bidi;
24
- }
56
+ /**
57
+ * This is an unsupported API. No compatibility guarantees are provided.
58
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
59
+ * evolves, this API will change or be removed without prior notice.
60
+ */
61
+ class Session extends domain_js_1.Domain {
25
62
  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 Session(bidi);
63
+ return new Session(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
32
64
  }
65
+ /**
66
+ * @returns {Promise<void>}
67
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-end
68
+ */
33
69
  async end() {
34
- const response = await this.bidi.send({
35
- method: 'session.end',
36
- params: {},
37
- });
38
- if (response['type'] === 'error') {
39
- throw new Error(`${response['error']}: ${response['message']}`);
40
- }
70
+ await this.send('session.end', {});
41
71
  }
72
+ /**
73
+ * @param {SessionNewParameters} params
74
+ * @param {SessionCapabilitiesRequest} params.capabilities
75
+ * @returns {Promise<SessionNewResult>}
76
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-new
77
+ */
42
78
  async new(params) {
43
- const response = await this.bidi.send({
44
- method: 'session.new',
45
- params: params,
46
- });
47
- if (response['type'] === 'error') {
48
- throw new Error(`${response['error']}: ${response['message']}`);
49
- }
50
- return response.result;
79
+ const validatedParams = new SessionNewParameters(params);
80
+ const result = await this.send('session.new', validatedParams);
81
+ return SessionNewResult.fromWire(result);
51
82
  }
83
+ /**
84
+ * @returns {Promise<SessionStatusResult>}
85
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-status
86
+ */
52
87
  async status() {
53
- const response = await this.bidi.send({
54
- method: 'session.status',
55
- params: {},
56
- });
57
- if (response['type'] === 'error') {
58
- throw new Error(`${response['error']}: ${response['message']}`);
59
- }
60
- return response.result;
88
+ const result = await this.send('session.status', {});
89
+ return SessionStatusResult.fromWire(result);
61
90
  }
91
+ /**
92
+ * @param {SessionSubscribeParameters} params
93
+ * @param {Array<string>} params.events
94
+ * @param {Array<BrowsingContextBrowsingContext>} [params.contexts]
95
+ * @param {Array<BrowserUserContext>} [params.userContexts]
96
+ * @returns {Promise<SessionSubscribeResult>}
97
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-subscribe
98
+ */
62
99
  async subscribe(params) {
63
- const response = await this.bidi.send({
64
- method: 'session.subscribe',
65
- params: params,
66
- });
67
- if (response['type'] === 'error') {
68
- throw new Error(`${response['error']}: ${response['message']}`);
69
- }
70
- return response.result;
100
+ const validatedParams = new SessionSubscribeParameters(params);
101
+ const result = await this.send('session.subscribe', validatedParams);
102
+ return SessionSubscribeResult.fromWire(result);
71
103
  }
104
+ /**
105
+ * @param {SessionUnsubscribeParameters} params
106
+ * @returns {Promise<void>}
107
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-unsubscribe
108
+ */
72
109
  async unsubscribe(params) {
73
- const response = await this.bidi.send({
74
- method: 'session.unsubscribe',
75
- params: params,
76
- });
77
- if (response['type'] === 'error') {
78
- throw new Error(`${response['error']}: ${response['message']}`);
79
- }
110
+ const validatedParams = SessionUnsubscribeParametersUnion.build(params);
111
+ await this.send('session.unsubscribe', validatedParams);
80
112
  }
81
113
  }
82
114
  exports.Session = Session;
115
+ Session.UserPromptHandlerType = Object.freeze({ ACCEPT: "accept", DISMISS: "dismiss", IGNORE: "ignore" });
@@ -1,5 +1,5 @@
1
+ import { Domain, type EventDescriptor } from '../domain.js';
1
2
  export type SpeculationPreloadingStatus = "pending" | "ready" | "success" | "failure";
2
- export type SpeculationEvent = SpeculationPrefetchStatusUpdated;
3
3
  export interface SpeculationPrefetchStatusUpdated {
4
4
  method: "speculation.prefetchStatusUpdated";
5
5
  params: SpeculationPrefetchStatusUpdatedParameters;
@@ -9,9 +9,19 @@ export interface SpeculationPrefetchStatusUpdatedParameters {
9
9
  url: string;
10
10
  status: SpeculationPreloadingStatus;
11
11
  }
12
- export declare class Speculation {
13
- private readonly bidi;
14
- private constructor();
12
+ /**
13
+ * This is an unsupported API. No compatibility guarantees are provided.
14
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
15
+ * evolves, this API will change or be removed without prior notice.
16
+ */
17
+ export declare class Speculation extends Domain {
18
+ /** @see https://w3c.github.io/webdriver-bidi/#event-speculation-prefetchStatusUpdated */
19
+ static readonly PREFETCH_STATUS_UPDATED: EventDescriptor<SpeculationPrefetchStatusUpdatedParameters>;
20
+ static readonly PreloadingStatus: Readonly<{
21
+ readonly PENDING: "pending";
22
+ readonly READY: "ready";
23
+ readonly SUCCESS: "success";
24
+ readonly FAILURE: "failure";
25
+ }>;
15
26
  static create(driver: unknown): Promise<Speculation>;
16
- onPrefetchStatusUpdated(callback: (params: SpeculationPrefetchStatusUpdatedParameters) => void): Promise<void>;
17
27
  }
@@ -17,24 +17,28 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Speculation = void 0;
20
+ // DO NOT EDIT! This file is generated by javascript/selenium-webdriver/generate_bidi.mjs.
21
+ // Regenerate with: `bazel build //javascript/selenium-webdriver:create-bidi-src`
22
+ // Built from the WebDriver BiDi CDDL spec (v1.0).
23
+ // Source: https://github.com/w3c/webref/tree/main/ed/cddl
24
+ const record_js_1 = require("../serialization/record.js");
25
+ const enum_js_1 = require("../serialization/enum.js");
26
+ const domain_js_1 = require("../domain.js");
27
+ const SpeculationPreloadingStatusEnum = (0, enum_js_1.defineEnum)('speculation.PreloadingStatus', ["pending", "ready", "success", "failure"]);
28
+ const SpeculationPrefetchStatusUpdated = (0, record_js_1.defineRecord)('speculation.PrefetchStatusUpdated', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "speculation.prefetchStatusUpdated" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "speculation.PrefetchStatusUpdatedParameters" } }]);
29
+ const SpeculationPrefetchStatusUpdatedParameters = (0, record_js_1.defineRecord)('speculation.PrefetchStatusUpdatedParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "primitive": "string" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "status", "wire": "status", "required": true, "type": { "ref": "speculation.PreloadingStatus" } }]);
20
30
  // --- Implementation ---
21
- class Speculation {
22
- constructor(bidi) {
23
- this.bidi = bidi;
24
- }
31
+ /**
32
+ * This is an unsupported API. No compatibility guarantees are provided.
33
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
34
+ * evolves, this API will change or be removed without prior notice.
35
+ */
36
+ class Speculation extends domain_js_1.Domain {
25
37
  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 Speculation(bidi);
32
- }
33
- async onPrefetchStatusUpdated(callback) {
34
- await this.bidi.subscribe('speculation.prefetchStatusUpdated');
35
- this.bidi.on('speculation.prefetchStatusUpdated', (params) => {
36
- callback(params);
37
- });
38
+ return new Speculation(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
38
39
  }
39
40
  }
40
41
  exports.Speculation = Speculation;
42
+ /** @see https://w3c.github.io/webdriver-bidi/#event-speculation-prefetchStatusUpdated */
43
+ Speculation.PREFETCH_STATUS_UPDATED = (0, domain_js_1.event)('speculation.prefetchStatusUpdated', SpeculationPrefetchStatusUpdatedParameters);
44
+ Speculation.PreloadingStatus = Object.freeze({ PENDING: "pending", READY: "ready", SUCCESS: "success", FAILURE: "failure" });
@@ -1,17 +1,19 @@
1
1
  import type { BrowsingContextBrowsingContext } from './browsing_context.js';
2
- import type { Extensible, JsUint } from './common.js';
2
+ import './browsing_context.js';
3
+ import type { JsUint } from './common.js';
4
+ import './common.js';
3
5
  import type { NetworkBytesValue, NetworkCookie, NetworkSameSite } from './network.js';
4
- export type StorageCommand = StorageDeleteCookies | StorageGetCookies | StorageSetCookie;
5
- export type StorageResult = StorageDeleteCookiesResult | StorageGetCookiesResult | StorageSetCookieResult;
6
- export type StoragePartitionKey = Extensible & {
6
+ import './network.js';
7
+ import { Domain } from '../domain.js';
8
+ export interface StoragePartitionKey {
7
9
  userContext?: string;
8
10
  sourceOrigin?: string;
9
- };
11
+ }
10
12
  export interface StorageGetCookies {
11
13
  method: "storage.getCookies";
12
14
  params: StorageGetCookiesParameters;
13
15
  }
14
- export type StorageCookieFilter = Extensible & {
16
+ export interface StorageCookieFilter {
15
17
  name?: string;
16
18
  value?: NetworkBytesValue;
17
19
  domain?: string;
@@ -21,30 +23,30 @@ export type StorageCookieFilter = Extensible & {
21
23
  secure?: boolean;
22
24
  sameSite?: NetworkSameSite;
23
25
  expiry?: JsUint;
24
- };
26
+ }
25
27
  export interface StorageBrowsingContextPartitionDescriptor {
26
28
  type: "context";
27
29
  context: BrowsingContextBrowsingContext;
28
30
  }
29
- export type StorageStorageKeyPartitionDescriptor = Extensible & {
31
+ export interface StorageStorageKeyPartitionDescriptor {
30
32
  type: "storageKey";
31
33
  userContext?: string;
32
34
  sourceOrigin?: string;
33
- };
35
+ }
34
36
  export type StoragePartitionDescriptor = StorageBrowsingContextPartitionDescriptor | StorageStorageKeyPartitionDescriptor;
35
37
  export interface StorageGetCookiesParameters {
36
38
  filter?: StorageCookieFilter;
37
39
  partition?: StoragePartitionDescriptor;
38
40
  }
39
41
  export interface StorageGetCookiesResult {
40
- cookies: NetworkCookie[];
42
+ cookies: Array<NetworkCookie>;
41
43
  partitionKey: StoragePartitionKey;
42
44
  }
43
45
  export interface StorageSetCookie {
44
46
  method: "storage.setCookie";
45
47
  params: StorageSetCookieParameters;
46
48
  }
47
- export type StoragePartialCookie = Extensible & {
49
+ export interface StoragePartialCookie {
48
50
  name: string;
49
51
  value: NetworkBytesValue;
50
52
  domain: string;
@@ -53,7 +55,7 @@ export type StoragePartialCookie = Extensible & {
53
55
  secure?: boolean;
54
56
  sameSite?: NetworkSameSite;
55
57
  expiry?: JsUint;
56
- };
58
+ }
57
59
  export interface StorageSetCookieParameters {
58
60
  cookie: StoragePartialCookie;
59
61
  partition?: StoragePartitionDescriptor;
@@ -72,13 +74,35 @@ export interface StorageDeleteCookiesParameters {
72
74
  export interface StorageDeleteCookiesResult {
73
75
  partitionKey: StoragePartitionKey;
74
76
  }
75
- /** @deprecated Use {@link Storage.create} instead — will be removed in a future major version. */
76
- export declare function getStorageInstance(driver: unknown): Promise<Storage>;
77
- export declare class Storage {
78
- private readonly bidi;
79
- private constructor();
77
+ /**
78
+ * This is an unsupported API. No compatibility guarantees are provided.
79
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
80
+ * evolves, this API will change or be removed without prior notice.
81
+ */
82
+ export declare class Storage extends Domain {
80
83
  static create(driver: unknown): Promise<Storage>;
84
+ /**
85
+ * @param {StorageDeleteCookiesParameters} params
86
+ * @param {StorageCookieFilter} [params.filter]
87
+ * @param {StoragePartitionDescriptor} [params.partition]
88
+ * @returns {Promise<StorageDeleteCookiesResult>}
89
+ * @see https://w3c.github.io/webdriver-bidi/#command-storage-deleteCookies
90
+ */
81
91
  deleteCookies(params: StorageDeleteCookiesParameters): Promise<StorageDeleteCookiesResult>;
92
+ /**
93
+ * @param {StorageGetCookiesParameters} params
94
+ * @param {StorageCookieFilter} [params.filter]
95
+ * @param {StoragePartitionDescriptor} [params.partition]
96
+ * @returns {Promise<StorageGetCookiesResult>}
97
+ * @see https://w3c.github.io/webdriver-bidi/#command-storage-getCookies
98
+ */
82
99
  getCookies(params: StorageGetCookiesParameters): Promise<StorageGetCookiesResult>;
100
+ /**
101
+ * @param {StorageSetCookieParameters} params
102
+ * @param {StoragePartialCookie} params.cookie
103
+ * @param {StoragePartitionDescriptor} [params.partition]
104
+ * @returns {Promise<StorageSetCookieResult>}
105
+ * @see https://w3c.github.io/webdriver-bidi/#command-storage-setCookie
106
+ */
83
107
  setCookie(params: StorageSetCookieParameters): Promise<StorageSetCookieResult>;
84
108
  }
@@ -17,54 +17,72 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Storage = void 0;
20
- exports.getStorageInstance = getStorageInstance;
21
- // --- Additional Types ---
22
- /** @deprecated Use {@link Storage.create} instead — will be removed in a future major version. */
23
- async function getStorageInstance(driver) {
24
- return Storage.create(driver);
25
- }
20
+ require("./browsing_context.js");
21
+ require("./common.js");
22
+ require("./network.js");
23
+ const record_js_1 = require("../serialization/record.js");
24
+ const union_js_1 = require("../serialization/union.js");
25
+ const domain_js_1 = require("../domain.js");
26
+ const StoragePartitionKey = (0, record_js_1.defineRecord)('storage.PartitionKey', [{ "name": "userContext", "wire": "userContext", "required": false, "type": { "primitive": "string" } }, { "name": "sourceOrigin", "wire": "sourceOrigin", "required": false, "type": { "primitive": "string" } }], { "extensible": true });
27
+ const StorageGetCookies = (0, record_js_1.defineRecord)('storage.GetCookies', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "storage.getCookies" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "storage.GetCookiesParameters" } }]);
28
+ const StorageCookieFilter = (0, record_js_1.defineRecord)('storage.CookieFilter', [{ "name": "name", "wire": "name", "required": false, "type": { "primitive": "string" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "network.BytesValue" } }, { "name": "domain", "wire": "domain", "required": false, "type": { "primitive": "string" } }, { "name": "path", "wire": "path", "required": false, "type": { "primitive": "string" } }, { "name": "size", "wire": "size", "required": false, "type": { "ref": "js-uint" } }, { "name": "httpOnly", "wire": "httpOnly", "required": false, "type": { "primitive": "boolean" } }, { "name": "secure", "wire": "secure", "required": false, "type": { "primitive": "boolean" } }, { "name": "sameSite", "wire": "sameSite", "required": false, "type": { "ref": "network.SameSite" } }, { "name": "expiry", "wire": "expiry", "required": false, "type": { "ref": "js-uint" } }], { "extensible": true });
29
+ const StorageBrowsingContextPartitionDescriptor = (0, record_js_1.defineRecord)('storage.BrowsingContextPartitionDescriptor', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "context" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }]);
30
+ const StorageStorageKeyPartitionDescriptor = (0, record_js_1.defineRecord)('storage.StorageKeyPartitionDescriptor', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "storageKey" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "primitive": "string" } }, { "name": "sourceOrigin", "wire": "sourceOrigin", "required": false, "type": { "primitive": "string" } }], { "extensible": true });
31
+ const StoragePartitionDescriptorUnion = (0, union_js_1.defineUnion)('storage.PartitionDescriptor', { "by": "type", "variants": [{ "value": "context", "ref": "storage.BrowsingContextPartitionDescriptor" }, { "value": "storageKey", "ref": "storage.StorageKeyPartitionDescriptor" }] }, { "objectOnly": true });
32
+ const StorageGetCookiesParameters = (0, record_js_1.defineRecord)('storage.GetCookiesParameters', [{ "name": "filter", "wire": "filter", "required": false, "type": { "ref": "storage.CookieFilter" } }, { "name": "partition", "wire": "partition", "required": false, "type": { "ref": "storage.PartitionDescriptor" } }]);
33
+ const StorageGetCookiesResult = (0, record_js_1.defineRecord)('storage.GetCookiesResult', [{ "name": "cookies", "wire": "cookies", "required": true, "type": { "list": { "ref": "network.Cookie" } } }, { "name": "partitionKey", "wire": "partitionKey", "required": true, "type": { "ref": "storage.PartitionKey" } }]);
34
+ const StorageSetCookie = (0, record_js_1.defineRecord)('storage.SetCookie', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "storage.setCookie" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "storage.SetCookieParameters" } }]);
35
+ const StoragePartialCookie = (0, record_js_1.defineRecord)('storage.PartialCookie', [{ "name": "name", "wire": "name", "required": true, "type": { "primitive": "string" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "network.BytesValue" } }, { "name": "domain", "wire": "domain", "required": true, "type": { "primitive": "string" } }, { "name": "path", "wire": "path", "required": false, "type": { "primitive": "string" } }, { "name": "httpOnly", "wire": "httpOnly", "required": false, "type": { "primitive": "boolean" } }, { "name": "secure", "wire": "secure", "required": false, "type": { "primitive": "boolean" } }, { "name": "sameSite", "wire": "sameSite", "required": false, "type": { "ref": "network.SameSite" } }, { "name": "expiry", "wire": "expiry", "required": false, "type": { "ref": "js-uint" } }], { "extensible": true });
36
+ const StorageSetCookieParameters = (0, record_js_1.defineRecord)('storage.SetCookieParameters', [{ "name": "cookie", "wire": "cookie", "required": true, "type": { "ref": "storage.PartialCookie" } }, { "name": "partition", "wire": "partition", "required": false, "type": { "ref": "storage.PartitionDescriptor" } }]);
37
+ const StorageSetCookieResult = (0, record_js_1.defineRecord)('storage.SetCookieResult', [{ "name": "partitionKey", "wire": "partitionKey", "required": true, "type": { "ref": "storage.PartitionKey" } }]);
38
+ const StorageDeleteCookies = (0, record_js_1.defineRecord)('storage.DeleteCookies', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "storage.deleteCookies" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "storage.DeleteCookiesParameters" } }]);
39
+ const StorageDeleteCookiesParameters = (0, record_js_1.defineRecord)('storage.DeleteCookiesParameters', [{ "name": "filter", "wire": "filter", "required": false, "type": { "ref": "storage.CookieFilter" } }, { "name": "partition", "wire": "partition", "required": false, "type": { "ref": "storage.PartitionDescriptor" } }]);
40
+ const StorageDeleteCookiesResult = (0, record_js_1.defineRecord)('storage.DeleteCookiesResult', [{ "name": "partitionKey", "wire": "partitionKey", "required": true, "type": { "ref": "storage.PartitionKey" } }]);
26
41
  // --- Implementation ---
27
- class Storage {
28
- constructor(bidi) {
29
- this.bidi = bidi;
30
- }
42
+ /**
43
+ * This is an unsupported API. No compatibility guarantees are provided.
44
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
45
+ * evolves, this API will change or be removed without prior notice.
46
+ */
47
+ class Storage extends domain_js_1.Domain {
31
48
  static async create(driver) {
32
- const caps = await driver.getCapabilities();
33
- if (!caps.get('webSocketUrl')) {
34
- throw new Error('WebDriver instance must support BiDi protocol');
35
- }
36
- const bidi = await driver.getBidi();
37
- return new Storage(bidi);
49
+ return new Storage(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
38
50
  }
51
+ /**
52
+ * @param {StorageDeleteCookiesParameters} params
53
+ * @param {StorageCookieFilter} [params.filter]
54
+ * @param {StoragePartitionDescriptor} [params.partition]
55
+ * @returns {Promise<StorageDeleteCookiesResult>}
56
+ * @see https://w3c.github.io/webdriver-bidi/#command-storage-deleteCookies
57
+ */
39
58
  async deleteCookies(params) {
40
- const response = await this.bidi.send({
41
- method: 'storage.deleteCookies',
42
- params: params,
43
- });
44
- if (response['type'] === 'error') {
45
- throw new Error(`${response['error']}: ${response['message']}`);
46
- }
47
- return response.result;
59
+ const validatedParams = new StorageDeleteCookiesParameters(params);
60
+ const result = await this.send('storage.deleteCookies', validatedParams);
61
+ return StorageDeleteCookiesResult.fromWire(result);
48
62
  }
63
+ /**
64
+ * @param {StorageGetCookiesParameters} params
65
+ * @param {StorageCookieFilter} [params.filter]
66
+ * @param {StoragePartitionDescriptor} [params.partition]
67
+ * @returns {Promise<StorageGetCookiesResult>}
68
+ * @see https://w3c.github.io/webdriver-bidi/#command-storage-getCookies
69
+ */
49
70
  async getCookies(params) {
50
- const response = await this.bidi.send({
51
- method: 'storage.getCookies',
52
- params: params,
53
- });
54
- if (response['type'] === 'error') {
55
- throw new Error(`${response['error']}: ${response['message']}`);
56
- }
57
- return response.result;
71
+ const validatedParams = new StorageGetCookiesParameters(params);
72
+ const result = await this.send('storage.getCookies', validatedParams);
73
+ return StorageGetCookiesResult.fromWire(result);
58
74
  }
75
+ /**
76
+ * @param {StorageSetCookieParameters} params
77
+ * @param {StoragePartialCookie} params.cookie
78
+ * @param {StoragePartitionDescriptor} [params.partition]
79
+ * @returns {Promise<StorageSetCookieResult>}
80
+ * @see https://w3c.github.io/webdriver-bidi/#command-storage-setCookie
81
+ */
59
82
  async setCookie(params) {
60
- const response = await this.bidi.send({
61
- method: 'storage.setCookie',
62
- params: params,
63
- });
64
- if (response['type'] === 'error') {
65
- throw new Error(`${response['error']}: ${response['message']}`);
66
- }
67
- return response.result;
83
+ const validatedParams = new StorageSetCookieParameters(params);
84
+ const result = await this.send('storage.setCookie', validatedParams);
85
+ return StorageSetCookieResult.fromWire(result);
68
86
  }
69
87
  }
70
88
  exports.Storage = Storage;
@@ -1,15 +1,11 @@
1
- export type UserAgentClientHintsCommand = UserAgentClientHintsSetClientHintsOverrideCommand;
1
+ import { Domain } from '../domain.js';
2
2
  export interface UserAgentClientHintsSetClientHintsOverrideCommand {
3
3
  method: "userAgentClientHints.setClientHintsOverride";
4
- params: {
5
- clientHints: UserAgentClientHintsClientHintsMetadata | null;
6
- contexts?: string[];
7
- userContexts?: string[];
8
- };
4
+ params: UserAgentClientHintsSetClientHintsOverrideCommandParams;
9
5
  }
10
6
  export interface UserAgentClientHintsClientHintsMetadata {
11
- brands?: UserAgentClientHintsBrandVersion[];
12
- fullVersionList?: UserAgentClientHintsBrandVersion[];
7
+ brands?: Array<UserAgentClientHintsBrandVersion>;
8
+ fullVersionList?: Array<UserAgentClientHintsBrandVersion>;
13
9
  platform?: string;
14
10
  platformVersion?: string;
15
11
  architecture?: string;
@@ -17,7 +13,7 @@ export interface UserAgentClientHintsClientHintsMetadata {
17
13
  mobile?: boolean;
18
14
  bitness?: string;
19
15
  wow64?: boolean;
20
- formFactors?: string[];
16
+ formFactors?: Array<string>;
21
17
  }
22
18
  export interface UserAgentClientHintsBrandVersion {
23
19
  brand: string;
@@ -25,9 +21,25 @@ export interface UserAgentClientHintsBrandVersion {
25
21
  }
26
22
  export interface UserAgentClientHintsSetClientHintsOverrideResult {
27
23
  }
28
- export declare class UserAgentClientHints {
29
- private readonly bidi;
30
- private constructor();
24
+ export interface UserAgentClientHintsSetClientHintsOverrideCommandParams {
25
+ clientHints: UserAgentClientHintsClientHintsMetadata | null;
26
+ contexts?: Array<string>;
27
+ userContexts?: Array<string>;
28
+ }
29
+ /**
30
+ * This is an unsupported API. No compatibility guarantees are provided.
31
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
32
+ * evolves, this API will change or be removed without prior notice.
33
+ */
34
+ export declare class UserAgentClientHints extends Domain {
31
35
  static create(driver: unknown): Promise<UserAgentClientHints>;
32
- setClientHintsOverride(): Promise<void>;
36
+ /**
37
+ * @param {UserAgentClientHintsSetClientHintsOverrideCommandParams} params
38
+ * @param {UserAgentClientHintsClientHintsMetadata | null} params.clientHints
39
+ * @param {Array<string>} [params.contexts]
40
+ * @param {Array<string>} [params.userContexts]
41
+ * @returns {Promise<void>}
42
+ * @see https://w3c.github.io/webdriver-bidi/#command-userAgentClientHints-setClientHintsOverride
43
+ */
44
+ setClientHintsOverride(params: UserAgentClientHintsSetClientHintsOverrideCommandParams): Promise<void>;
33
45
  }
@@ -17,27 +17,38 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.UserAgentClientHints = void 0;
20
+ // DO NOT EDIT! This file is generated by javascript/selenium-webdriver/generate_bidi.mjs.
21
+ // Regenerate with: `bazel build //javascript/selenium-webdriver:create-bidi-src`
22
+ // Built from the WebDriver BiDi CDDL spec (v1.0).
23
+ // Source: https://github.com/w3c/webref/tree/main/ed/cddl
24
+ const record_js_1 = require("../serialization/record.js");
25
+ const domain_js_1 = require("../domain.js");
26
+ const UserAgentClientHintsSetClientHintsOverrideCommand = (0, record_js_1.defineRecord)('userAgentClientHints.SetClientHintsOverrideCommand', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "userAgentClientHints.setClientHintsOverride" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "userAgentClientHints.SetClientHintsOverrideCommandParams" } }]);
27
+ const UserAgentClientHintsClientHintsMetadata = (0, record_js_1.defineRecord)('userAgentClientHints.ClientHintsMetadata', [{ "name": "brands", "wire": "brands", "required": false, "type": { "list": { "ref": "userAgentClientHints.BrandVersion" } } }, { "name": "fullVersionList", "wire": "fullVersionList", "required": false, "type": { "list": { "ref": "userAgentClientHints.BrandVersion" } } }, { "name": "platform", "wire": "platform", "required": false, "type": { "primitive": "string" } }, { "name": "platformVersion", "wire": "platformVersion", "required": false, "type": { "primitive": "string" } }, { "name": "architecture", "wire": "architecture", "required": false, "type": { "primitive": "string" } }, { "name": "model", "wire": "model", "required": false, "type": { "primitive": "string" } }, { "name": "mobile", "wire": "mobile", "required": false, "type": { "primitive": "boolean" } }, { "name": "bitness", "wire": "bitness", "required": false, "type": { "primitive": "string" } }, { "name": "wow64", "wire": "wow64", "required": false, "type": { "primitive": "boolean" } }, { "name": "formFactors", "wire": "formFactors", "required": false, "type": { "list": { "primitive": "string" } } }]);
28
+ const UserAgentClientHintsBrandVersion = (0, record_js_1.defineRecord)('userAgentClientHints.BrandVersion', [{ "name": "brand", "wire": "brand", "required": true, "type": { "primitive": "string" } }, { "name": "version", "wire": "version", "required": true, "type": { "primitive": "string" } }]);
29
+ const UserAgentClientHintsSetClientHintsOverrideResult = (0, record_js_1.defineRecord)('userAgentClientHints.SetClientHintsOverrideResult', []);
30
+ const UserAgentClientHintsSetClientHintsOverrideCommandParams = (0, record_js_1.defineRecord)('userAgentClientHints.SetClientHintsOverrideCommandParams', [{ "name": "clientHints", "wire": "clientHints", "required": true, "type": { "ref": "userAgentClientHints.ClientHintsMetadata", "nullable": true } }, { "name": "contexts", "wire": "contexts", "required": false, "type": { "list": { "primitive": "string" } } }, { "name": "userContexts", "wire": "userContexts", "required": false, "type": { "list": { "primitive": "string" } } }]);
20
31
  // --- Implementation ---
21
- class UserAgentClientHints {
22
- constructor(bidi) {
23
- this.bidi = bidi;
24
- }
32
+ /**
33
+ * This is an unsupported API. No compatibility guarantees are provided.
34
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
35
+ * evolves, this API will change or be removed without prior notice.
36
+ */
37
+ class UserAgentClientHints extends domain_js_1.Domain {
25
38
  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 UserAgentClientHints(bidi);
39
+ return new UserAgentClientHints(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
32
40
  }
33
- async setClientHintsOverride() {
34
- const response = await this.bidi.send({
35
- method: 'userAgentClientHints.setClientHintsOverride',
36
- params: {},
37
- });
38
- if (response['type'] === 'error') {
39
- throw new Error(`${response['error']}: ${response['message']}`);
40
- }
41
+ /**
42
+ * @param {UserAgentClientHintsSetClientHintsOverrideCommandParams} params
43
+ * @param {UserAgentClientHintsClientHintsMetadata | null} params.clientHints
44
+ * @param {Array<string>} [params.contexts]
45
+ * @param {Array<string>} [params.userContexts]
46
+ * @returns {Promise<void>}
47
+ * @see https://w3c.github.io/webdriver-bidi/#command-userAgentClientHints-setClientHintsOverride
48
+ */
49
+ async setClientHintsOverride(params) {
50
+ const validatedParams = new UserAgentClientHintsSetClientHintsOverrideCommandParams(params);
51
+ await this.send('userAgentClientHints.setClientHintsOverride', validatedParams);
41
52
  }
42
53
  }
43
54
  exports.UserAgentClientHints = UserAgentClientHints;