selenium-webdriver 4.49.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 (49) hide show
  1. package/CHANGES.md +16 -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 +269 -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 +347 -77
  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-x86_64/selenium-manager +0 -0
  38. package/bin/macos/selenium-manager +0 -0
  39. package/bin/selenium-manager-THIRD-PARTY-NOTICES.txt +74 -43
  40. package/bin/selenium-manager.cdx.json +421 -421
  41. package/bin/windows/selenium-manager.exe +0 -0
  42. package/eslint.config.js +2 -1
  43. package/firefox.js +7 -104
  44. package/index.js +8 -0
  45. package/lib/atoms/find-elements.js +14 -2
  46. package/package.json +9 -9
  47. package/remote/index.js +12 -3
  48. package/remote/util.js +5 -5
  49. package/testing/index.js +84 -1
@@ -17,130 +17,217 @@
17
17
  // under the License.
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Script = void 0;
20
- exports.getScriptManagerInstance = getScriptManagerInstance;
21
- // --- Additional Types ---
22
- /** @deprecated Use {@link Script.create} instead — will be removed in a future major version. */
23
- async function getScriptManagerInstance(driver) {
24
- return Script.create(driver);
25
- }
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
+ (0, record_js_1.defineAlias)('script.Channel', { "primitive": "string" });
28
+ const ScriptChannelValue = (0, record_js_1.defineRecord)('script.ChannelValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "channel" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.ChannelProperties" } }]);
29
+ const ScriptChannelProperties = (0, record_js_1.defineRecord)('script.ChannelProperties', [{ "name": "channel", "wire": "channel", "required": true, "type": { "ref": "script.Channel" } }, { "name": "serializationOptions", "wire": "serializationOptions", "required": false, "type": { "ref": "script.SerializationOptions" } }, { "name": "ownership", "wire": "ownership", "required": false, "type": { "ref": "script.ResultOwnership" } }]);
30
+ const ScriptEvaluateResultUnion = (0, union_js_1.defineUnion)('script.EvaluateResult', { "by": "type", "variants": [{ "value": "success", "ref": "script.EvaluateResultSuccess" }, { "value": "exception", "ref": "script.EvaluateResultException" }] }, { "objectOnly": true });
31
+ const ScriptEvaluateResultSuccess = (0, record_js_1.defineRecord)('script.EvaluateResultSuccess', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "success" } }, { "name": "result", "wire": "result", "required": true, "type": { "ref": "script.RemoteValue" } }, { "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }]);
32
+ const ScriptEvaluateResultException = (0, record_js_1.defineRecord)('script.EvaluateResultException', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "exception" } }, { "name": "exceptionDetails", "wire": "exceptionDetails", "required": true, "type": { "ref": "script.ExceptionDetails" } }, { "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }]);
33
+ const ScriptExceptionDetails = (0, record_js_1.defineRecord)('script.ExceptionDetails', [{ "name": "columnNumber", "wire": "columnNumber", "required": true, "type": { "ref": "js-uint" } }, { "name": "exception", "wire": "exception", "required": true, "type": { "ref": "script.RemoteValue" } }, { "name": "lineNumber", "wire": "lineNumber", "required": true, "type": { "ref": "js-uint" } }, { "name": "stackTrace", "wire": "stackTrace", "required": true, "type": { "ref": "script.StackTrace" } }, { "name": "text", "wire": "text", "required": true, "type": { "primitive": "string" } }]);
34
+ (0, record_js_1.defineAlias)('script.Handle', { "primitive": "string" });
35
+ (0, record_js_1.defineAlias)('script.InternalId', { "primitive": "string" });
36
+ const ScriptLocalValueUnion = (0, union_js_1.defineUnion)('script.LocalValue', { "by": "type", "variants": [{ "value": "undefined", "ref": "script.UndefinedValue" }, { "value": "null", "ref": "script.NullValue" }, { "value": "string", "ref": "script.StringValue" }, { "value": "number", "ref": "script.NumberValue" }, { "value": "boolean", "ref": "script.BooleanValue" }, { "value": "bigint", "ref": "script.BigIntValue" }, { "value": "channel", "ref": "script.ChannelValue" }, { "value": "array", "ref": "script.ArrayLocalValue" }, { "value": "date", "ref": "script.DateLocalValue" }, { "value": "map", "ref": "script.MapLocalValue" }, { "value": "object", "ref": "script.ObjectLocalValue" }, { "value": "regexp", "ref": "script.RegExpLocalValue" }, { "value": "set", "ref": "script.SetLocalValue" }], "default": "script.RemoteReference" }, { "objectOnly": true });
37
+ (0, record_js_1.defineAlias)('script.ListLocalValue', { "list": { "ref": "script.LocalValue" } });
38
+ const ScriptArrayLocalValue = (0, record_js_1.defineRecord)('script.ArrayLocalValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "array" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.ListLocalValue" } }]);
39
+ const ScriptDateLocalValue = (0, record_js_1.defineRecord)('script.DateLocalValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "date" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
40
+ (0, record_js_1.defineAlias)('script.MappingLocalValue', { "list": { "list": { "union": [{ "ref": "script.LocalValue" }, { "primitive": "string" }], "scalar": "string" } } });
41
+ const ScriptMapLocalValue = (0, record_js_1.defineRecord)('script.MapLocalValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "map" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.MappingLocalValue" } }]);
42
+ const ScriptObjectLocalValue = (0, record_js_1.defineRecord)('script.ObjectLocalValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "object" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.MappingLocalValue" } }]);
43
+ const ScriptRegExpValue = (0, record_js_1.defineRecord)('script.RegExpValue', [{ "name": "pattern", "wire": "pattern", "required": true, "type": { "primitive": "string" } }, { "name": "flags", "wire": "flags", "required": false, "type": { "primitive": "string" } }]);
44
+ const ScriptRegExpLocalValue = (0, record_js_1.defineRecord)('script.RegExpLocalValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "regexp" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.RegExpValue" } }]);
45
+ const ScriptSetLocalValue = (0, record_js_1.defineRecord)('script.SetLocalValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "set" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.ListLocalValue" } }]);
46
+ (0, record_js_1.defineAlias)('script.PreloadScript', { "primitive": "string" });
47
+ (0, record_js_1.defineAlias)('script.Realm', { "primitive": "string" });
48
+ const ScriptPrimitiveProtocolValueUnion = (0, union_js_1.defineUnion)('script.PrimitiveProtocolValue', { "by": "type", "variants": [{ "value": "undefined", "ref": "script.UndefinedValue" }, { "value": "null", "ref": "script.NullValue" }, { "value": "string", "ref": "script.StringValue" }, { "value": "number", "ref": "script.NumberValue" }, { "value": "boolean", "ref": "script.BooleanValue" }, { "value": "bigint", "ref": "script.BigIntValue" }] }, { "objectOnly": true });
49
+ const ScriptUndefinedValue = (0, record_js_1.defineRecord)('script.UndefinedValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "undefined" } }]);
50
+ const ScriptNullValue = (0, record_js_1.defineRecord)('script.NullValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "null" } }]);
51
+ const ScriptStringValue = (0, record_js_1.defineRecord)('script.StringValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "string" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
52
+ const ScriptSpecialNumberEnum = (0, enum_js_1.defineEnum)('script.SpecialNumber', ["NaN", "-0", "Infinity", "-Infinity"]);
53
+ const ScriptNumberValue = (0, record_js_1.defineRecord)('script.NumberValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "number" } }, { "name": "value", "wire": "value", "required": true, "type": { "union": [{ "primitive": "number" }, { "ref": "script.SpecialNumber" }], "scalar": "number" } }]);
54
+ const ScriptBooleanValue = (0, record_js_1.defineRecord)('script.BooleanValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "boolean" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "boolean" } }]);
55
+ const ScriptBigIntValue = (0, record_js_1.defineRecord)('script.BigIntValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "bigint" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }]);
56
+ const ScriptRealmInfoUnion = (0, union_js_1.defineUnion)('script.RealmInfo', { "by": "type", "variants": [{ "value": "window", "ref": "script.WindowRealmInfo" }, { "value": "dedicated-worker", "ref": "script.DedicatedWorkerRealmInfo" }, { "value": "shared-worker", "ref": "script.SharedWorkerRealmInfo" }, { "value": "service-worker", "ref": "script.ServiceWorkerRealmInfo" }, { "value": "worker", "ref": "script.WorkerRealmInfo" }, { "value": "paint-worklet", "ref": "script.PaintWorkletRealmInfo" }, { "value": "audio-worklet", "ref": "script.AudioWorkletRealmInfo" }, { "value": "worklet", "ref": "script.WorkletRealmInfo" }] }, { "objectOnly": true });
57
+ const ScriptBaseRealmInfo = (0, record_js_1.defineRecord)('script.BaseRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }]);
58
+ const ScriptWindowRealmInfo = (0, record_js_1.defineRecord)('script.WindowRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "window" } }, { "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }, { "name": "sandbox", "wire": "sandbox", "required": false, "type": { "primitive": "string" } }]);
59
+ const ScriptDedicatedWorkerRealmInfo = (0, record_js_1.defineRecord)('script.DedicatedWorkerRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "dedicated-worker" } }, { "name": "owners", "wire": "owners", "required": true, "type": { "list": { "ref": "script.Realm" } } }]);
60
+ const ScriptSharedWorkerRealmInfo = (0, record_js_1.defineRecord)('script.SharedWorkerRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "shared-worker" } }]);
61
+ const ScriptServiceWorkerRealmInfo = (0, record_js_1.defineRecord)('script.ServiceWorkerRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "service-worker" } }]);
62
+ const ScriptWorkerRealmInfo = (0, record_js_1.defineRecord)('script.WorkerRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "worker" } }]);
63
+ const ScriptPaintWorkletRealmInfo = (0, record_js_1.defineRecord)('script.PaintWorkletRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "paint-worklet" } }]);
64
+ const ScriptAudioWorkletRealmInfo = (0, record_js_1.defineRecord)('script.AudioWorkletRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "audio-worklet" } }]);
65
+ const ScriptWorkletRealmInfo = (0, record_js_1.defineRecord)('script.WorkletRealmInfo', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "origin", "wire": "origin", "required": true, "type": { "primitive": "string" } }, { "name": "type", "wire": "type", "required": true, "type": { "const": "worklet" } }]);
66
+ const ScriptRealmTypeEnum = (0, enum_js_1.defineEnum)('script.RealmType', ["window", "dedicated-worker", "shared-worker", "service-worker", "worker", "paint-worklet", "audio-worklet", "worklet"]);
67
+ const ScriptRemoteReferenceUnion = (0, union_js_1.defineUnion)('script.RemoteReference', { "ordered": [{ "ref": "script.SharedReference", "requires": ["sharedId"] }, { "ref": "script.RemoteObjectReference", "requires": ["handle"] }] }, { "objectOnly": true });
68
+ const ScriptSharedReference = (0, record_js_1.defineRecord)('script.SharedReference', [{ "name": "sharedId", "wire": "sharedId", "required": true, "type": { "ref": "script.SharedId" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }], { "extensible": true });
69
+ const ScriptRemoteObjectReference = (0, record_js_1.defineRecord)('script.RemoteObjectReference', [{ "name": "handle", "wire": "handle", "required": true, "type": { "ref": "script.Handle" } }, { "name": "sharedId", "wire": "sharedId", "required": false, "type": { "ref": "script.SharedId" } }], { "extensible": true });
70
+ const ScriptRemoteValueUnion = (0, union_js_1.defineUnion)('script.RemoteValue', { "by": "type", "variants": [{ "value": "undefined", "ref": "script.UndefinedValue" }, { "value": "null", "ref": "script.NullValue" }, { "value": "string", "ref": "script.StringValue" }, { "value": "number", "ref": "script.NumberValue" }, { "value": "boolean", "ref": "script.BooleanValue" }, { "value": "bigint", "ref": "script.BigIntValue" }, { "value": "symbol", "ref": "script.SymbolRemoteValue" }, { "value": "array", "ref": "script.ArrayRemoteValue" }, { "value": "object", "ref": "script.ObjectRemoteValue" }, { "value": "function", "ref": "script.FunctionRemoteValue" }, { "value": "regexp", "ref": "script.RegExpRemoteValue" }, { "value": "date", "ref": "script.DateRemoteValue" }, { "value": "map", "ref": "script.MapRemoteValue" }, { "value": "set", "ref": "script.SetRemoteValue" }, { "value": "weakmap", "ref": "script.WeakMapRemoteValue" }, { "value": "weakset", "ref": "script.WeakSetRemoteValue" }, { "value": "generator", "ref": "script.GeneratorRemoteValue" }, { "value": "error", "ref": "script.ErrorRemoteValue" }, { "value": "proxy", "ref": "script.ProxyRemoteValue" }, { "value": "promise", "ref": "script.PromiseRemoteValue" }, { "value": "typedarray", "ref": "script.TypedArrayRemoteValue" }, { "value": "arraybuffer", "ref": "script.ArrayBufferRemoteValue" }, { "value": "nodelist", "ref": "script.NodeListRemoteValue" }, { "value": "htmlcollection", "ref": "script.HTMLCollectionRemoteValue" }, { "value": "node", "ref": "script.NodeRemoteValue" }, { "value": "window", "ref": "script.WindowProxyRemoteValue" }] }, { "objectOnly": true });
71
+ (0, record_js_1.defineAlias)('script.ListRemoteValue', { "list": { "ref": "script.RemoteValue" } });
72
+ (0, record_js_1.defineAlias)('script.MappingRemoteValue', { "list": { "list": { "union": [{ "ref": "script.RemoteValue" }, { "primitive": "string" }], "scalar": "string" } } });
73
+ const ScriptSymbolRemoteValue = (0, record_js_1.defineRecord)('script.SymbolRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "symbol" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
74
+ const ScriptArrayRemoteValue = (0, record_js_1.defineRecord)('script.ArrayRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "array" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.ListRemoteValue" } }]);
75
+ const ScriptObjectRemoteValue = (0, record_js_1.defineRecord)('script.ObjectRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "object" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.MappingRemoteValue" } }]);
76
+ const ScriptFunctionRemoteValue = (0, record_js_1.defineRecord)('script.FunctionRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "function" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
77
+ const ScriptRegExpRemoteValue = (0, record_js_1.defineRecord)('script.RegExpRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "regexp" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.RegExpValue" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
78
+ const ScriptDateRemoteValue = (0, record_js_1.defineRecord)('script.DateRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "date" } }, { "name": "value", "wire": "value", "required": true, "type": { "primitive": "string" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
79
+ const ScriptMapRemoteValue = (0, record_js_1.defineRecord)('script.MapRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "map" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.MappingRemoteValue" } }]);
80
+ const ScriptSetRemoteValue = (0, record_js_1.defineRecord)('script.SetRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "set" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.ListRemoteValue" } }]);
81
+ const ScriptWeakMapRemoteValue = (0, record_js_1.defineRecord)('script.WeakMapRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "weakmap" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
82
+ const ScriptWeakSetRemoteValue = (0, record_js_1.defineRecord)('script.WeakSetRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "weakset" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
83
+ const ScriptGeneratorRemoteValue = (0, record_js_1.defineRecord)('script.GeneratorRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "generator" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
84
+ const ScriptErrorRemoteValue = (0, record_js_1.defineRecord)('script.ErrorRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "error" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
85
+ const ScriptProxyRemoteValue = (0, record_js_1.defineRecord)('script.ProxyRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "proxy" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
86
+ const ScriptPromiseRemoteValue = (0, record_js_1.defineRecord)('script.PromiseRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "promise" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
87
+ const ScriptTypedArrayRemoteValue = (0, record_js_1.defineRecord)('script.TypedArrayRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "typedarray" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
88
+ const ScriptArrayBufferRemoteValue = (0, record_js_1.defineRecord)('script.ArrayBufferRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "arraybuffer" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
89
+ const ScriptNodeListRemoteValue = (0, record_js_1.defineRecord)('script.NodeListRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "nodelist" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.ListRemoteValue" } }]);
90
+ const ScriptHtmlCollectionRemoteValue = (0, record_js_1.defineRecord)('script.HTMLCollectionRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "htmlcollection" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.ListRemoteValue" } }]);
91
+ const ScriptNodeRemoteValue = (0, record_js_1.defineRecord)('script.NodeRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "node" } }, { "name": "sharedId", "wire": "sharedId", "required": false, "type": { "ref": "script.SharedId" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }, { "name": "value", "wire": "value", "required": false, "type": { "ref": "script.NodeProperties" } }]);
92
+ const ScriptNodeProperties = (0, record_js_1.defineRecord)('script.NodeProperties', [{ "name": "nodeType", "wire": "nodeType", "required": true, "type": { "ref": "js-uint" } }, { "name": "childNodeCount", "wire": "childNodeCount", "required": true, "type": { "ref": "js-uint" } }, { "name": "attributes", "wire": "attributes", "required": false, "type": { "ref": "script.NodePropertiesAttributes" } }, { "name": "children", "wire": "children", "required": false, "type": { "list": { "ref": "script.NodeRemoteValue" } } }, { "name": "localName", "wire": "localName", "required": false, "type": { "primitive": "string" } }, { "name": "mode", "wire": "mode", "required": false, "type": { "ref": "script.NodePropertiesMode" } }, { "name": "namespaceURI", "wire": "namespaceURI", "required": false, "type": { "primitive": "string" } }, { "name": "nodeValue", "wire": "nodeValue", "required": false, "type": { "primitive": "string" } }, { "name": "shadowRoot", "wire": "shadowRoot", "required": false, "type": { "ref": "script.NodeRemoteValue", "nullable": true } }]);
93
+ const ScriptWindowProxyRemoteValue = (0, record_js_1.defineRecord)('script.WindowProxyRemoteValue', [{ "name": "type", "wire": "type", "required": true, "type": { "const": "window" } }, { "name": "value", "wire": "value", "required": true, "type": { "ref": "script.WindowProxyProperties" } }, { "name": "handle", "wire": "handle", "required": false, "type": { "ref": "script.Handle" } }, { "name": "internalId", "wire": "internalId", "required": false, "type": { "ref": "script.InternalId" } }]);
94
+ const ScriptWindowProxyProperties = (0, record_js_1.defineRecord)('script.WindowProxyProperties', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }]);
95
+ const ScriptResultOwnershipEnum = (0, enum_js_1.defineEnum)('script.ResultOwnership', ["root", "none"]);
96
+ const ScriptSerializationOptions = (0, record_js_1.defineRecord)('script.SerializationOptions', [{ "name": "maxDomDepth", "wire": "maxDomDepth", "required": false, "type": { "ref": "js-uint", "nullable": true } }, { "name": "maxObjectDepth", "wire": "maxObjectDepth", "required": false, "type": { "ref": "js-uint", "nullable": true } }, { "name": "includeShadowTree", "wire": "includeShadowTree", "required": false, "type": { "ref": "script.SerializationOptionsIncludeShadowTree" } }]);
97
+ (0, record_js_1.defineAlias)('script.SharedId', { "primitive": "string" });
98
+ const ScriptStackFrame = (0, record_js_1.defineRecord)('script.StackFrame', [{ "name": "columnNumber", "wire": "columnNumber", "required": true, "type": { "ref": "js-uint" } }, { "name": "functionName", "wire": "functionName", "required": true, "type": { "primitive": "string" } }, { "name": "lineNumber", "wire": "lineNumber", "required": true, "type": { "ref": "js-uint" } }, { "name": "url", "wire": "url", "required": true, "type": { "primitive": "string" } }]);
99
+ const ScriptStackTrace = (0, record_js_1.defineRecord)('script.StackTrace', [{ "name": "callFrames", "wire": "callFrames", "required": true, "type": { "list": { "ref": "script.StackFrame" } } }]);
100
+ const ScriptSource = (0, record_js_1.defineRecord)('script.Source', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }, { "name": "context", "wire": "context", "required": false, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "userContext", "wire": "userContext", "required": false, "type": { "ref": "browser.UserContext" } }]);
101
+ const ScriptRealmTarget = (0, record_js_1.defineRecord)('script.RealmTarget', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }]);
102
+ const ScriptContextTarget = (0, record_js_1.defineRecord)('script.ContextTarget', [{ "name": "context", "wire": "context", "required": true, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "sandbox", "wire": "sandbox", "required": false, "type": { "primitive": "string" } }]);
103
+ const ScriptTargetUnion = (0, union_js_1.defineUnion)('script.Target', { "ordered": [{ "ref": "script.ContextTarget", "requires": ["context"] }, { "ref": "script.RealmTarget", "requires": ["realm"] }] }, { "objectOnly": true });
104
+ const ScriptAddPreloadScript = (0, record_js_1.defineRecord)('script.AddPreloadScript', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.addPreloadScript" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.AddPreloadScriptParameters" } }]);
105
+ const ScriptAddPreloadScriptParameters = (0, record_js_1.defineRecord)('script.AddPreloadScriptParameters', [{ "name": "functionDeclaration", "wire": "functionDeclaration", "required": true, "type": { "primitive": "string" } }, { "name": "arguments", "wire": "arguments", "required": false, "type": { "list": { "ref": "script.ChannelValue" } } }, { "name": "contexts", "wire": "contexts", "required": false, "type": { "list": { "ref": "browsingContext.BrowsingContext" } } }, { "name": "userContexts", "wire": "userContexts", "required": false, "type": { "list": { "ref": "browser.UserContext" } } }, { "name": "sandbox", "wire": "sandbox", "required": false, "type": { "primitive": "string" } }]);
106
+ const ScriptAddPreloadScriptResult = (0, record_js_1.defineRecord)('script.AddPreloadScriptResult', [{ "name": "script", "wire": "script", "required": true, "type": { "ref": "script.PreloadScript" } }]);
107
+ const ScriptDisown = (0, record_js_1.defineRecord)('script.Disown', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.disown" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.DisownParameters" } }]);
108
+ const ScriptDisownParameters = (0, record_js_1.defineRecord)('script.DisownParameters', [{ "name": "handles", "wire": "handles", "required": true, "type": { "list": { "ref": "script.Handle" } } }, { "name": "target", "wire": "target", "required": true, "type": { "ref": "script.Target" } }]);
109
+ (0, record_js_1.defineAlias)('script.DisownResult', { "ref": "EmptyResult" });
110
+ const ScriptCallFunction = (0, record_js_1.defineRecord)('script.CallFunction', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.callFunction" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.CallFunctionParameters" } }]);
111
+ const ScriptCallFunctionParameters = (0, record_js_1.defineRecord)('script.CallFunctionParameters', [{ "name": "functionDeclaration", "wire": "functionDeclaration", "required": true, "type": { "primitive": "string" } }, { "name": "awaitPromise", "wire": "awaitPromise", "required": true, "type": { "primitive": "boolean" } }, { "name": "target", "wire": "target", "required": true, "type": { "ref": "script.Target" } }, { "name": "arguments", "wire": "arguments", "required": false, "type": { "list": { "ref": "script.LocalValue" } } }, { "name": "resultOwnership", "wire": "resultOwnership", "required": false, "type": { "ref": "script.ResultOwnership" } }, { "name": "serializationOptions", "wire": "serializationOptions", "required": false, "type": { "ref": "script.SerializationOptions" } }, { "name": "this", "wire": "this", "required": false, "type": { "ref": "script.LocalValue" } }, { "name": "userActivation", "wire": "userActivation", "required": false, "type": { "primitive": "boolean" } }]);
112
+ (0, record_js_1.defineAlias)('script.CallFunctionResult', { "ref": "script.EvaluateResult" });
113
+ const ScriptEvaluate = (0, record_js_1.defineRecord)('script.Evaluate', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.evaluate" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.EvaluateParameters" } }]);
114
+ const ScriptEvaluateParameters = (0, record_js_1.defineRecord)('script.EvaluateParameters', [{ "name": "expression", "wire": "expression", "required": true, "type": { "primitive": "string" } }, { "name": "target", "wire": "target", "required": true, "type": { "ref": "script.Target" } }, { "name": "awaitPromise", "wire": "awaitPromise", "required": true, "type": { "primitive": "boolean" } }, { "name": "resultOwnership", "wire": "resultOwnership", "required": false, "type": { "ref": "script.ResultOwnership" } }, { "name": "serializationOptions", "wire": "serializationOptions", "required": false, "type": { "ref": "script.SerializationOptions" } }, { "name": "userActivation", "wire": "userActivation", "required": false, "type": { "primitive": "boolean" } }]);
115
+ const ScriptGetRealms = (0, record_js_1.defineRecord)('script.GetRealms', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.getRealms" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.GetRealmsParameters" } }]);
116
+ const ScriptGetRealmsParameters = (0, record_js_1.defineRecord)('script.GetRealmsParameters', [{ "name": "context", "wire": "context", "required": false, "type": { "ref": "browsingContext.BrowsingContext" } }, { "name": "type", "wire": "type", "required": false, "type": { "ref": "script.RealmType" } }]);
117
+ const ScriptGetRealmsResult = (0, record_js_1.defineRecord)('script.GetRealmsResult', [{ "name": "realms", "wire": "realms", "required": true, "type": { "list": { "ref": "script.RealmInfo" } } }]);
118
+ const ScriptRemovePreloadScript = (0, record_js_1.defineRecord)('script.RemovePreloadScript', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.removePreloadScript" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.RemovePreloadScriptParameters" } }]);
119
+ const ScriptRemovePreloadScriptParameters = (0, record_js_1.defineRecord)('script.RemovePreloadScriptParameters', [{ "name": "script", "wire": "script", "required": true, "type": { "ref": "script.PreloadScript" } }]);
120
+ (0, record_js_1.defineAlias)('script.RemovePreloadScriptResult', { "ref": "EmptyResult" });
121
+ const ScriptMessage = (0, record_js_1.defineRecord)('script.Message', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.message" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.MessageParameters" } }]);
122
+ const ScriptMessageParameters = (0, record_js_1.defineRecord)('script.MessageParameters', [{ "name": "channel", "wire": "channel", "required": true, "type": { "ref": "script.Channel" } }, { "name": "data", "wire": "data", "required": true, "type": { "ref": "script.RemoteValue" } }, { "name": "source", "wire": "source", "required": true, "type": { "ref": "script.Source" } }]);
123
+ const ScriptRealmCreated = (0, record_js_1.defineRecord)('script.RealmCreated', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.realmCreated" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.RealmInfo" } }]);
124
+ const ScriptRealmDestroyed = (0, record_js_1.defineRecord)('script.RealmDestroyed', [{ "name": "method", "wire": "method", "required": true, "type": { "const": "script.realmDestroyed" } }, { "name": "params", "wire": "params", "required": true, "type": { "ref": "script.RealmDestroyedParameters" } }]);
125
+ const ScriptRealmDestroyedParameters = (0, record_js_1.defineRecord)('script.RealmDestroyedParameters', [{ "name": "realm", "wire": "realm", "required": true, "type": { "ref": "script.Realm" } }]);
126
+ const ScriptNodePropertiesModeEnum = (0, enum_js_1.defineEnum)('script.NodePropertiesMode', ["open", "closed"]);
127
+ const ScriptSerializationOptionsIncludeShadowTreeEnum = (0, enum_js_1.defineEnum)('script.SerializationOptionsIncludeShadowTree', ["none", "open", "all"]);
128
+ const ScriptNodePropertiesAttributes = (0, record_js_1.defineRecord)('script.NodePropertiesAttributes', []);
26
129
  // --- Implementation ---
27
- class Script {
28
- constructor(bidi) {
29
- this.bidi = bidi;
30
- }
130
+ /**
131
+ * This is an unsupported API. No compatibility guarantees are provided.
132
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
133
+ * evolves, this API will change or be removed without prior notice.
134
+ */
135
+ class Script extends domain_js_1.Domain {
31
136
  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 Script(bidi);
38
- }
137
+ return new Script(await domain_js_1.Domain.connect(driver), domain_js_1.DOMAIN_TOKEN);
138
+ }
139
+ /**
140
+ * @param {ScriptAddPreloadScriptParameters} params
141
+ * @param {string} params.functionDeclaration
142
+ * @param {Array<ScriptChannelValue>} [params.arguments]
143
+ * @param {Array<BrowsingContextBrowsingContext>} [params.contexts]
144
+ * @param {Array<BrowserUserContext>} [params.userContexts]
145
+ * @param {string} [params.sandbox]
146
+ * @returns {Promise<ScriptAddPreloadScriptResult>}
147
+ * @see https://w3c.github.io/webdriver-bidi/#command-script-addPreloadScript
148
+ */
39
149
  async addPreloadScript(params) {
40
- const response = await this.bidi.send({
41
- method: 'script.addPreloadScript',
42
- params: params,
43
- });
44
- if (response['type'] === 'error') {
45
- throw new Error(`${response['error']}: ${response['message']}`);
46
- }
47
- return response.result;
48
- }
150
+ const validatedParams = new ScriptAddPreloadScriptParameters(params);
151
+ const result = await this.send('script.addPreloadScript', validatedParams);
152
+ return ScriptAddPreloadScriptResult.fromWire(result);
153
+ }
154
+ /**
155
+ * @param {ScriptCallFunctionParameters} params
156
+ * @param {string} params.functionDeclaration
157
+ * @param {boolean} params.awaitPromise
158
+ * @param {ScriptTarget} params.target
159
+ * @param {Array<ScriptLocalValue>} [params.arguments]
160
+ * @param {ScriptResultOwnership} [params.resultOwnership]
161
+ * @param {ScriptSerializationOptions} [params.serializationOptions]
162
+ * @param {ScriptLocalValue} [params.this]
163
+ * @param {boolean} [params.userActivation]
164
+ * @returns {Promise<ScriptCallFunctionResult>}
165
+ * @see https://w3c.github.io/webdriver-bidi/#command-script-callFunction
166
+ */
49
167
  async callFunction(params) {
50
- const response = await this.bidi.send({
51
- method: 'script.callFunction',
52
- params: params,
53
- });
54
- if (response['type'] === 'error') {
55
- throw new Error(`${response['error']}: ${response['message']}`);
56
- }
57
- return response.result;
58
- }
168
+ const validatedParams = new ScriptCallFunctionParameters(params);
169
+ const result = await this.send('script.callFunction', validatedParams);
170
+ return ScriptEvaluateResultUnion.fromWire(result);
171
+ }
172
+ /**
173
+ * @param {ScriptDisownParameters} params
174
+ * @param {Array<ScriptHandle>} params.handles
175
+ * @param {ScriptTarget} params.target
176
+ * @returns {Promise<void>}
177
+ * @see https://w3c.github.io/webdriver-bidi/#command-script-disown
178
+ */
59
179
  async disown(params) {
60
- const response = await this.bidi.send({
61
- method: 'script.disown',
62
- params: params,
63
- });
64
- if (response['type'] === 'error') {
65
- throw new Error(`${response['error']}: ${response['message']}`);
66
- }
67
- }
180
+ const validatedParams = new ScriptDisownParameters(params);
181
+ await this.send('script.disown', validatedParams);
182
+ }
183
+ /**
184
+ * @param {ScriptEvaluateParameters} params
185
+ * @param {string} params.expression
186
+ * @param {ScriptTarget} params.target
187
+ * @param {boolean} params.awaitPromise
188
+ * @param {ScriptResultOwnership} [params.resultOwnership]
189
+ * @param {ScriptSerializationOptions} [params.serializationOptions]
190
+ * @param {boolean} [params.userActivation]
191
+ * @returns {Promise<ScriptEvaluateResult>}
192
+ * @see https://w3c.github.io/webdriver-bidi/#command-script-evaluate
193
+ */
68
194
  async evaluate(params) {
69
- const response = await this.bidi.send({
70
- method: 'script.evaluate',
71
- params: params,
72
- });
73
- if (response['type'] === 'error') {
74
- throw new Error(`${response['error']}: ${response['message']}`);
75
- }
76
- return response.result;
77
- }
195
+ const validatedParams = new ScriptEvaluateParameters(params);
196
+ const result = await this.send('script.evaluate', validatedParams);
197
+ return ScriptEvaluateResultUnion.fromWire(result);
198
+ }
199
+ /**
200
+ * @param {ScriptGetRealmsParameters} params
201
+ * @param {BrowsingContextBrowsingContext} [params.context]
202
+ * @param {ScriptRealmType} [params.type]
203
+ * @returns {Promise<ScriptGetRealmsResult>}
204
+ * @see https://w3c.github.io/webdriver-bidi/#command-script-getRealms
205
+ */
78
206
  async getRealms(params) {
79
- const response = await this.bidi.send({
80
- method: 'script.getRealms',
81
- params: params,
82
- });
83
- if (response['type'] === 'error') {
84
- throw new Error(`${response['error']}: ${response['message']}`);
85
- }
86
- return response.result;
87
- }
207
+ const validatedParams = new ScriptGetRealmsParameters(params);
208
+ const result = await this.send('script.getRealms', validatedParams);
209
+ return ScriptGetRealmsResult.fromWire(result);
210
+ }
211
+ /**
212
+ * @param {ScriptRemovePreloadScriptParameters} params
213
+ * @param {ScriptPreloadScript} params.script
214
+ * @returns {Promise<void>}
215
+ * @see https://w3c.github.io/webdriver-bidi/#command-script-removePreloadScript
216
+ */
88
217
  async removePreloadScript(params) {
89
- const response = await this.bidi.send({
90
- method: 'script.removePreloadScript',
91
- params: params,
92
- });
93
- if (response['type'] === 'error') {
94
- throw new Error(`${response['error']}: ${response['message']}`);
95
- }
96
- }
97
- async onMessage(callback) {
98
- await this.bidi.subscribe('script.message');
99
- this.bidi.on('script.message', (params) => {
100
- callback(params);
101
- });
102
- }
103
- async onRealmCreated(callback) {
104
- await this.bidi.subscribe('script.realmCreated');
105
- this.bidi.on('script.realmCreated', (params) => {
106
- callback(params);
107
- });
108
- }
109
- async onRealmDestroyed(callback) {
110
- await this.bidi.subscribe('script.realmDestroyed');
111
- this.bidi.on('script.realmDestroyed', (params) => {
112
- callback(params);
113
- });
114
- }
115
- async getAllRealms() {
116
- return this.getRealms({});
117
- }
118
- async getRealmsByType(type) {
119
- return this.getRealms({ type });
120
- }
121
- async getRealmsInBrowsingContext(context) {
122
- return this.getRealms({ context });
123
- }
124
- async getRealmsInBrowsingContextByType(context, type) {
125
- return this.getRealms({ context, type });
126
- }
127
- async callFunctionInRealm(realmId, functionDeclaration, awaitPromise, args, resultOwnership, serializationOptions, userActivation) {
128
- return this.callFunction({ functionDeclaration, awaitPromise, target: { realm: realmId }, arguments: args, resultOwnership, serializationOptions, userActivation });
129
- }
130
- async callFunctionInBrowsingContext(browsingContextId, functionDeclaration, awaitPromise, args, sandbox, resultOwnership, serializationOptions, userActivation) {
131
- return this.callFunction({ functionDeclaration, awaitPromise, target: { context: browsingContextId, sandbox }, arguments: args, resultOwnership, serializationOptions, userActivation });
132
- }
133
- async evaluateFunctionInRealm(realmId, expression, awaitPromise, resultOwnership, serializationOptions, userActivation) {
134
- return this.evaluate({ expression, awaitPromise, target: { realm: realmId }, resultOwnership, serializationOptions, userActivation });
135
- }
136
- async evaluateFunctionInBrowsingContext(browsingContextId, expression, awaitPromise, sandbox, resultOwnership, serializationOptions, userActivation) {
137
- return this.evaluate({ expression, awaitPromise, target: { context: browsingContextId, sandbox }, resultOwnership, serializationOptions, userActivation });
138
- }
139
- async disownRealmScript(realmId, handles) {
140
- await this.disown({ handles, target: { realm: realmId } });
141
- }
142
- async disownBrowsingContextScript(browsingContextId, handles, sandbox) {
143
- await this.disown({ handles, target: { context: browsingContextId, sandbox } });
218
+ const validatedParams = new ScriptRemovePreloadScriptParameters(params);
219
+ await this.send('script.removePreloadScript', validatedParams);
144
220
  }
145
221
  }
146
222
  exports.Script = Script;
223
+ /** @see https://w3c.github.io/webdriver-bidi/#event-script-message */
224
+ Script.MESSAGE = (0, domain_js_1.event)('script.message', ScriptMessageParameters);
225
+ /** @see https://w3c.github.io/webdriver-bidi/#event-script-realmCreated */
226
+ Script.REALM_CREATED = (0, domain_js_1.event)('script.realmCreated', ScriptRealmInfoUnion);
227
+ /** @see https://w3c.github.io/webdriver-bidi/#event-script-realmDestroyed */
228
+ Script.REALM_DESTROYED = (0, domain_js_1.event)('script.realmDestroyed', ScriptRealmDestroyedParameters);
229
+ Script.SpecialNumber = Object.freeze({ NA_N: "NaN", _0: "-0", INFINITY: "Infinity", _INFINITY: "-Infinity" });
230
+ Script.RealmType = Object.freeze({ WINDOW: "window", DEDICATED_WORKER: "dedicated-worker", SHARED_WORKER: "shared-worker", SERVICE_WORKER: "service-worker", WORKER: "worker", PAINT_WORKLET: "paint-worklet", AUDIO_WORKLET: "audio-worklet", WORKLET: "worklet" });
231
+ Script.ResultOwnership = Object.freeze({ ROOT: "root", NONE: "none" });
232
+ Script.NodePropertiesMode = Object.freeze({ OPEN: "open", CLOSED: "closed" });
233
+ Script.SerializationOptionsIncludeShadowTree = Object.freeze({ NONE: "none", OPEN: "open", ALL: "all" });
@@ -1,44 +1,48 @@
1
1
  import type { BrowserUserContext } from './browser.js';
2
+ import './browser.js';
2
3
  import type { BrowsingContextBrowsingContext } from './browsing_context.js';
3
- import type { EmptyParams, EmptyResult, Extensible } from './common.js';
4
- export type SessionCommand = SessionEnd | SessionNew | SessionStatus | SessionSubscribe | SessionUnsubscribe;
5
- export type SessionResult = SessionEndResult | SessionNewResult | SessionStatusResult | SessionSubscribeResult | SessionUnsubscribeResult;
4
+ import './browsing_context.js';
5
+ import type { EmptyParams, EmptyResult } from './common.js';
6
+ import './common.js';
7
+ import { Domain } from '../domain.js';
6
8
  export interface SessionCapabilitiesRequest {
7
9
  alwaysMatch?: SessionCapabilityRequest;
8
- firstMatch?: SessionCapabilityRequest[];
10
+ firstMatch?: Array<SessionCapabilityRequest>;
9
11
  }
10
- export type SessionCapabilityRequest = Extensible & {
12
+ export interface SessionCapabilityRequest {
11
13
  acceptInsecureCerts?: boolean;
12
14
  browserName?: string;
13
15
  browserVersion?: string;
14
16
  platformName?: string;
15
17
  proxy?: SessionProxyConfiguration;
16
18
  unhandledPromptBehavior?: SessionUserPromptHandler;
17
- };
19
+ }
18
20
  export type SessionProxyConfiguration = SessionAutodetectProxyConfiguration | SessionDirectProxyConfiguration | SessionManualProxyConfiguration | SessionPacProxyConfiguration | SessionSystemProxyConfiguration;
19
- export type SessionAutodetectProxyConfiguration = Extensible & {
21
+ export interface SessionAutodetectProxyConfiguration {
20
22
  proxyType: "autodetect";
21
- };
22
- export type SessionDirectProxyConfiguration = Extensible & {
23
+ }
24
+ export interface SessionDirectProxyConfiguration {
23
25
  proxyType: "direct";
24
- };
25
- export type SessionManualProxyConfiguration = SessionSocksProxyConfiguration & Extensible & {
26
+ }
27
+ export interface SessionManualProxyConfiguration {
26
28
  proxyType: "manual";
27
29
  httpProxy?: string;
28
30
  sslProxy?: string;
29
- noProxy?: string[];
30
- };
31
+ socksProxy: string;
32
+ socksVersion: number;
33
+ noProxy?: Array<string>;
34
+ }
31
35
  export interface SessionSocksProxyConfiguration {
32
36
  socksProxy: string;
33
37
  socksVersion: number;
34
38
  }
35
- export type SessionPacProxyConfiguration = Extensible & {
39
+ export interface SessionPacProxyConfiguration {
36
40
  proxyType: "pac";
37
41
  proxyAutoconfigUrl: string;
38
- };
39
- export type SessionSystemProxyConfiguration = Extensible & {
42
+ }
43
+ export interface SessionSystemProxyConfiguration {
40
44
  proxyType: "system";
41
- };
45
+ }
42
46
  export interface SessionUserPromptHandler {
43
47
  alert?: SessionUserPromptHandlerType;
44
48
  beforeUnload?: SessionUserPromptHandlerType;
@@ -50,15 +54,15 @@ export interface SessionUserPromptHandler {
50
54
  export type SessionUserPromptHandlerType = "accept" | "dismiss" | "ignore";
51
55
  export type SessionSubscription = string;
52
56
  export interface SessionSubscribeParameters {
53
- events: string[];
54
- contexts?: BrowsingContextBrowsingContext[];
55
- userContexts?: BrowserUserContext[];
57
+ events: Array<string>;
58
+ contexts?: Array<BrowsingContextBrowsingContext>;
59
+ userContexts?: Array<BrowserUserContext>;
56
60
  }
57
61
  export interface SessionUnsubscribeByIdRequest {
58
- subscriptions: SessionSubscription[];
62
+ subscriptions: Array<SessionSubscription>;
59
63
  }
60
64
  export interface SessionUnsubscribeByAttributesRequest {
61
- events: string[];
65
+ events: Array<string>;
62
66
  }
63
67
  export interface SessionStatus {
64
68
  method: "session.status";
@@ -77,17 +81,7 @@ export interface SessionNewParameters {
77
81
  }
78
82
  export interface SessionNewResult {
79
83
  sessionId: string;
80
- capabilities: {
81
- acceptInsecureCerts: boolean;
82
- browserName: string;
83
- browserVersion: string;
84
- platformName: string;
85
- setWindowRect: boolean;
86
- userAgent: string;
87
- proxy?: SessionProxyConfiguration;
88
- unhandledPromptBehavior?: SessionUserPromptHandler;
89
- webSocketUrl?: string;
90
- };
84
+ capabilities: SessionNewResultCapabilities;
91
85
  }
92
86
  export interface SessionEnd {
93
87
  method: "session.end";
@@ -107,13 +101,59 @@ export interface SessionUnsubscribe {
107
101
  }
108
102
  export type SessionUnsubscribeParameters = SessionUnsubscribeByAttributesRequest | SessionUnsubscribeByIdRequest;
109
103
  export type SessionUnsubscribeResult = EmptyResult;
110
- export declare class Session {
111
- private readonly bidi;
112
- private constructor();
104
+ export interface SessionNewResultCapabilities {
105
+ acceptInsecureCerts: boolean;
106
+ browserName: string;
107
+ browserVersion: string;
108
+ platformName: string;
109
+ setWindowRect: boolean;
110
+ userAgent: string;
111
+ proxy?: SessionProxyConfiguration;
112
+ unhandledPromptBehavior?: SessionUserPromptHandler;
113
+ webSocketUrl?: string;
114
+ }
115
+ /**
116
+ * This is an unsupported API. No compatibility guarantees are provided.
117
+ * It tracks the W3C WebDriver BiDi specification directly. As the specification
118
+ * evolves, this API will change or be removed without prior notice.
119
+ */
120
+ export declare class Session extends Domain {
121
+ static readonly UserPromptHandlerType: Readonly<{
122
+ readonly ACCEPT: "accept";
123
+ readonly DISMISS: "dismiss";
124
+ readonly IGNORE: "ignore";
125
+ }>;
113
126
  static create(driver: unknown): Promise<Session>;
127
+ /**
128
+ * @returns {Promise<void>}
129
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-end
130
+ */
114
131
  end(): Promise<void>;
132
+ /**
133
+ * @param {SessionNewParameters} params
134
+ * @param {SessionCapabilitiesRequest} params.capabilities
135
+ * @returns {Promise<SessionNewResult>}
136
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-new
137
+ */
115
138
  new(params: SessionNewParameters): Promise<SessionNewResult>;
139
+ /**
140
+ * @returns {Promise<SessionStatusResult>}
141
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-status
142
+ */
116
143
  status(): Promise<SessionStatusResult>;
144
+ /**
145
+ * @param {SessionSubscribeParameters} params
146
+ * @param {Array<string>} params.events
147
+ * @param {Array<BrowsingContextBrowsingContext>} [params.contexts]
148
+ * @param {Array<BrowserUserContext>} [params.userContexts]
149
+ * @returns {Promise<SessionSubscribeResult>}
150
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-subscribe
151
+ */
117
152
  subscribe(params: SessionSubscribeParameters): Promise<SessionSubscribeResult>;
153
+ /**
154
+ * @param {SessionUnsubscribeParameters} params
155
+ * @returns {Promise<void>}
156
+ * @see https://w3c.github.io/webdriver-bidi/#command-session-unsubscribe
157
+ */
118
158
  unsubscribe(params: SessionUnsubscribeParameters): Promise<void>;
119
159
  }