lib/selenium/webdriver/bidi/protocol/script.rb



# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# This file is automatically generated. DO NOT EDIT!
# Regenerate with: bazel run //rb/lib/selenium/webdriver:bidi-generate

module Selenium
  module WebDriver
    class BiDi
      module Protocol
        # @api private
        # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
        class Script < Domain
          EVENTS = {
            message: 'script.message',
            realm_created: 'script.realmCreated',
            realm_destroyed: 'script.realmDestroyed'
          }.freeze

          SPECIAL_NUMBER = {
            na_n: 'NaN',
            neg0: '-0',
            infinity: 'Infinity',
            neg_infinity: '-Infinity'
          }.freeze

          REALM_TYPE = {
            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'
          }.freeze

          RESULT_OWNERSHIP = {
            root: 'root',
            none: 'none'
          }.freeze

          NODE_PROPERTIES_MODE = {
            open: 'open',
            closed: 'closed'
          }.freeze

          SERIALIZATION_OPTIONS_INCLUDE_SHADOW_TREE = {
            none: 'none',
            open: 'open',
            all: 'all'
          }.freeze

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ChannelValue = Serialization::Record.define(
            type: {fixed: 'channel'},
            value: {wire_key: 'value', ref: 'Script::ChannelProperties'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ChannelProperties = Serialization::Record.define(
            channel: 'channel',
            serialization_options: {
              wire_key: 'serializationOptions',
              required: false,
              ref: 'Script::SerializationOptions'
            },
            ownership: {wire_key: 'ownership', required: false, enum: 'Script::RESULT_OWNERSHIP'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class EvaluateResult < Serialization::Union
            discriminator 'type', {success: 'success', exception: 'exception'}
            variants(
              success: 'Script::EvaluateResultSuccess',
              exception: 'Script::EvaluateResultException'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          EvaluateResultSuccess = Serialization::Record.define(
            type: {fixed: 'success'},
            result: {wire_key: 'result', ref: 'Script::RemoteValue'},
            realm: 'realm'
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          EvaluateResultException = Serialization::Record.define(
            type: {fixed: 'exception'},
            exception_details: {wire_key: 'exceptionDetails', ref: 'Script::ExceptionDetails'},
            realm: 'realm'
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ExceptionDetails = Serialization::Record.define(
            column_number: 'columnNumber',
            exception: {wire_key: 'exception', ref: 'Script::RemoteValue'},
            line_number: 'lineNumber',
            stack_trace: {wire_key: 'stackTrace', ref: 'Script::StackTrace'},
            text: {wire_key: 'text', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class LocalValue < Serialization::Union
            discriminator 'type', {
              undefined: 'undefined',
              null: 'null',
              string: 'string',
              number: 'number',
              boolean: 'boolean',
              bigint: 'bigint',
              channel: 'channel',
              array: 'array',
              date: 'date',
              map: 'map',
              object: 'object',
              regexp: 'regexp',
              set: 'set'
            }
            variants(
              undefined: 'Script::UndefinedValue',
              null: 'Script::NullValue',
              string: 'Script::StringValue',
              number: 'Script::NumberValue',
              boolean: 'Script::BooleanValue',
              bigint: 'Script::BigIntValue',
              channel: 'Script::ChannelValue',
              array: 'Script::ArrayLocalValue',
              date: 'Script::DateLocalValue',
              map: 'Script::MapLocalValue',
              object: 'Script::ObjectLocalValue',
              regexp: 'Script::RegExpLocalValue',
              set: 'Script::SetLocalValue'
            )
            fallback 'Script::RemoteReference'
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ArrayLocalValue = Serialization::Record.define(
            type: {fixed: 'array'},
            value: {wire_key: 'value', ref: 'Script::LocalValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          DateLocalValue = Serialization::Record.define(
            type: {fixed: 'date'},
            value: {wire_key: 'value', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          MapLocalValue = Serialization::Record.define(
            type: {fixed: 'map'},
            value: {wire_key: 'value', ref: 'Script::LocalValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ObjectLocalValue = Serialization::Record.define(
            type: {fixed: 'object'},
            value: {wire_key: 'value', ref: 'Script::LocalValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RegExpValue = Serialization::Record.define(
            pattern: {wire_key: 'pattern', primitive: 'string'},
            flags: {wire_key: 'flags', required: false, primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RegExpLocalValue = Serialization::Record.define(
            type: {fixed: 'regexp'},
            value: {wire_key: 'value', ref: 'Script::RegExpValue'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SetLocalValue = Serialization::Record.define(
            type: {fixed: 'set'},
            value: {wire_key: 'value', ref: 'Script::LocalValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class PrimitiveProtocolValue < Serialization::Union
            discriminator 'type', {
              undefined: 'undefined',
              null: 'null',
              string: 'string',
              number: 'number',
              boolean: 'boolean',
              bigint: 'bigint'
            }
            variants(
              undefined: 'Script::UndefinedValue',
              null: 'Script::NullValue',
              string: 'Script::StringValue',
              number: 'Script::NumberValue',
              boolean: 'Script::BooleanValue',
              bigint: 'Script::BigIntValue'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          UndefinedValue = Serialization::Record.define(type: {fixed: 'undefined'})

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          NullValue = Serialization::Record.define(type: {fixed: 'null'})

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          StringValue = Serialization::Record.define(
            type: {fixed: 'string'},
            value: {wire_key: 'value', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          NumberValue = Serialization::Record.define(type: {fixed: 'number'}, value: 'value')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          BooleanValue = Serialization::Record.define(
            type: {fixed: 'boolean'},
            value: {wire_key: 'value', primitive: 'boolean'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          BigIntValue = Serialization::Record.define(
            type: {fixed: 'bigint'},
            value: {wire_key: 'value', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class RealmInfo < Serialization::Union
            discriminator 'type', {
              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'
            }
            variants(
              window: 'Script::WindowRealmInfo',
              dedicated_worker: 'Script::DedicatedWorkerRealmInfo',
              shared_worker: 'Script::SharedWorkerRealmInfo',
              service_worker: 'Script::ServiceWorkerRealmInfo',
              worker: 'Script::WorkerRealmInfo',
              paint_worklet: 'Script::PaintWorkletRealmInfo',
              audio_worklet: 'Script::AudioWorkletRealmInfo',
              worklet: 'Script::WorkletRealmInfo'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          BaseRealmInfo = Serialization::Record.define(
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WindowRealmInfo = Serialization::Record.define(
            type: {fixed: 'window'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'},
            context: 'context',
            user_context: {wire_key: 'userContext', required: false},
            sandbox: {wire_key: 'sandbox', required: false, primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          DedicatedWorkerRealmInfo = Serialization::Record.define(
            type: {fixed: 'dedicated-worker'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'},
            owners: {wire_key: 'owners', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SharedWorkerRealmInfo = Serialization::Record.define(
            type: {fixed: 'shared-worker'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ServiceWorkerRealmInfo = Serialization::Record.define(
            type: {fixed: 'service-worker'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WorkerRealmInfo = Serialization::Record.define(
            type: {fixed: 'worker'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PaintWorkletRealmInfo = Serialization::Record.define(
            type: {fixed: 'paint-worklet'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          AudioWorkletRealmInfo = Serialization::Record.define(
            type: {fixed: 'audio-worklet'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WorkletRealmInfo = Serialization::Record.define(
            type: {fixed: 'worklet'},
            realm: 'realm',
            origin: {wire_key: 'origin', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class RemoteReference < Serialization::Union
            presence(
              'Script::SharedReference' => ['sharedId'],
              'Script::RemoteObjectReference' => ['handle']
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SharedReference = Serialization::Record.define(
            shared_id: 'sharedId',
            handle: {wire_key: 'handle', required: false},
            extensible: true
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RemoteObjectReference = Serialization::Record.define(
            handle: 'handle',
            shared_id: {wire_key: 'sharedId', required: false},
            extensible: true
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class RemoteValue < Serialization::Union
            discriminator 'type', {
              undefined: 'undefined',
              null: 'null',
              string: 'string',
              number: 'number',
              boolean: 'boolean',
              bigint: 'bigint',
              symbol: 'symbol',
              array: 'array',
              object: 'object',
              function: 'function',
              regexp: 'regexp',
              date: 'date',
              map: 'map',
              set: 'set',
              weakmap: 'weakmap',
              weakset: 'weakset',
              generator: 'generator',
              error: 'error',
              proxy: 'proxy',
              promise: 'promise',
              typedarray: 'typedarray',
              arraybuffer: 'arraybuffer',
              nodelist: 'nodelist',
              htmlcollection: 'htmlcollection',
              node: 'node',
              window: 'window'
            }
            variants(
              undefined: 'Script::UndefinedValue',
              null: 'Script::NullValue',
              string: 'Script::StringValue',
              number: 'Script::NumberValue',
              boolean: 'Script::BooleanValue',
              bigint: 'Script::BigIntValue',
              symbol: 'Script::SymbolRemoteValue',
              array: 'Script::ArrayRemoteValue',
              object: 'Script::ObjectRemoteValue',
              function: 'Script::FunctionRemoteValue',
              regexp: 'Script::RegExpRemoteValue',
              date: 'Script::DateRemoteValue',
              map: 'Script::MapRemoteValue',
              set: 'Script::SetRemoteValue',
              weakmap: 'Script::WeakMapRemoteValue',
              weakset: 'Script::WeakSetRemoteValue',
              generator: 'Script::GeneratorRemoteValue',
              error: 'Script::ErrorRemoteValue',
              proxy: 'Script::ProxyRemoteValue',
              promise: 'Script::PromiseRemoteValue',
              typedarray: 'Script::TypedArrayRemoteValue',
              arraybuffer: 'Script::ArrayBufferRemoteValue',
              nodelist: 'Script::NodeListRemoteValue',
              htmlcollection: 'Script::HTMLCollectionRemoteValue',
              node: 'Script::NodeRemoteValue',
              window: 'Script::WindowProxyRemoteValue'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SymbolRemoteValue = Serialization::Record.define(
            type: {fixed: 'symbol'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ArrayRemoteValue = Serialization::Record.define(
            type: {fixed: 'array'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::RemoteValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ObjectRemoteValue = Serialization::Record.define(
            type: {fixed: 'object'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::RemoteValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          FunctionRemoteValue = Serialization::Record.define(
            type: {fixed: 'function'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RegExpRemoteValue = Serialization::Record.define(
            type: {fixed: 'regexp'},
            value: {wire_key: 'value', ref: 'Script::RegExpValue'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          DateRemoteValue = Serialization::Record.define(
            type: {fixed: 'date'},
            value: {wire_key: 'value', primitive: 'string'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          MapRemoteValue = Serialization::Record.define(
            type: {fixed: 'map'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::RemoteValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SetRemoteValue = Serialization::Record.define(
            type: {fixed: 'set'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::RemoteValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WeakMapRemoteValue = Serialization::Record.define(
            type: {fixed: 'weakmap'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WeakSetRemoteValue = Serialization::Record.define(
            type: {fixed: 'weakset'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          GeneratorRemoteValue = Serialization::Record.define(
            type: {fixed: 'generator'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ErrorRemoteValue = Serialization::Record.define(
            type: {fixed: 'error'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ProxyRemoteValue = Serialization::Record.define(
            type: {fixed: 'proxy'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          PromiseRemoteValue = Serialization::Record.define(
            type: {fixed: 'promise'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          TypedArrayRemoteValue = Serialization::Record.define(
            type: {fixed: 'typedarray'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ArrayBufferRemoteValue = Serialization::Record.define(
            type: {fixed: 'arraybuffer'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          NodeListRemoteValue = Serialization::Record.define(
            type: {fixed: 'nodelist'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::RemoteValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          HTMLCollectionRemoteValue = Serialization::Record.define(
            type: {fixed: 'htmlcollection'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::RemoteValue', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          NodeRemoteValue = Serialization::Record.define(
            type: {fixed: 'node'},
            shared_id: {wire_key: 'sharedId', required: false},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false},
            value: {wire_key: 'value', required: false, ref: 'Script::NodeProperties'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          NodeProperties = Serialization::Record.define(
            node_type: 'nodeType',
            child_node_count: 'childNodeCount',
            attributes: {wire_key: 'attributes', required: false},
            children: {wire_key: 'children', required: false, ref: 'Script::NodeRemoteValue', list: true},
            local_name: {wire_key: 'localName', required: false, primitive: 'string'},
            mode: {wire_key: 'mode', required: false, enum: 'Script::NODE_PROPERTIES_MODE'},
            namespace_uri: {wire_key: 'namespaceURI', required: false, primitive: 'string'},
            node_value: {wire_key: 'nodeValue', required: false, primitive: 'string'},
            shadow_root: {wire_key: 'shadowRoot', required: false, nullable: true, ref: 'Script::NodeRemoteValue'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WindowProxyRemoteValue = Serialization::Record.define(
            type: {fixed: 'window'},
            value: {wire_key: 'value', ref: 'Script::WindowProxyProperties'},
            handle: {wire_key: 'handle', required: false},
            internal_id: {wire_key: 'internalId', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          WindowProxyProperties = Serialization::Record.define(context: 'context')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SerializationOptions = Serialization::Record.define(
            max_dom_depth: {wire_key: 'maxDomDepth', required: false, nullable: true},
            max_object_depth: {wire_key: 'maxObjectDepth', required: false, nullable: true},
            include_shadow_tree: {
              wire_key: 'includeShadowTree',
              required: false,
              enum: 'Script::SERIALIZATION_OPTIONS_INCLUDE_SHADOW_TREE'
            }
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          StackFrame = Serialization::Record.define(
            column_number: 'columnNumber',
            function_name: {wire_key: 'functionName', primitive: 'string'},
            line_number: 'lineNumber',
            url: {wire_key: 'url', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          StackTrace = Serialization::Record.define(
            call_frames: {wire_key: 'callFrames', ref: 'Script::StackFrame', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          Source = Serialization::Record.define(
            realm: 'realm',
            context: {wire_key: 'context', required: false},
            user_context: {wire_key: 'userContext', required: false}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RealmTarget = Serialization::Record.define(realm: 'realm')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ContextTarget = Serialization::Record.define(
            context: 'context',
            sandbox: {wire_key: 'sandbox', required: false, primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class Target < Serialization::Union
            presence(
              'Script::ContextTarget' => ['context'],
              'Script::RealmTarget' => ['realm']
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          AddPreloadScriptParameters = Serialization::Record.define(
            function_declaration: {wire_key: 'functionDeclaration', primitive: 'string'},
            arguments: {wire_key: 'arguments', required: false, ref: 'Script::ChannelValue', list: true},
            contexts: {wire_key: 'contexts', required: false, list: true},
            user_contexts: {wire_key: 'userContexts', required: false, list: true},
            sandbox: {wire_key: 'sandbox', required: false, primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          AddPreloadScriptResult = Serialization::Record.define(script: 'script')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          DisownParameters = Serialization::Record.define(
            handles: {wire_key: 'handles', list: true},
            target: {wire_key: 'target', ref: 'Script::Target'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          CallFunctionParameters = Serialization::Record.define(
            function_declaration: {wire_key: 'functionDeclaration', primitive: 'string'},
            await_promise: {wire_key: 'awaitPromise', primitive: 'boolean'},
            target: {wire_key: 'target', ref: 'Script::Target'},
            arguments: {wire_key: 'arguments', required: false, ref: 'Script::LocalValue', list: true},
            result_ownership: {wire_key: 'resultOwnership', required: false, enum: 'Script::RESULT_OWNERSHIP'},
            serialization_options: {
              wire_key: 'serializationOptions',
              required: false,
              ref: 'Script::SerializationOptions'
            },
            this: {wire_key: 'this', required: false, ref: 'Script::LocalValue'},
            user_activation: {wire_key: 'userActivation', required: false, primitive: 'boolean'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          EvaluateParameters = Serialization::Record.define(
            expression: {wire_key: 'expression', primitive: 'string'},
            target: {wire_key: 'target', ref: 'Script::Target'},
            await_promise: {wire_key: 'awaitPromise', primitive: 'boolean'},
            result_ownership: {wire_key: 'resultOwnership', required: false, enum: 'Script::RESULT_OWNERSHIP'},
            serialization_options: {
              wire_key: 'serializationOptions',
              required: false,
              ref: 'Script::SerializationOptions'
            },
            user_activation: {wire_key: 'userActivation', required: false, primitive: 'boolean'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          GetRealmsParameters = Serialization::Record.define(
            context: {wire_key: 'context', required: false},
            type: {wire_key: 'type', required: false, enum: 'Script::REALM_TYPE'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          GetRealmsResult = Serialization::Record.define(
            realms: {wire_key: 'realms', ref: 'Script::RealmInfo', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RemovePreloadScriptParameters = Serialization::Record.define(script: 'script')

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          MessageParameters = Serialization::Record.define(
            channel: 'channel',
            data: {wire_key: 'data', ref: 'Script::RemoteValue'},
            source: {wire_key: 'source', ref: 'Script::Source'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RealmDestroyedParameters = Serialization::Record.define(realm: 'realm')

          EVENT_TYPES = {
            'script.message' => Script::MessageParameters,
            'script.realmCreated' => Script::RealmInfo,
            'script.realmDestroyed' => Script::RealmDestroyedParameters
          }.freeze

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def add_preload_script(
            function_declaration:,
            arguments: Serialization::UNSET,
            contexts: Serialization::UNSET,
            user_contexts: Serialization::UNSET,
            sandbox: Serialization::UNSET
          )
            params = AddPreloadScriptParameters.new(
              function_declaration: function_declaration,
              arguments: arguments,
              contexts: contexts,
              user_contexts: user_contexts,
              sandbox: sandbox
            )
            execute(cmd: 'script.addPreloadScript', params: params, result: Script::AddPreloadScriptResult)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def call_function(
            function_declaration:,
            await_promise:,
            target:,
            arguments: Serialization::UNSET,
            result_ownership: Serialization::UNSET,
            serialization_options: Serialization::UNSET,
            this: Serialization::UNSET,
            user_activation: Serialization::UNSET
          )
            Serialization.validate!('resultOwnership', result_ownership, Script::RESULT_OWNERSHIP)
            params = CallFunctionParameters.new(
              function_declaration: function_declaration,
              await_promise: await_promise,
              target: target,
              arguments: arguments,
              result_ownership: result_ownership,
              serialization_options: serialization_options,
              this: this,
              user_activation: user_activation
            )
            execute(cmd: 'script.callFunction', params: params, result: Script::EvaluateResult)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def disown(handles:, target:)
            params = DisownParameters.new(handles: handles, target: target)
            execute(cmd: 'script.disown', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def evaluate(
            expression:,
            target:,
            await_promise:,
            result_ownership: Serialization::UNSET,
            serialization_options: Serialization::UNSET,
            user_activation: Serialization::UNSET
          )
            Serialization.validate!('resultOwnership', result_ownership, Script::RESULT_OWNERSHIP)
            params = EvaluateParameters.new(
              expression: expression,
              target: target,
              await_promise: await_promise,
              result_ownership: result_ownership,
              serialization_options: serialization_options,
              user_activation: user_activation
            )
            execute(cmd: 'script.evaluate', params: params, result: Script::EvaluateResult)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def get_realms(context: Serialization::UNSET, type: Serialization::UNSET)
            Serialization.validate!('type', type, Script::REALM_TYPE)
            params = GetRealmsParameters.new(context: context, type: type)
            execute(cmd: 'script.getRealms', params: params, result: Script::GetRealmsResult)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def remove_preload_script(script:)
            params = RemovePreloadScriptParameters.new(script: script)
            execute(cmd: 'script.removePreloadScript', params: params)
          end
        end # Script
      end # Protocol
    end # BiDi
  end # WebDriver
end # Selenium