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,264 +17,351 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.BrowsingContext = void 0;
20
- exports.getBrowsingContextInstance = getBrowsingContextInstance;
21
- // --- Additional Types ---
22
- /** @deprecated Use {@link BrowsingContext.create} instead — will be removed in a future major version. */
23
- async function getBrowsingContextInstance(driver) {
24
- return BrowsingContext.create(driver);
25
- }
20
+ require("./browser.js");
21
+ require("./common.js");
22
+ require("./script.js");
23
+ require("./session.js");
24
+ const record_js_1 = require("../serialization/record.js");
25
+ const enum_js_1 = require("../serialization/enum.js");
26
+ const union_js_1 = require("../serialization/union.js");
27
+ const domain_js_1 = require("../domain.js");
28
+ (0, record_js_1.defineAlias)('browsingContext.BrowsingContext', { "primitive": "string" });
29
+ (0, record_js_1.defineAlias)('browsingContext.InfoList', { "list": { "ref": "browsingContext.Info" } });
30
+ const BrowsingContextBaseInfo = (0, record_js_1.defineRecord)('browsingContext.BaseInfo', [{ "name": "children", "wire": "children", "required": true, "type": { "ref": "browsingContext.InfoList", "nullable": true } }, { "name": "clientWindow", "wire": "clientWindow", "required": true, "type": { "ref": "browser.ClientWindow" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "originalOpener", "wire": "originalOpener", "required": true, "type": { "ref": "browsingContext.BrowsingContext", "nullable": true } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": true, "type": { "ref": "browser.UserContext" } }, { "name": "parent", "wire": "parent", "required": false, "type": { "ref": "browsingContext.BrowsingContext", "nullable": true } }]);
31
+ const BrowsingContextInfo = (0, record_js_1.defineRecord)('browsingContext.Info', [{ "name": "children", "wire": "children", "required": true, "type": { "ref": "browsingContext.InfoList", "nullable": true } }, { "name": "clientWindow", "wire": "clientWindow", "required": true, "type": { "ref": "browser.ClientWindow" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "originalOpener", "wire": "originalOpener", "required": true, "type": { "ref": "browsingContext.BrowsingContext", "nullable": true } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": true, "type": { "ref": "browser.UserContext" } }, { "name": "parent", "wire": "parent", "required": false, "type": { "ref": "browsingContext.BrowsingContext", "nullable": true } }]);
32
+ const BrowsingContextLocatorUnion = (0, union_js_1.defineUnion)('browsingContext.Locator', { "by": "type", "variants": [{ "value": "accessibility", "ref": "browsingContext.AccessibilityLocator" }, { "value": "css", "ref": "browsingContext.CssLocator" }, { "value": "context", "ref": "browsingContext.ContextLocator" }, { "value": "innerText", "ref": "browsingContext.InnerTextLocator" }, { "value": "xpath", "ref": "browsingContext.XPathLocator" }] }, { "objectOnly": true });
33
+ const BrowsingContextAccessibilityLocator = (0, record_js_1.defineRecord)('browsingContext.AccessibilityLocator', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "accessibility" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "browsingContext.AccessibilityLocatorValue" } }]);
34
+ const BrowsingContextCssLocator = (0, record_js_1.defineRecord)('browsingContext.CssLocator', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "css" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
35
+ const BrowsingContextContextLocator = (0, record_js_1.defineRecord)('browsingContext.ContextLocator', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "context" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "browsingContext.ContextLocatorValue" } }]);
36
+ const BrowsingContextInnerTextLocator = (0, record_js_1.defineRecord)('browsingContext.InnerTextLocator', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "innerText" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }, { "name": "ignoreCase", "wire": "ignoreCase", "required": false, "type": { "primitive": "boolean" } }, { "name": "matchType", "wire": "matchType", "required": false, "type": { "ref": "browsingContext.InnerTextLocatorMatchType" } }, { "name": "maxDepth", "wire": "maxDepth", "required": false, "type": { "ref": "js-uint" } }]);
37
+ const BrowsingContextXPathLocator = (0, record_js_1.defineRecord)('browsingContext.XPathLocator', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "xpath" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
38
+ (0, record_js_1.defineAlias)('browsingContext.Navigation', { "primitive": "string" });
39
+ (0, record_js_1.defineAlias)('browsingContext.Download', { "primitive": "string" });
40
+ const BrowsingContextBaseNavigationInfo = (0, record_js_1.defineRecord)('browsingContext.BaseNavigationInfo', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "navigation", "wire": "navigation", "required": true, "type": { "ref": "browsingContext.Navigation", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
41
+ const BrowsingContextNavigationInfo = (0, record_js_1.defineRecord)('browsingContext.NavigationInfo', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "navigation", "wire": "navigation", "required": true, "type": { "ref": "browsingContext.Navigation", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
42
+ const BrowsingContextReadinessStateEnum = (0, enum_js_1.defineEnum)('browsingContext.ReadinessState', ["none", "interactive", "complete"]);
43
+ const BrowsingContextUserPromptTypeEnum = (0, enum_js_1.defineEnum)('browsingContext.UserPromptType', ["alert", "beforeunload", "confirm", "prompt"]);
44
+ const BrowsingContextActivate = (0, record_js_1.defineRecord)('browsingContext.Activate', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.activate" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.ActivateParameters" } }]);
45
+ const BrowsingContextActivateParameters = (0, record_js_1.defineRecord)('browsingContext.ActivateParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }]);
46
+ (0, record_js_1.defineAlias)('browsingContext.ActivateResult', { "ref": "EmptyResult" });
47
+ const BrowsingContextCaptureScreenshot = (0, record_js_1.defineRecord)('browsingContext.CaptureScreenshot', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.captureScreenshot" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.CaptureScreenshotParameters" } }]);
48
+ const BrowsingContextCaptureScreenshotParameters = (0, record_js_1.defineRecord)('browsingContext.CaptureScreenshotParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "origin", "wire": "origin", "required": false, "type": { "ref": "browsingContext.CaptureScreenshotParametersOrigin" } }, { "name": "format", "wire": "format", "required": false, "type": { "ref": "browsingContext.ImageFormat" } }, { "name": "clip", "wire": "clip", "required": false, "type": { "ref": "browsingContext.ClipRectangle" } }, { "name": "imageSize", "wire": "imageSize", "required": false, "type": { "ref": "browsingContext.ImageSize" } }]);
49
+ const BrowsingContextImageFormat = (0, record_js_1.defineRecord)('browsingContext.ImageFormat', [{ "name": "type", "wire": "type", "required": true, "type": { "primitive": "string" } }, { "name": "quality", "wire": "quality", "required": false, "type": { "primitive": "number" } }]);
50
+ const BrowsingContextImageSize = (0, record_js_1.defineRecord)('browsingContext.ImageSize', [{ "name": "maxWidth", "wire": "maxWidth", "required": false, "type": { "ref": "js-uint" } }, { "name": "maxHeight", "wire": "maxHeight", "required": false, "type": { "ref": "js-uint" } }]);
51
+ const BrowsingContextClipRectangleUnion = (0, union_js_1.defineUnion)('browsingContext.ClipRectangle', { "by": "type", "variants": [{ "value": "box", "ref": "browsingContext.BoxClipRectangle" }, { "value": "element", "ref": "browsingContext.ElementClipRectangle" }] }, { "objectOnly": true });
52
+ const BrowsingContextElementClipRectangle = (0, record_js_1.defineRecord)('browsingContext.ElementClipRectangle', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "element" } }, { "name": "element", "wire": "element", "required": true, "type": { "ref": "script.SharedReference" } }]);
53
+ const BrowsingContextBoxClipRectangle = (0, record_js_1.defineRecord)('browsingContext.BoxClipRectangle', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "box" } }, { "name": "x", "wire": "x", "required": true, "type": { "primitive": "number" } }, { "name": "y", "wire": "y", "required": true, "type": { "primitive": "number" } }, { "name": "width", "wire": "width", "required": true, "type": { "primitive": "number" } }, { "name": "height", "wire": "height", "required": true, "type": { "primitive": "number" } }]);
54
+ const BrowsingContextCaptureScreenshotResult = (0, record_js_1.defineRecord)('browsingContext.CaptureScreenshotResult', [{ "name": "data", "wire": "data", "required": true, "type": { "primitive": "string" } }]);
55
+ const BrowsingContextClose = (0, record_js_1.defineRecord)('browsingContext.Close', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.close" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.CloseParameters" } }]);
56
+ const BrowsingContextCloseParameters = (0, record_js_1.defineRecord)('browsingContext.CloseParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "promptUnload", "wire": "promptUnload", "required": false, "type": { "primitive": "boolean" } }]);
57
+ (0, record_js_1.defineAlias)('browsingContext.CloseResult', { "ref": "EmptyResult" });
58
+ const BrowsingContextCreate = (0, record_js_1.defineRecord)('browsingContext.Create', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.create" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.CreateParameters" } }]);
59
+ const BrowsingContextCreateTypeEnum = (0, enum_js_1.defineEnum)('browsingContext.CreateType', ["tab", "window"]);
60
+ const BrowsingContextCreateParameters = (0, record_js_1.defineRecord)('browsingContext.CreateParameters', [{ "name": "type", "wire": "type", "required": true, "type": { "ref": "browsingContext.CreateType" } }, { "name": "referenceContext", "wire": "referenceContext", "required": false, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "background", "wire": "background", "required": false, "type": { "primitive": "boolean" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
61
+ const BrowsingContextCreateResult = (0, record_js_1.defineRecord)('browsingContext.CreateResult', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
62
+ const BrowsingContextGetTree = (0, record_js_1.defineRecord)('browsingContext.GetTree', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.getTree" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.GetTreeParameters" } }]);
63
+ const BrowsingContextGetTreeParameters = (0, record_js_1.defineRecord)('browsingContext.GetTreeParameters', [{ "name": "maxDepth", "wire": "maxDepth", "required": false, "type": { "ref": "js-uint" } }, { "name": "root", "wire": "root", "required": false, "type": { "ref": "browsingContext.BrowsingContext" } }]);
64
+ const BrowsingContextGetTreeResult = (0, record_js_1.defineRecord)('browsingContext.GetTreeResult', [{ "name": "contexts", "wire": "contexts", "required": true, "type": { "ref": "browsingContext.InfoList" } }]);
65
+ const BrowsingContextHandleUserPrompt = (0, record_js_1.defineRecord)('browsingContext.HandleUserPrompt', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.handleUserPrompt" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.HandleUserPromptParameters" } }]);
66
+ const BrowsingContextHandleUserPromptParameters = (0, record_js_1.defineRecord)('browsingContext.HandleUserPromptParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "accept", "wire": "accept", "required": false, "type": { "primitive": "boolean" } }, { "name": "userText", "wire": "userText", "required": false, "type": { "primitive": "string" } }]);
67
+ (0, record_js_1.defineAlias)('browsingContext.HandleUserPromptResult', { "ref": "EmptyResult" });
68
+ const BrowsingContextLocateNodes = (0, record_js_1.defineRecord)('browsingContext.LocateNodes', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.locateNodes" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.LocateNodesParameters" } }]);
69
+ const BrowsingContextLocateNodesParameters = (0, record_js_1.defineRecord)('browsingContext.LocateNodesParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "locator", "wire": "locator", "required": true, "type": { "ref": "browsingContext.Locator" } }, { "name": "maxNodeCount", "wire": "maxNodeCount", "required": false, "type": { "ref": "js-uint" } }, { "name": "serializationOptions", "wire": "serializationOptions", "required": false, "type": { "ref": "script.SerializationOptions" } }, { "name": "startNodes", "wire": "startNodes", "required": false, "type": { "list": { "ref": "script.SharedReference" } } }]);
70
+ const BrowsingContextLocateNodesResult = (0, record_js_1.defineRecord)('browsingContext.LocateNodesResult', [{ "name": "nodes", "wire": "nodes", "required": true, "type": { "list": { "ref": "script.NodeRemoteValue" } } }]);
71
+ const BrowsingContextNavigate = (0, record_js_1.defineRecord)('browsingContext.Navigate', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.navigate" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigateParameters" } }]);
72
+ const BrowsingContextNavigateParameters = (0, record_js_1.defineRecord)('browsingContext.NavigateParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "wait", "wire": "wait", "required": false, "type": { "ref": "browsingContext.ReadinessState" } }]);
73
+ const BrowsingContextNavigateResult = (0, record_js_1.defineRecord)('browsingContext.NavigateResult', [{ "name": "navigation", "wire": "navigation", "required": true, "type": { "ref": "browsingContext.Navigation", "nullable": true } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }]);
74
+ const BrowsingContextPrint = (0, record_js_1.defineRecord)('browsingContext.Print', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.print" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.PrintParameters" } }]);
75
+ const BrowsingContextPrintParameters = (0, record_js_1.defineRecord)('browsingContext.PrintParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "background", "wire": "background", "required": false, "type": { "primitive": "boolean" } }, { "name": "margin", "wire": "margin", "required": false, "type": { "ref": "browsingContext.PrintMarginParameters" } }, { "name": "orientation", "wire": "orientation", "required": false, "type": { "ref": "browsingContext.PrintParametersOrientation" } }, { "name": "page", "wire": "page", "required": false, "type": { "ref": "browsingContext.PrintPageParameters" } }, { "name": "pageRanges", "wire": "pageRanges", "required": false, "type": { "list": { "union": [{ "ref": "js-uint" }, { "primitive": "string" }], "scalar": "string" } } }, { "name": "scale", "wire": "scale", "required": false, "type": { "primitive": "number" } }, { "name": "shrinkToFit", "wire": "shrinkToFit", "required": false, "type": { "primitive": "boolean" } }]);
76
+ const BrowsingContextPrintMarginParameters = (0, record_js_1.defineRecord)('browsingContext.PrintMarginParameters', [{ "name": "bottom", "wire": "bottom", "required": false, "type": { "primitive": "number" } }, { "name": "left", "wire": "left", "required": false, "type": { "primitive": "number" } }, { "name": "right", "wire": "right", "required": false, "type": { "primitive": "number" } }, { "name": "top", "wire": "top", "required": false, "type": { "primitive": "number" } }]);
77
+ const BrowsingContextPrintPageParameters = (0, record_js_1.defineRecord)('browsingContext.PrintPageParameters', [{ "name": "height", "wire": "height", "required": false, "type": { "primitive": "number" } }, { "name": "width", "wire": "width", "required": false, "type": { "primitive": "number" } }]);
78
+ const BrowsingContextPrintResult = (0, record_js_1.defineRecord)('browsingContext.PrintResult', [{ "name": "data", "wire": "data", "required": true, "type": { "primitive": "string" } }]);
79
+ const BrowsingContextReload = (0, record_js_1.defineRecord)('browsingContext.Reload', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.reload" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.ReloadParameters" } }]);
80
+ const BrowsingContextReloadParameters = (0, record_js_1.defineRecord)('browsingContext.ReloadParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "ignoreCache", "wire": "ignoreCache", "required": false, "type": { "primitive": "boolean" } }, { "name": "wait", "wire": "wait", "required": false, "type": { "ref": "browsingContext.ReadinessState" } }]);
81
+ (0, record_js_1.defineAlias)('browsingContext.ReloadResult', { "ref": "browsingContext.NavigateResult" });
82
+ const BrowsingContextSetBypassCsp = (0, record_js_1.defineRecord)('browsingContext.SetBypassCSP', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.setBypassCSP" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.SetBypassCSPParameters" } }]);
83
+ const BrowsingContextSetBypassCspParameters = (0, record_js_1.defineRecord)('browsingContext.SetBypassCSPParameters', [{ "name": "bypass", "wire": "bypass", "required": true, "type": { "const": true, "nullable": true } }, { "name": "contexts", "wire": "contexts", "required": false, "type": { "list": { "ref": "browsingContext.BrowsingContext" } } }, { "name": "userContexts", "wire": "userContexts", "required": false, "type": { "list": { "ref": "browser.UserContext" } } }]);
84
+ (0, record_js_1.defineAlias)('browsingContext.SetBypassCSPResult', { "ref": "EmptyResult" });
85
+ const BrowsingContextSetViewport = (0, record_js_1.defineRecord)('browsingContext.SetViewport', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.setViewport" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.SetViewportParameters" } }]);
86
+ const BrowsingContextSetViewportParameters = (0, record_js_1.defineRecord)('browsingContext.SetViewportParameters', [{ "name": "context", "wire": "context", "required": false, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "viewport", "wire": "viewport", "required": false, "type": { "ref": "browsingContext.Viewport", "nullable": true } }, { "name": "devicePixelRatio", "wire": "devicePixelRatio", "required": false, "type": { "primitive": "number", "nullable": true } }, { "name": "userContexts", "wire": "userContexts", "required": false, "type": { "list": { "ref": "browser.UserContext" } } }]);
87
+ const BrowsingContextViewport = (0, record_js_1.defineRecord)('browsingContext.Viewport', [{ "name": "width", "wire": "width", "required": true, "type": { "ref": "js-uint" } }, { "name": "height", "wire": "height", "required": true, "type": { "ref": "js-uint" } }]);
88
+ (0, record_js_1.defineAlias)('browsingContext.SetViewportResult', { "ref": "EmptyResult" });
89
+ const BrowsingContextStartScreencast = (0, record_js_1.defineRecord)('browsingContext.StartScreencast', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.startScreencast" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.StartScreencastParameters" } }]);
90
+ const BrowsingContextStartScreencastParameters = (0, record_js_1.defineRecord)('browsingContext.StartScreencastParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "destinationFolder", "wire": "destinationFolder", "required": false, "type": { "primitive": "string" } }, { "name": "mimeType", "wire": "mimeType", "required": false, "type": { "primitive": "string" } }, { "name": "video", "wire": "video", "required": false, "type": { "ref": "browsingContext.MediaTrackConstraints" } }, { "name": "audio", "wire": "audio", "required": false, "type": { "primitive": "boolean" } }]);
91
+ const BrowsingContextMediaTrackConstraints = (0, record_js_1.defineRecord)('browsingContext.MediaTrackConstraints', [{ "name": "width", "wire": "width", "required": false, "type": { "ref": "js-uint" } }, { "name": "height", "wire": "height", "required": false, "type": { "ref": "js-uint" } }, { "name": "frameRate", "wire": "frameRate", "required": false, "type": { "ref": "js-uint" } }]);
92
+ const BrowsingContextStartScreencastResult = (0, record_js_1.defineRecord)('browsingContext.StartScreencastResult', [{ "name": "screencast", "wire": "screencast", "required": true, "type": { "ref": "browsingContext.Screencast" } }, { "name": "path", "wire": "path", "required": true, "type": { "primitive": "string" } }]);
93
+ (0, record_js_1.defineAlias)('browsingContext.Screencast', { "primitive": "string" });
94
+ const BrowsingContextStopScreencast = (0, record_js_1.defineRecord)('browsingContext.StopScreencast', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.stopScreencast" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.StopScreencastParameters" } }]);
95
+ const BrowsingContextStopScreencastParameters = (0, record_js_1.defineRecord)('browsingContext.StopScreencastParameters', [{ "name": "screencast", "wire": "screencast", "required": true, "type": { "ref": "browsingContext.Screencast" } }]);
96
+ const BrowsingContextStopScreencastResult = (0, record_js_1.defineRecord)('browsingContext.StopScreencastResult', [{ "name": "path", "wire": "path", "required": true, "type": { "primitive": "string" } }, { "name": "error", "wire": "error", "required": false, "type": { "primitive": "string" } }]);
97
+ const BrowsingContextTraverseHistory = (0, record_js_1.defineRecord)('browsingContext.TraverseHistory', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.traverseHistory" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.TraverseHistoryParameters" } }]);
98
+ const BrowsingContextTraverseHistoryParameters = (0, record_js_1.defineRecord)('browsingContext.TraverseHistoryParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "delta", "wire": "delta", "required": true, "type": { "ref": "js-int" } }]);
99
+ (0, record_js_1.defineAlias)('browsingContext.TraverseHistoryResult', { "ref": "EmptyResult" });
100
+ const BrowsingContextContextCreated = (0, record_js_1.defineRecord)('browsingContext.ContextCreated', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.contextCreated" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.ContextCreatedParameters" } }]);
101
+ const BrowsingContextContextDestroyed = (0, record_js_1.defineRecord)('browsingContext.ContextDestroyed', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.contextDestroyed" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.Info" } }]);
102
+ const BrowsingContextNavigationStarted = (0, record_js_1.defineRecord)('browsingContext.NavigationStarted', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.navigationStarted" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
103
+ const BrowsingContextFragmentNavigated = (0, record_js_1.defineRecord)('browsingContext.FragmentNavigated', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.fragmentNavigated" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
104
+ const BrowsingContextHistoryUpdated = (0, record_js_1.defineRecord)('browsingContext.HistoryUpdated', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.historyUpdated" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.HistoryUpdatedParameters" } }]);
105
+ const BrowsingContextHistoryUpdatedParameters = (0, record_js_1.defineRecord)('browsingContext.HistoryUpdatedParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
106
+ const BrowsingContextDomContentLoaded = (0, record_js_1.defineRecord)('browsingContext.DomContentLoaded', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.domContentLoaded" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
107
+ const BrowsingContextLoad = (0, record_js_1.defineRecord)('browsingContext.Load', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.load" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
108
+ const BrowsingContextDownloadWillBegin = (0, record_js_1.defineRecord)('browsingContext.DownloadWillBegin', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.downloadWillBegin" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.DownloadWillBeginParams" } }]);
109
+ const BrowsingContextDownloadWillBeginParams = (0, record_js_1.defineRecord)('browsingContext.DownloadWillBeginParams', [{ "name": "download", "wire": "download", "required": true, "type": { "ref": "browsingContext.Download" } }, { "name": "suggestedFilename", "wire": "suggestedFilename", "required": true, "type": { "primitive": "string" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "navigation", "wire": "navigation", "required": true, "type": { "ref": "browsingContext.Navigation", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
110
+ const BrowsingContextDownloadEnd = (0, record_js_1.defineRecord)('browsingContext.DownloadEnd', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.downloadEnd" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.DownloadEndParams" } }]);
111
+ const BrowsingContextDownloadEndParamsUnion = (0, union_js_1.defineUnion)('browsingContext.DownloadEndParams', { "by": "status", "variants": [{ "value": "canceled", "ref": "browsingContext.DownloadEndParams_CanceledParams" }, { "value": "complete", "ref": "browsingContext.DownloadEndParams_CompleteParams" }] }, { "objectOnly": true });
112
+ const BrowsingContextNavigationAborted = (0, record_js_1.defineRecord)('browsingContext.NavigationAborted', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.navigationAborted" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
113
+ const BrowsingContextNavigationCommitted = (0, record_js_1.defineRecord)('browsingContext.NavigationCommitted', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.navigationCommitted" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
114
+ const BrowsingContextNavigationFailed = (0, record_js_1.defineRecord)('browsingContext.NavigationFailed', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.navigationFailed" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.NavigationInfo" } }]);
115
+ const BrowsingContextUserPromptClosed = (0, record_js_1.defineRecord)('browsingContext.UserPromptClosed', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.userPromptClosed" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.UserPromptClosedParameters" } }]);
116
+ const BrowsingContextUserPromptClosedParameters = (0, record_js_1.defineRecord)('browsingContext.UserPromptClosedParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "accepted", "wire": "accepted", "required": true, "type": { "primitive": "boolean" } }, { "name": "type", "wire": "type", "required": true, "type": { "ref": "browsingContext.UserPromptType" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }, { "name": "userText", "wire": "userText", "required": false, "type": { "primitive": "string" } }]);
117
+ const BrowsingContextUserPromptOpened = (0, record_js_1.defineRecord)('browsingContext.UserPromptOpened', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "browsingContext.userPromptOpened" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "browsingContext.UserPromptOpenedParameters" } }]);
118
+ const BrowsingContextUserPromptOpenedParameters = (0, record_js_1.defineRecord)('browsingContext.UserPromptOpenedParameters', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "handler", "wire": "handler", "required": true, "type": { "ref": "session.UserPromptHandlerType" } }, { "name": "message", "wire": "message", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "ref": "browsingContext.UserPromptType" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }, { "name": "defaultValue", "wire": "defaultValue", "required": false, "type": { "primitive": "string" } }]);
119
+ const BrowsingContextContextCreatedParameters = (0, record_js_1.defineRecord)('browsingContext.ContextCreatedParameters', [{ "name": "children", "wire": "children", "required": true, "type": { "ref": "browsingContext.InfoList", "nullable": true } }, { "name": "clientWindow", "wire": "clientWindow", "required": true, "type": { "ref": "browser.ClientWindow" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "originalOpener", "wire": "originalOpener", "required": true, "type": { "ref": "browsingContext.BrowsingContext", "nullable": true } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": true, "type": { "ref": "browser.UserContext" } }, { "name": "parent", "wire": "parent", "required": false, "type": { "ref": "browsingContext.BrowsingContext", "nullable": true } }, { "name": "hasPlannedNavigation", "wire": "hasPlannedNavigation", "required": false, "type": { "primitive": "boolean" } }]);
120
+ const BrowsingContextInnerTextLocatorMatchTypeEnum = (0, enum_js_1.defineEnum)('browsingContext.InnerTextLocatorMatchType', ["full", "partial"]);
121
+ const BrowsingContextCaptureScreenshotParametersOriginEnum = (0, enum_js_1.defineEnum)('browsingContext.CaptureScreenshotParametersOrigin', ["viewport", "document"]);
122
+ const BrowsingContextPrintParametersOrientationEnum = (0, enum_js_1.defineEnum)('browsingContext.PrintParametersOrientation', ["portrait", "landscape"]);
123
+ const BrowsingContextDownloadEndParams_CanceledParams = (0, record_js_1.defineRecord)('browsingContext.DownloadEndParams_CanceledParams', [{ "name": "status", "wire": "status", "required": true, "type": { "const": "canceled" } }, { "name": "download", "wire": "download", "required": true, "type": { "ref": "browsingContext.Download" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "navigation", "wire": "navigation", "required": true, "type": { "ref": "browsingContext.Navigation", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
124
+ const BrowsingContextDownloadEndParams_CompleteParams = (0, record_js_1.defineRecord)('browsingContext.DownloadEndParams_CompleteParams', [{ "name": "status", "wire": "status", "required": true, "type": { "const": "complete" } }, { "name": "download", "wire": "download", "required": true, "type": { "ref": "browsingContext.Download" } }, { "name": "filepath", "wire": "filepath", "required": true, "type": { "primitive": "string", "nullable": true } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "navigation", "wire": "navigation", "required": true, "type": { "ref": "browsingContext.Navigation", "nullable": true } }, { "name": "timestamp", "wire": "timestamp", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
125
+ const BrowsingContextAccessibilityLocatorValue = (0, record_js_1.defineRecord)('browsingContext.AccessibilityLocatorValue', [{ "name": "name", "wire": "name", "required": false, "type": { "primitive": "string" } }, { "name": "role", "wire": "role", "required": false, "type": { "primitive": "string" } }]);
126
+ const BrowsingContextContextLocatorValue = (0, record_js_1.defineRecord)('browsingContext.ContextLocatorValue', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }]);
26
127
  // --- Implementation ---
27
- class BrowsingContext {
28
- constructor(bidi) {
29
- this.bidi = bidi;
30
- }
128
+ /**
129
+ * This is an unsupported API. No compatibility guarantees are provided.
130
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
131
+ * evolves, this API will change or be removed without prior notice.
132
+ */
133
+ class BrowsingContext extends domain_js_1.Domain {
31
134
  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 BrowsingContext(bidi);
38
- }
135
+ return new BrowsingContext(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
136
+ }
137
+ /**
138
+ * @param {BrowsingContextActivateParameters} params
139
+ * @param {BrowsingContextBrowsingContext} params.context
140
+ * @returns {Promise<void>}
141
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-activate
142
+ */
39
143
  async activate(params) {
40
- const response = await this.bidi.send({
41
- method: 'browsingContext.activate',
42
- params: params,
43
- });
44
- if (response['type'] === 'error') {
45
- throw new Error(`${response['error']}: ${response['message']}`);
46
- }
47
- }
144
+ const validatedParams = new BrowsingContextActivateParameters(params);
145
+ await this.send('browsingContext.activate', validatedParams);
146
+ }
147
+ /**
148
+ * @param {BrowsingContextCaptureScreenshotParameters} params
149
+ * @param {BrowsingContextBrowsingContext} params.context
150
+ * @param {BrowsingContextCaptureScreenshotParametersOrigin} [params.origin]
151
+ * @param {BrowsingContextImageFormat} [params.format]
152
+ * @param {BrowsingContextClipRectangle} [params.clip]
153
+ * @param {BrowsingContextImageSize} [params.imageSize]
154
+ * @returns {Promise<BrowsingContextCaptureScreenshotResult>}
155
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-captureScreenshot
156
+ */
48
157
  async captureScreenshot(params) {
49
- const response = await this.bidi.send({
50
- method: 'browsingContext.captureScreenshot',
51
- params: params,
52
- });
53
- if (response['type'] === 'error') {
54
- throw new Error(`${response['error']}: ${response['message']}`);
55
- }
56
- return response.result;
57
- }
158
+ const validatedParams = new BrowsingContextCaptureScreenshotParameters(params);
159
+ const result = await this.send('browsingContext.captureScreenshot', validatedParams);
160
+ return BrowsingContextCaptureScreenshotResult.fromWire(result);
161
+ }
162
+ /**
163
+ * @param {BrowsingContextCloseParameters} params
164
+ * @param {BrowsingContextBrowsingContext} params.context
165
+ * @param {boolean} [params.promptUnload]
166
+ * @returns {Promise<void>}
167
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-close
168
+ */
58
169
  async close(params) {
59
- const response = await this.bidi.send({
60
- method: 'browsingContext.close',
61
- params: params,
62
- });
63
- if (response['type'] === 'error') {
64
- throw new Error(`${response['error']}: ${response['message']}`);
65
- }
66
- }
170
+ const validatedParams = new BrowsingContextCloseParameters(params);
171
+ await this.send('browsingContext.close', validatedParams);
172
+ }
173
+ /**
174
+ * @param {BrowsingContextCreateParameters} params
175
+ * @param {BrowsingContextCreateType} params.type
176
+ * @param {BrowsingContextBrowsingContext} [params.referenceContext]
177
+ * @param {boolean} [params.background]
178
+ * @param {BrowserUserContext} [params.userContext]
179
+ * @returns {Promise<BrowsingContextCreateResult>}
180
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-create
181
+ */
67
182
  async create(params) {
68
- const response = await this.bidi.send({
69
- method: 'browsingContext.create',
70
- params: params,
71
- });
72
- if (response['type'] === 'error') {
73
- throw new Error(`${response['error']}: ${response['message']}`);
74
- }
75
- return response.result;
76
- }
183
+ const validatedParams = new BrowsingContextCreateParameters(params);
184
+ const result = await this.send('browsingContext.create', validatedParams);
185
+ return BrowsingContextCreateResult.fromWire(result);
186
+ }
187
+ /**
188
+ * @param {BrowsingContextGetTreeParameters} params
189
+ * @param {JsUint} [params.maxDepth]
190
+ * @param {BrowsingContextBrowsingContext} [params.root]
191
+ * @returns {Promise<BrowsingContextGetTreeResult>}
192
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-getTree
193
+ */
77
194
  async getTree(params) {
78
- const response = await this.bidi.send({
79
- method: 'browsingContext.getTree',
80
- params: params,
81
- });
82
- if (response['type'] === 'error') {
83
- throw new Error(`${response['error']}: ${response['message']}`);
84
- }
85
- return response.result;
86
- }
195
+ const validatedParams = new BrowsingContextGetTreeParameters(params);
196
+ const result = await this.send('browsingContext.getTree', validatedParams);
197
+ return BrowsingContextGetTreeResult.fromWire(result);
198
+ }
199
+ /**
200
+ * @param {BrowsingContextHandleUserPromptParameters} params
201
+ * @param {BrowsingContextBrowsingContext} params.context
202
+ * @param {boolean} [params.accept]
203
+ * @param {string} [params.userText]
204
+ * @returns {Promise<void>}
205
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-handleUserPrompt
206
+ */
87
207
  async handleUserPrompt(params) {
88
- const response = await this.bidi.send({
89
- method: 'browsingContext.handleUserPrompt',
90
- params: params,
91
- });
92
- if (response['type'] === 'error') {
93
- throw new Error(`${response['error']}: ${response['message']}`);
94
- }
95
- }
208
+ const validatedParams = new BrowsingContextHandleUserPromptParameters(params);
209
+ await this.send('browsingContext.handleUserPrompt', validatedParams);
210
+ }
211
+ /**
212
+ * @param {BrowsingContextLocateNodesParameters} params
213
+ * @param {BrowsingContextBrowsingContext} params.context
214
+ * @param {BrowsingContextLocator} params.locator
215
+ * @param {JsUint} [params.maxNodeCount]
216
+ * @param {ScriptSerializationOptions} [params.serializationOptions]
217
+ * @param {Array<ScriptSharedReference>} [params.startNodes]
218
+ * @returns {Promise<BrowsingContextLocateNodesResult>}
219
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-locateNodes
220
+ */
96
221
  async locateNodes(params) {
97
- const response = await this.bidi.send({
98
- method: 'browsingContext.locateNodes',
99
- params: params,
100
- });
101
- if (response['type'] === 'error') {
102
- throw new Error(`${response['error']}: ${response['message']}`);
103
- }
104
- return response.result;
105
- }
222
+ const validatedParams = new BrowsingContextLocateNodesParameters(params);
223
+ const result = await this.send('browsingContext.locateNodes', validatedParams);
224
+ return BrowsingContextLocateNodesResult.fromWire(result);
225
+ }
226
+ /**
227
+ * @param {BrowsingContextNavigateParameters} params
228
+ * @param {BrowsingContextBrowsingContext} params.context
229
+ * @param {string} params.url
230
+ * @param {BrowsingContextReadinessState} [params.wait]
231
+ * @returns {Promise<BrowsingContextNavigateResult>}
232
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-navigate
233
+ */
106
234
  async navigate(params) {
107
- const response = await this.bidi.send({
108
- method: 'browsingContext.navigate',
109
- params: params,
110
- });
111
- if (response['type'] === 'error') {
112
- throw new Error(`${response['error']}: ${response['message']}`);
113
- }
114
- return response.result;
115
- }
235
+ const validatedParams = new BrowsingContextNavigateParameters(params);
236
+ const result = await this.send('browsingContext.navigate', validatedParams);
237
+ return BrowsingContextNavigateResult.fromWire(result);
238
+ }
239
+ /**
240
+ * @param {BrowsingContextPrintParameters} params
241
+ * @param {BrowsingContextBrowsingContext} params.context
242
+ * @param {boolean} [params.background]
243
+ * @param {BrowsingContextPrintMarginParameters} [params.margin]
244
+ * @param {BrowsingContextPrintParametersOrientation} [params.orientation]
245
+ * @param {BrowsingContextPrintPageParameters} [params.page]
246
+ * @param {Array<JsUint | string>} [params.pageRanges]
247
+ * @param {number} [params.scale]
248
+ * @param {boolean} [params.shrinkToFit]
249
+ * @returns {Promise<BrowsingContextPrintResult>}
250
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-print
251
+ */
116
252
  async print(params) {
117
- const response = await this.bidi.send({
118
- method: 'browsingContext.print',
119
- params: params,
120
- });
121
- if (response['type'] === 'error') {
122
- throw new Error(`${response['error']}: ${response['message']}`);
123
- }
124
- return response.result;
125
- }
253
+ const validatedParams = new BrowsingContextPrintParameters(params);
254
+ const result = await this.send('browsingContext.print', validatedParams);
255
+ return BrowsingContextPrintResult.fromWire(result);
256
+ }
257
+ /**
258
+ * @param {BrowsingContextReloadParameters} params
259
+ * @param {BrowsingContextBrowsingContext} params.context
260
+ * @param {boolean} [params.ignoreCache]
261
+ * @param {BrowsingContextReadinessState} [params.wait]
262
+ * @returns {Promise<BrowsingContextReloadResult>}
263
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-reload
264
+ */
126
265
  async reload(params) {
127
- const response = await this.bidi.send({
128
- method: 'browsingContext.reload',
129
- params: params,
130
- });
131
- if (response['type'] === 'error') {
132
- throw new Error(`${response['error']}: ${response['message']}`);
133
- }
134
- return response.result;
135
- }
266
+ const validatedParams = new BrowsingContextReloadParameters(params);
267
+ const result = await this.send('browsingContext.reload', validatedParams);
268
+ return BrowsingContextNavigateResult.fromWire(result);
269
+ }
270
+ /**
271
+ * @param {BrowsingContextSetBypassCspParameters} params
272
+ * @param {true | null} params.bypass
273
+ * @param {Array<BrowsingContextBrowsingContext>} [params.contexts]
274
+ * @param {Array<BrowserUserContext>} [params.userContexts]
275
+ * @returns {Promise<void>}
276
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-setBypassCSP
277
+ */
136
278
  async setBypassCSP(params) {
137
- const response = await this.bidi.send({
138
- method: 'browsingContext.setBypassCSP',
139
- params: params,
140
- });
141
- if (response['type'] === 'error') {
142
- throw new Error(`${response['error']}: ${response['message']}`);
143
- }
144
- }
279
+ const validatedParams = new BrowsingContextSetBypassCspParameters(params);
280
+ await this.send('browsingContext.setBypassCSP', validatedParams);
281
+ }
282
+ /**
283
+ * @param {BrowsingContextSetViewportParameters} params
284
+ * @param {BrowsingContextBrowsingContext} [params.context]
285
+ * @param {BrowsingContextViewport | null} [params.viewport]
286
+ * @param {number | null} [params.devicePixelRatio]
287
+ * @param {Array<BrowserUserContext>} [params.userContexts]
288
+ * @returns {Promise<void>}
289
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-setViewport
290
+ */
145
291
  async setViewport(params) {
146
- const response = await this.bidi.send({
147
- method: 'browsingContext.setViewport',
148
- params: params,
149
- });
150
- if (response['type'] === 'error') {
151
- throw new Error(`${response['error']}: ${response['message']}`);
152
- }
153
- }
292
+ const validatedParams = new BrowsingContextSetViewportParameters(params);
293
+ await this.send('browsingContext.setViewport', validatedParams);
294
+ }
295
+ /**
296
+ * @param {BrowsingContextStartScreencastParameters} params
297
+ * @param {BrowsingContextBrowsingContext} params.context
298
+ * @param {string} [params.destinationFolder]
299
+ * @param {string} [params.mimeType]
300
+ * @param {BrowsingContextMediaTrackConstraints} [params.video]
301
+ * @param {boolean} [params.audio]
302
+ * @returns {Promise<BrowsingContextStartScreencastResult>}
303
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-startScreencast
304
+ */
154
305
  async startScreencast(params) {
155
- const response = await this.bidi.send({
156
- method: 'browsingContext.startScreencast',
157
- params: params,
158
- });
159
- if (response['type'] === 'error') {
160
- throw new Error(`${response['error']}: ${response['message']}`);
161
- }
162
- return response.result;
163
- }
306
+ const validatedParams = new BrowsingContextStartScreencastParameters(params);
307
+ const result = await this.send('browsingContext.startScreencast', validatedParams);
308
+ return BrowsingContextStartScreencastResult.fromWire(result);
309
+ }
310
+ /**
311
+ * @param {BrowsingContextStopScreencastParameters} params
312
+ * @param {BrowsingContextScreencast} params.screencast
313
+ * @returns {Promise<BrowsingContextStopScreencastResult>}
314
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-stopScreencast
315
+ */
164
316
  async stopScreencast(params) {
165
- const response = await this.bidi.send({
166
- method: 'browsingContext.stopScreencast',
167
- params: params,
168
- });
169
- if (response['type'] === 'error') {
170
- throw new Error(`${response['error']}: ${response['message']}`);
171
- }
172
- return response.result;
173
- }
317
+ const validatedParams = new BrowsingContextStopScreencastParameters(params);
318
+ const result = await this.send('browsingContext.stopScreencast', validatedParams);
319
+ return BrowsingContextStopScreencastResult.fromWire(result);
320
+ }
321
+ /**
322
+ * @param {BrowsingContextTraverseHistoryParameters} params
323
+ * @param {BrowsingContextBrowsingContext} params.context
324
+ * @param {JsInt} params.delta
325
+ * @returns {Promise<void>}
326
+ * @see https://w3c.github.io/webdriver-bidi/#command-browsingContext-traverseHistory
327
+ */
174
328
  async traverseHistory(params) {
175
- const response = await this.bidi.send({
176
- method: 'browsingContext.traverseHistory',
177
- params: params,
178
- });
179
- if (response['type'] === 'error') {
180
- throw new Error(`${response['error']}: ${response['message']}`);
181
- }
182
- }
183
- async onContextCreated(callback) {
184
- await this.bidi.subscribe('browsingContext.contextCreated');
185
- this.bidi.on('browsingContext.contextCreated', (params) => {
186
- callback(params);
187
- });
188
- }
189
- async onContextDestroyed(callback) {
190
- await this.bidi.subscribe('browsingContext.contextDestroyed');
191
- this.bidi.on('browsingContext.contextDestroyed', (params) => {
192
- callback(params);
193
- });
194
- }
195
- async onDomContentLoaded(callback) {
196
- await this.bidi.subscribe('browsingContext.domContentLoaded');
197
- this.bidi.on('browsingContext.domContentLoaded', (params) => {
198
- callback(params);
199
- });
200
- }
201
- async onDownloadEnd(callback) {
202
- await this.bidi.subscribe('browsingContext.downloadEnd');
203
- this.bidi.on('browsingContext.downloadEnd', (params) => {
204
- callback(params);
205
- });
206
- }
207
- async onDownloadWillBegin(callback) {
208
- await this.bidi.subscribe('browsingContext.downloadWillBegin');
209
- this.bidi.on('browsingContext.downloadWillBegin', (params) => {
210
- callback(params);
211
- });
212
- }
213
- async onFragmentNavigated(callback) {
214
- await this.bidi.subscribe('browsingContext.fragmentNavigated');
215
- this.bidi.on('browsingContext.fragmentNavigated', (params) => {
216
- callback(params);
217
- });
218
- }
219
- async onHistoryUpdated(callback) {
220
- await this.bidi.subscribe('browsingContext.historyUpdated');
221
- this.bidi.on('browsingContext.historyUpdated', (params) => {
222
- callback(params);
223
- });
224
- }
225
- async onLoad(callback) {
226
- await this.bidi.subscribe('browsingContext.load');
227
- this.bidi.on('browsingContext.load', (params) => {
228
- callback(params);
229
- });
230
- }
231
- async onNavigationAborted(callback) {
232
- await this.bidi.subscribe('browsingContext.navigationAborted');
233
- this.bidi.on('browsingContext.navigationAborted', (params) => {
234
- callback(params);
235
- });
236
- }
237
- async onNavigationCommitted(callback) {
238
- await this.bidi.subscribe('browsingContext.navigationCommitted');
239
- this.bidi.on('browsingContext.navigationCommitted', (params) => {
240
- callback(params);
241
- });
242
- }
243
- async onNavigationFailed(callback) {
244
- await this.bidi.subscribe('browsingContext.navigationFailed');
245
- this.bidi.on('browsingContext.navigationFailed', (params) => {
246
- callback(params);
247
- });
248
- }
249
- async onNavigationStarted(callback) {
250
- await this.bidi.subscribe('browsingContext.navigationStarted');
251
- this.bidi.on('browsingContext.navigationStarted', (params) => {
252
- callback(params);
253
- });
254
- }
255
- async onUserPromptClosed(callback) {
256
- await this.bidi.subscribe('browsingContext.userPromptClosed');
257
- this.bidi.on('browsingContext.userPromptClosed', (params) => {
258
- callback(params);
259
- });
260
- }
261
- async onUserPromptOpened(callback) {
262
- await this.bidi.subscribe('browsingContext.userPromptOpened');
263
- this.bidi.on('browsingContext.userPromptOpened', (params) => {
264
- callback(params);
265
- });
266
- }
267
- async back(context) {
268
- await this.traverseHistory({ context, delta: -1 });
269
- }
270
- async forward(context) {
271
- await this.traverseHistory({ context, delta: 1 });
272
- }
273
- async getTopLevelContexts() {
274
- return this.getTree({});
275
- }
276
- async printPage(params) {
277
- return this.print(params);
329
+ const validatedParams = new BrowsingContextTraverseHistoryParameters(params);
330
+ await this.send('browsingContext.traverseHistory', validatedParams);
278
331
  }
279
332
  }
280
333
  exports.BrowsingContext = BrowsingContext;
334
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-contextCreated */
335
+ BrowsingContext.CONTEXT_CREATED = (0, domain_js_1.event)('browsingContext.contextCreated', BrowsingContextContextCreatedParameters);
336
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-contextDestroyed */
337
+ BrowsingContext.CONTEXT_DESTROYED = (0, domain_js_1.event)('browsingContext.contextDestroyed', BrowsingContextInfo);
338
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-domContentLoaded */
339
+ BrowsingContext.DOM_CONTENT_LOADED = (0, domain_js_1.event)('browsingContext.domContentLoaded', BrowsingContextNavigationInfo);
340
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-downloadEnd */
341
+ BrowsingContext.DOWNLOAD_END = (0, domain_js_1.event)('browsingContext.downloadEnd', BrowsingContextDownloadEndParamsUnion);
342
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-downloadWillBegin */
343
+ BrowsingContext.DOWNLOAD_WILL_BEGIN = (0, domain_js_1.event)('browsingContext.downloadWillBegin', BrowsingContextDownloadWillBeginParams);
344
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-fragmentNavigated */
345
+ BrowsingContext.FRAGMENT_NAVIGATED = (0, domain_js_1.event)('browsingContext.fragmentNavigated', BrowsingContextNavigationInfo);
346
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-historyUpdated */
347
+ BrowsingContext.HISTORY_UPDATED = (0, domain_js_1.event)('browsingContext.historyUpdated', BrowsingContextHistoryUpdatedParameters);
348
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-load */
349
+ BrowsingContext.LOAD = (0, domain_js_1.event)('browsingContext.load', BrowsingContextNavigationInfo);
350
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-navigationAborted */
351
+ BrowsingContext.NAVIGATION_ABORTED = (0, domain_js_1.event)('browsingContext.navigationAborted', BrowsingContextNavigationInfo);
352
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-navigationCommitted */
353
+ BrowsingContext.NAVIGATION_COMMITTED = (0, domain_js_1.event)('browsingContext.navigationCommitted', BrowsingContextNavigationInfo);
354
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-navigationFailed */
355
+ BrowsingContext.NAVIGATION_FAILED = (0, domain_js_1.event)('browsingContext.navigationFailed', BrowsingContextNavigationInfo);
356
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-navigationStarted */
357
+ BrowsingContext.NAVIGATION_STARTED = (0, domain_js_1.event)('browsingContext.navigationStarted', BrowsingContextNavigationInfo);
358
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-userPromptClosed */
359
+ BrowsingContext.USER_PROMPT_CLOSED = (0, domain_js_1.event)('browsingContext.userPromptClosed', BrowsingContextUserPromptClosedParameters);
360
+ /** @see https://w3c.github.io/webdriver-bidi/#event-browsingContext-userPromptOpened */
361
+ BrowsingContext.USER_PROMPT_OPENED = (0, domain_js_1.event)('browsingContext.userPromptOpened', BrowsingContextUserPromptOpenedParameters);
362
+ BrowsingContext.ReadinessState = Object.freeze({ NONE: "none", INTERACTIVE: "interactive", COMPLETE: "complete" });
363
+ BrowsingContext.UserPromptType = Object.freeze({ ALERT: "alert", BEFOREUNLOAD: "beforeunload", CONFIRM: "confirm", PROMPT: "prompt" });
364
+ BrowsingContext.CreateType = Object.freeze({ TAB: "tab", WINDOW: "window" });
365
+ BrowsingContext.InnerTextLocatorMatchType = Object.freeze({ FULL: "full", PARTIAL: "partial" });
366
+ BrowsingContext.CaptureScreenshotParametersOrigin = Object.freeze({ VIEWPORT: "viewport", DOCUMENT: "document" });
367
+ BrowsingContext.PrintParametersOrientation = Object.freeze({ PORTRAIT: "portrait", LANDSCAPE: "landscape" });