WebDriver BiDi

W3C 作業草案,

この文書の詳細
このバージョン:
https://www.w3.org/TR/2026/WD-webdriver-bidi-20260629/
最新公開バージョン:
https://www.w3.org/TR/webdriver-bidi/
編集者草案:
https://w3c.github.io/webdriver-bidi/
以前のバージョン:
履歴:
https://www.w3.org/standards/history/webdriver-bidi/
実装報告:
https://wpt.fyi/results/webdriver/tests/bidi
テストスイート:
https://github.com/web-platform-tests/wpt/tree/master/webdriver/tests/bidi
フィードバック:
GitHub
仕様内インライン
編集者:
James Graham (Mozilla)
Alex Rudenko (Google)
Maksim Sadym (Google)
チャンネル:
irc.w3.org 上の #webdriver
Wiki:
W3C WebDriver Wiki

概要

この文書は、ユーザーエージェントをリモート制御するための仕組みである、双方向 WebDriver プロトコルを定義する。

この文書のステータス

この節は、この文書の公開時点におけるステータスを説明する。現在の W3C 公開文書の一覧およびこの技術報告書の最新改訂版は、W3C 標準および草案索引で確認できる。

この仕様に関する議論には、GitHub Issues が推奨される。 あるいは、Browser Testing and Tools Working Group のメーリングリスト public-browser-tools-testing@w3.orgアーカイブ)へコメントを送ることもできる。

この文書は、Browser Testing and Tools Working Group により、勧告 トラックを用いた作業草案として公開された。

作業草案としての公開は、 W3C およびそのメンバーによる支持を意味しない。

これは草案文書であり、いつでも他の文書によって更新、置換、または廃止される可能性がある。 作業中のもの以外としてこの文書を引用することは不適切である。

この文書は、W3C Patent Policy の下で活動するグループによって作成された。 W3C は、このグループの成果物に関連して行われたすべての 特許開示の公開リストを維持している。そのページには、特許を開示するための手順も含まれる。 個人が、その個人の知る限り Essential Claim(s) を含むと考える特許について実際の知識を有する場合、その情報を W3C Patent Policy の第 6 節に従って開示しなければならない。

この文書は、2025年8月18日版 W3C Process Document によって管理される。

1. 序論

この節は非規範的である。

WebDriver は、ユーザーエージェントの イントロスペクションおよび リモート制御のためのプロトコルを定義する。この仕様は、 双方向通信を導入することにより WebDriver を拡張する。WebDriver の厳密な コマンド/レスポンス形式に代えて、これによりイベントを ユーザーエージェントから制御ソフトウェアへストリーミングできるようになり、 ブラウザー DOM のイベント駆動の性質によりよく一致する。

2. 基盤

この仕様は Infra Standard に依存する。[INFRA]

ネットワークプロトコルメッセージは CDDL を用いて定義される。[RFC8610]

この仕様は、map である wait queue を定義する。

この「イベントを待つ」ことを行うための、もっとよい 仕組みがきっとあるはずだ。

並列に実行されているアルゴリズム algorithm が、イベントの集合 events および resume idawaits するとき:

  1. algorithm の実行を一時停止する。

  2. 表明: wait queueresume id を含まない。

  3. wait queue[resume id] を (events, algorithm) に設定する。

与えられた nameid および parametersresume するには:
  1. wait queueid を含まない場合、戻る。

  2. (events, algorithm) を wait queue[id] とする

  3. events 内の各 event について:

    1. eventname と等しい場合:

      1. wait queue から id を削除する。

      2. algorithm 内のステップの実行を、 一時停止された地点から再開し、name および parametersawait の結果として渡す。

        これがイベントループ上の他のどのタスクよりも先に 実行されることを保証するために、microtasks のようなものを 持つべきだろうか?

WebDriver configuration は、次を持つ struct である:

WebDriver configurationassociated type を持ち、 これは type である。

WebDriver configuration に対する value は、その設定に対する associated type である型を持つ値、または unset のいずれかである。

Unset は、特定の設定 value が設定されていないことを示す値である。

注: このアルゴリズムは、与えられた navigable についての WebDriver configuration に、 navigables 内の値を確認し、次に user contexts 内、最後に global 内を確認することでアクセスできるようにする。 設定されていない場合は unset を返す。

WebDriver configuration configuration の、 navigable navigable に対する get WebDriver configuration value は:

  1. top-level traversablenavigabletop-level traversable とする。

  2. configurationnavigablestop-level traversable含む場合:

    1. navigable configuration valueconfigurationnavigables[top-level traversable] とする。

    2. navigable configuration valueunset でない場合、 navigable configuration value を返す。

  3. user contextnavigableassociated user context とする。

  4. configurationuser contextsuser context含む場合:

    1. user context configuration valueconfigurationuser contexts[user context] とする。

    2. user context configuration valueunset でない場合、 user context configuration value を返す。

  5. configurationglobal を返す。

注: これは WebDriver configurationtarget ごとに格納するための汎用アルゴリズムであり、targetnavigableuser context のいずれか、または target が null もしくは省略された場合はグローバルに格納できる。

WebDriver configuration configurationvalue value を、任意の targetstore するには。これは navigableuser context、または提供されない場合は null である:

  1. target が null である場合、configurationglobalvalue に設定する。

  2. targetuser context である場合、configurationuser contexts[target] を value に設定する。

  3. targetnavigable である場合、configurationnavigables[target] を value に設定する。

注: この汎用アルゴリズムは、 command parameters 内の "userContexts" および "contexts" の存在に応じて、WebDriver configurationvalueglobaluser contexts、または navigables に格納する。これらの パラメーター は相互に排他的である。どちらも提供されない場合、設定はグローバルに格納される。

与えられた command parameters について、WebDriver configuration configurationvalue valuestore WebDriver configuration するには:

  1. command parameters が "userContexts" を含み、かつ command parameters が "contexts" を含む場合、error を、error code invalid argument とともに返す。

  2. affected navigables を空の set とする。

  3. command parameters が "contexts" を含む場合:

    1. navigables を、command parameters["contexts"] で get valid top-level traversables by ids することを試みた結果とする。

    2. navigables の各 navigable について:

      1. navigableaffected navigables追加する

      2. configurationvaluenavigablestore する。

  4. そうでなく、command parameters が "userContexts" を含む場合:

    1. user contexts を、command parameters["userContexts"] で get valid user contexts することを試みた結果とする。

    2. user contexts の各 user context について:

      1. user context である associated user context を持つ、すべての top-level traversables のリスト内の 各 top-level traversable について反復する:

        1. top-level traversableaffected navigables追加する

      2. configurationvalueuser contextstore する。

  5. そうでなければ:

    1. すべての top-level traversables の各 top-level traversable について反復しtop-level traversableaffected navigables追加する

    2. configurationvalueStore する。

  6. affected navigables を返す。

3. プロトコル

この節は、WebDriver BiDi プロトコルの基本概念を定義する。これらの用語は、 トランスポート層での表現とは異なる。

このプロトコルは CDDL 定義を用いて定義される。実装者の便宜のため、2 つの別々の CDDL 定義が定義される。 すなわち、local end で生成され、remote end で消費されるメッセージの形式を 定義する remote end definition と、 remote end で生成され、 local end で消費されるメッセージの形式を定義する local end definition である。

3.1. 定義

これは 付録であるべきだろうか?

この節は、remote end definition および local end definition の初期内容を示す。 これらは、仕様の残りの部分で定義される定義断片によって拡張される。

Command = {
    id: js-uint,
    CommandData,
    Extensible,
    }

    CommandData = (
    BrowserCommand //
    BrowsingContextCommand //
    EmulationCommand //
    InputCommand //
    NetworkCommand //
    ScriptCommand //
    SessionCommand //
    StorageCommand //
    WebExtensionCommand
    )

    EmptyParams = {
    Extensible
    }

Local end definition

Message = (
  CommandResponse /
  ErrorResponse /
  Event
)

CommandResponse = {
  type: "success",
  id: js-uint,
  result: ResultData,
  Extensible
}

ErrorResponse = {
  type: "error",
  id: js-uint / null,
  error: ErrorCode,
  message: text,
  ? stacktrace: text,
  Extensible
}

ResultData = (
  BrowserResult /
  BrowsingContextResult /
  EmulationResult /
  InputResult /
  NetworkResult /
  ScriptResult /
  SessionResult /
  StorageResult /
  WebExtensionResult
)

EmptyResult = {
  Extensible
}

Event = {
  type: "event",
  EventData,
  Extensible
}

EventData = (
  BrowsingContextEvent //
  InputEvent //
  LogEvent //
  NetworkEvent //
  ScriptEvent
)

EmptyResult は、 必須フィールドを持たない結果型であり、 結果データを生成しないコマンドの返り値の型として使用される。

Remote end definition および Local end definition

Extensible = (*text => any)

js-int = -9007199254740991..9007199254740991
js-uint = 0..9007199254740991

3.2. セッション

WebDriver BiDi は、セッション概念を WebDriver から拡張する。

セッションBiDi フラグを持ち、特に明記されない限り、 これは false である。

BiDi セッションは、セッションであって、BiDi フラグが true に設定されているものである。

active BiDi sessions のリストは、次で与えられる:
  1. BiDi sessions を新しい list とする。

  2. active sessions 内の各 session について:

    1. sessionBiDi session である場合、sessionBiDi sessions に追加する。

  3. BiDi sessions を返す。

3.3. モジュール

WebDriver BiDi プロトコルはモジュールに編成される。

module は、ユーザー エージェントの特定の側面に関係する、関連した commands および events の集合を表す。たとえば、モジュールは DOM の検査や 操作、またはスクリプト実行のための機能を含むことがある。

各モジュールは、文字列である module name を持つ。 モジュール内で定義されるコマンドおよびイベントに対する command name および event name は、 module name で始まり、その後にピリオド "." が続く。

commands を含むモジュールは、remote end definition 断片を定義する。これらは、モジュールの commands に対して CommandData グループ内に選択肢を提供し、また 追加の定義プロパティを定義することもできる。それらは、モジュール内のコマンド結果に対して ResultData グループ内に追加の選択肢を提供する local end definition 断片を定義することもできる。

イベントを含むモジュールは、モジュールの events に対して Event グループ内の 選択肢となる local end definition 断片を定義する。

実装は extension modules を定義してもよい。これらは、単一のコロン ":" 文字を含む module name を持たなければならない。コロンの前の部分は接頭辞であり、通常は特定の実装に固有のすべての extension modules で同じであり、特定の実装に対して一意であるべきである。

他の仕様は、プロトコルを拡張する独自の WebDriver-BiDi モジュールを定義してもよい。 そのようなモジュールは、コロン(:)文字を含む名前を持ってはならず、 また、その文字を含む command namesevent names、またはプロパティ 名を定義してはならない。

外部仕様の作者には、既存のモジュールを拡張するのではなく、新しいモジュールを追加することが推奨される。 既存のモジュールを拡張することが望まれる場合は、その拡張を元のモジュール定義を含む仕様に直接統合することが望ましい。

3.4. コマンド

command は非同期 操作であり、local end によって要求され、remote end 上で実行され、 その結果として result または error のいずれかが local end に返される。 複数の コマンドを同時に実行でき、コマンドは潜在的に 長時間実行されることがある。その結果、コマンドは順序どおりでなく完了することがある。

command は次によって定義される:

アクティブなセッションなしで実行できるコマンドは static command である。コマンドは、その 定義で述べられない限り static command ではない。

コマンドが local end から送信されるとき、 それらは command id を持つ。これは、特定の コマンドからのレスポンスを識別するために local end が使用する識別子である。 remote end の観点からは、この識別子は不透明であり、 コマンドを識別するために内部的に使用することはできない。

注: これは、command id が完全に local end によって制御され、セッションの過程で必ずしも一意ではないためである。たとえば、すべてのレスポンスを無視する local end は、 各コマンドに同じ command id を使用できる。

set of all command names は、set であり、 extension modules に属するものを含む、定義済みのすべての command names を含む。

3.5. エラー

WebDriver BiDi は、error codes の集合を WebDriver から次の追加コードで拡張する:

invalid web extension
無効な Web 拡張機能をインストールしようとした。
no such client window
未知の client window とやり取りしようとした。
no such handle
未知の RemoteObjectReference を逆シリアル化しようとした。
no such history entry
未知の session history entry へ移動しようとした。
no such network collector
未知の collector を削除しようとした。
no such intercept
未知の network intercept を削除しようとした。
no such network data
未知の network data を参照しようとした。
no such node
未知の SharedReference を逆シリアル化しようとした。
no such request
未知の request を続行しようとした。
そのようなスクリーンキャストはない
不明なスクリーンキャスト記録を停止しようとした。
no such script
未知の preload script を削除しようとした。
no such storage partition
存在しないストレージパーティション内のデータにアクセスしようとした。
no such user context
未知の user context を参照しようとした。
no such web extension
未知の Web 拡張機能を参照しようとした。
unable to close browser
ブラウザーを閉じようとしたが、失敗した。
unable to set cookie
Cookie を作成しようとしたが、ユーザーエージェントに拒否された。
underspecified storage partition
十分に指定されていないストレージパーティション内のデータとやり取りしようとした。
unable to set file input
ファイル入力を設定しようとしたが、失敗した。
unavailable network data
収集されていない、またはすでに破棄されたネットワークデータを取得しようとした。
ErrorCode = "invalid argument" /
            "invalid selector" /
            "invalid session id" /
            "invalid web extension" /
            "move target out of bounds" /
            "no such alert" /
            "no such network collector" /
            "no such element" /
            "no such frame" /
            "no such handle" /
            "no such history entry" /
            "no such intercept" /
            "no such network data" /
            "no such node" /
            "no such request" /
            "no such screencast" /
            "no such script" /
            "no such storage partition" /
            "no such user context" /
            "no such web extension" /
            "session not created" /
            "unable to capture screen" /
            "unable to close browser" /
            "unable to set cookie" /
            "unable to set file input" /
            "unavailable network data" /
            "underspecified storage partition" /
            "unknown command" /
            "unknown error" /
            "unsupported operation"

3.6. イベント

event は通知であり、 remote end によって local end へ送信され、remote end 上で関心のある何かが 発生したことを通知する。

BiDi sessionsubscriptions を持ち、これは list of subscriptions である。

BiDi sessionknown subscription ids を持ち、これは set であり、 local end に発行されたがまだ購読解除されていない、すべての subscription ids を含む。

subscription は、struct であり、 subscription id(文字列)、 event names(event names の set)、 top-level traversable idstop-level traversables の ID の set) および user context idsuser contexts の ID の set)からなる。

subscription subscription は、subscriptiontop-level traversable ids が空の set であり、 かつ subscriptionuser context ids が空の set である場合、 global である。

event name および navigables が与えられたときの set of sessions for which an event is enabled は次である:

  1. sessions を新しい set とする。

  2. active BiDi sessions 内の各 session について:

    1. sessionevent name および navigablesevent is enabled である場合、 sessionsessions に追加する。

  3. sessions を返す。

sessionevent name および navigables が与えられたとき、event is enabled であるかどうかを判定するには:

注: shared worker は複数のコンテキストに関連付けられ得るため、 navigables は set である。

  1. top-level traversables を、navigablesget top-level traversables したものとする。

  2. sessionsubscriptions 内の各 subscription について:

    1. subscriptionevent namesevent name含まない場合、continue する。

    2. subscriptionglobal である場合、true を返す。

    3. user context ids が空でない場合:

      1. top-level traversables 内の各 navigable について反復する:

        1. subscriptionuser context ids が、 navigableassociated user contextuser context id含む場合、 true を返す。

    4. そうでなければ:

      1. subscription top-level traversables を、subscriptiontop-level traversable idsget navigables by ids したものとする。

      2. top-level traversablessubscription top-level traversables積集合でない場合、true を返す。

  3. false を返す。

event name および session が与えられたときの set of top-level traversables for which an event is enabled は次である:

  1. result を新しい set とする。

  2. sessionsubscriptions 内の各 subscription について:

    1. subscriptionevent namesevent name含まない場合、 continue する。

    2. subscriptionglobal である場合:

      1. remote end の top-level traversables 内の各 traversable について:

        1. traversableresult追加する

      2. Break する。

    3. そうでなく、user context ids が空でない場合:

      1. remote end の top-level traversables 内の各 traversable について:

        1. subscriptionuser context idstraversableassociated user contextuser context id含む場合、 traversableresult追加する

    4. そうでなければ:

      1. top-level traversables を、subscriptiontop-level traversable idsget navigables by ids したものとする。

      2. top-level traversables の各項目を result追加する

  3. result を返す。

与えられた nameobtain a set of event names するには:
  1. events を空の set とする。

  2. name が U+002E(ピリオド)を含む場合:

    1. name がイベントに対する event name である場合、nameevents に追加し、 data events とともに success を返す。

    2. error code invalid argument を持つ error を返す

  3. そうでなければ、name はモジュール内のすべてのイベントを表すものとして解釈される。 namemodule name でない場合、error code invalid argument を持つ error を返す。

  4. 名前 name を持つモジュール内の各 event に対する event nameevents に追加する。

  5. data events とともに success を返す。

4. トランスポート

メッセージトランスポートは WebSocket プロトコルを用いて提供される。 [RFC6455]

注: WebSocket プロトコルの用語では、local end は クライアントであり、remote end はサーバー / リモートホストである。

注: commands および events のメッセージとしての符号化は JSON-RPC に似ているが、この仕様はそれを規範的に 参照しない。[JSON-RPC] 代わりに、remote ends に対する規範的要件は正確な処理モデルとして与えられ、 local ends に対する 規範的要件は与えられない。

WebSocket listener は、受信する WebSocket 接続を 受け入れることができるネットワークエンドポイントである。

WebSocket listenerhostportsecure flag、および list of WebSocket resources を持つ。

WebSocket listener listener が作成されたとき、remote end は、listenerhost および port によって与えられるホストおよびポート上で、 WebSocket 接続を待ち受け始めなければならない。 listenersecure flag が設定されている場合、 listener から確立される接続は TLS で暗号化されなければならない。

remote end は、set of WebSocket listeners である active listeners を持ち、これは初期状態では空である。

remote end は、set of WebSocket connections not associated with a session を持ち、これは初期状態では空である。

WebSocket connection は、 WebSocket protocol の要件に従うネットワーク接続である

BiDi session は、set of session WebSocket connections を持ち、その要素は WebSocket connections である。これは 初期状態では空である。

BiDi session session は、sessionsession WebSocket connectionsconnection を含む場合、connectionassociated with connection している。

注:WebSocket connection は、最大でも 1 つの BiDi session と関連付けられる。

クライアントが WebSocket 接続を確立するとき、すなわち connectionactive listeners の集合内の listener の 1 つに接続して 確立するとき、実装は WebSocket の server-side requirements に従って進めなければならず、受信接続を 受け入れるかどうかを決定するときに次のステップを実行する:

  1. resource name を、クライアントの開始ハンドシェイクを読むことから得られるリソース名とする。 resource namelistenerlist of WebSocket resources 内にない場合、 これらのステップの実行を停止し、要求されたサービスが利用できないかのように動作する。

  2. resource name がバイト文字列 "/session" であり、 実装が supports BiDi-only sessions する場合:

    1. 接続を受け入れるべきかどうかを決定するための、その他の実装定義のステップを実行し、 受け入れない場合はこれらのステップの実行を停止し、 要求されたサービスが利用できないかのように動作する。

    2. その接続を WebSocket connections not associated with a session に追加する。

    3. 戻る。

  3. resource nameGet a session ID for a WebSocket resource し、 session id をその値とする。session id が null である場合、 これらのステップの実行を停止し、要求されたサービスが利用できないかのように動作する。

  4. アクティブなセッションのリスト内に、 session id をその セッション ID とする セッションがある場合、session をその セッションとする。そうでなければ、これらの手順の実行を停止し、 要求されたサービスが利用できないものとして振る舞う。

  5. 接続を受け入れるべきかどうかを決定するための、その他の実装定義のステップを実行し、 受け入れない場合はこれらのステップの実行を停止し、 要求されたサービスが利用できないかのように動作する。

  6. そうでなければ、connectionsessionsession WebSocket connections に追加し、サーバーが受信接続を受け入れることを選択するときの WebSocket server-side requirements に従って進める。

1 つのセッションに対して 2 つ以上の 接続をサポートするのか?

WebSocket メッセージが受信されたとき、WebSocket connection connection について、型 type およびデータ data が与えられる場合、remote endconnectiontype および data が与えられたものとして handle an incoming message しなければならない。

WebSocket の終了ハンドシェイクが開始されたとき、または WebSocket 接続が閉じられたとき、WebSocket connection connection について、remote endconnection が与えられたものとして handle a connection closing しなければならない。

注: 終了ハンドシェイクなしに WebSocket 接続が閉じられる可能性があるため、 両方の条件が必要である。

セッション session が与えられたとき、WebSocket リソース名を構築するには、次を実行する:

  1. session が null なら、"/session" を返す

  2. 文字列 "/session/" と sessionセッション ID とを連結した結果を返す。

WebSocket リスナー listener および セッション session が与えられたとき、WebSocket URL を構築するには、 次を実行する:

  1. resource name を、session により WebSocket リソース名を構築する 結果とする。

  2. host を listenerhost に、port を listenerport に、path を resource name に設定して構築された WebSocket URI を返す。これは、 listenersecure flag が設定されている場合は wss-URI 構成に従い、そうでなければ ws-URL 構成に従う。

resource name が与えられたとき、WebSocket リソースのセッション ID を取得するには、次を実行する:

  1. resource name がバイト文字列 "/session/" で始まらない場合、null を返す。

  2. session id を、resource name 内の "/session/" 接頭辞に続くバイト列とする。

  3. session idUUID の文字列表現でない場合、null を返す。

  4. session id を返す。

セッション session が与えられたとき、WebSocket 接続のリッスンを開始するには、次を実行する:
  1. リモートエンドが再利用したい既存の WebSocket リスナーアクティブリスナー内にある場合、 listener をその リスナーとする。そうでなければ、listener を、実装定義hostportsecure flag、および空の WebSocket リソースのリストを持つ新しい WebSocket リスナーとする。

  2. resource name を、session により WebSocket リソース名を構築する 結果とする。

  3. resource namelistenerWebSocket リソースのリストに 追加する。

  4. listenerリモートエンドアクティブリスナー追加する。

  5. listener を返す。

注: 複数のセッションを処理する intermediary node は、1 つまたは多数の WebSocket listener を使用できる。WebDriver は、 endpoint node が同時に最大 1 つのセッションをサポートすると定義しているため、 listener は 1 つだけであることが想定される。

注: endpoint node では、上記ステップにおける host は 通常 "localhost" になる。

WebSocket connection connection、型 type およびデータ data が与えられたとき、 handle an incoming message するには:
  1. typetext でない場合、connection、 null、および invalid argument が与えられたものとして send an error response し、最後に 戻る。

  2. Assert: datascalar value string である。そうでなければ、WebSocket の UTF-8 符号化データ内のエラー処理 が、すでに WebSocket connection を失敗させているためである。

    UTF-8 エラーにどの status code が使用されるかを定義しているものはないように思われる。

  3. connectionassociated with connection している BiDi Session が存在する場合、 session をそのセッションとする。そうでなく、connectionWebSocket connections not associated with a session 内にある場合、session を null とする。そうでなければ、戻る。

  4. parsed を、data が与えられたものとして JSON を Infra values に構文解析する結果とする。 これが例外を投げる場合、connection、 null、および invalid argument が与えられたものとして send an error response し、 最後に戻る。

  5. session が null でなく、かつ active sessions 内にない場合、戻る。

  6. parsedremote end definition に対して照合する。 これが 一致になる場合:

    1. matched を、一致したデータを表す map とする。

    2. Assert: matched は "id"、"method"、および "params" を含む

    3. command idmatched["id"] とする。

    4. methodmatched["method"] とする

    5. command を、command name method を持つ command とする。

    6. session が null であり、かつ commandstatic command でない場合、 connectioncommand id、および invalid session id が与えられたものとして send an error response し、戻る。

    7. 次のステップを並列に実行する:

      1. result を、 session および command parameters matched["params"] が与えられたものとして、 command に対する remote end steps を実行した結果とする。

      2. resulterror である場合、 connectioncommand id、および resulterror code が与えられたものとして send an error response し、最後に 戻る。

      3. valueresult の data とする。

      4. Assert: value は、command name method を持つ command に対応する result type の定義に一致する。

      5. method が "session.new" である場合、sessionactive sessions のリスト内の、その session IDvalue の "sessionId" プロパティと等しいエントリーとし、connectionsessionsession WebSocket connections追加しconnectionWebSocket connections not associated with a session から削除する。

      6. response を、local end definition 内の CommandResponse 生成規則に一致する新しい map とする。 id フィールドは command id に設定され、value フィールドは value に設定される。

      7. serialized を、response が与えられたものとして serialize an infra value to JSON bytes した結果とする。

      8. serialized からなる WebSocket メッセージを送信する。 これは connection 上で行う。

  7. そうでなければ:

    1. command id を null とする。

    2. parsedmap であり、かつ parsed["id"] が存在し、0 以上の integer である場合、command id をその integer に設定する。

    3. error codeinvalid argument とする。

    4. parsedmap であり、かつ parsed["method"] が存在し、 string であるが、parsed["method"] が set of all command names 内にない場合、 error codeunknown command に設定する。

    5. connectioncommand id、および error code が与えられたものとして Send an error response する。

settings object settings が与えられたとき、get related navigables するには:

  1. related navigables を空の set とする。

  2. settingsrelevant global objectWindow である場合:

    1. navigable を、relevant global objectassociated Documentnode navigable とする。

    2. navigable が null でない場合、navigablerelated navigables に追加する。

  3. そうでなく、settings によって指定される global objectWorkerGlobalScope である場合、 global objectowner set 内の各 owner について:

    1. navigable を null とする。

    2. ownerDocument である場合、navigableownernode navigable に設定する。

    3. navigable が null でない場合、navigablerelated navigables に追加する。

  4. related navigables を返す。

context ids の list navigable ids が与えられたとき、get navigables by ids するには:

  1. result を空の set とする。

  2. navigable ids 内の各 navigable id について:

    1. navigable を、id navigable id を持つ navigable が存在する場合はその navigable、そうでなければ null とする。

    2. navigable が null でない場合、 navigableresult追加する

  3. result を返す。

list of navigables navigables が与えられたとき、get top-level traversables するには:

  1. result を空の set とする。

  2. navigables 内の各 navigable について:

    1. navigabletop-level traversableresult追加する

  3. result を返す。

context ids の list navigable ids が与えられたとき、get valid navigables by ids するには:

  1. result を空の set とする。

  2. navigable ids 内の各 navigable id について:

    1. navigable を、navigable idget a navigable することを試みた結果とする。

    2. navigableresult追加する

  3. data result とともに success を返す。

context ids の list navigable ids が与えられたとき、 get valid top-level traversables by ids するには:

  1. result を空の set とする。

  2. navigable ids 内の各 navigable id について:

    1. navigable を、navigable idget a navigable することを試みた結果とする。

    2. navigabletop-level traversable でない場合、 error を、error code invalid argument とともに返す。

    3. navigableresult追加する

  3. data result とともに success を返す。

session および body が与えられたとき、 emit an event するには:
  1. Assert: bodyEvent 生成規則に一致する。

  2. serialized を、body が与えられたものとして serialize an infra value to JSON bytes した結果とする。

  3. sessionsession WebSocket connections 内の各 connection について反復する:

    1. serialized からなる WebSocket メッセージを送信する。 これは connection 上で行う。

WebSocket connection connectioncommand id、および error code が与えられたとき、 send an error response するには:
  1. error data を、local end definition 内の ErrorResponse 生成規則に一致する新しい map とする。 id フィールドは command id に設定され、error フィールドは error code に設定され、 message フィールドは、発生したエラーの人間可読な定義を含む 実装定義の文字列に設定され、stacktrace フィールドは任意で、 エラーが発生した時点のアクティブなスタックフレームのスタックトレース報告を含む 実装定義の文字列に設定される。

  2. response を、error data が与えられたものとして serialize an infra value to JSON bytes した結果とする。

    注: command id は null になり得る。その場合、 id フィールドも null に設定され、 response から省略されるわけではない。

  3. response からなる WebSocket メッセージを送信する。 これは connection 上で行う。

WebSocket connection connection が与えられたとき、handle a connection closing するには:

  1. connectionassociated with connection している BiDi session が存在する場合:

    1. session を、connectionassociated with connection している BiDi session とする。

    2. connectionsessionsession WebSocket connections から削除する。

  2. そうでなく、WebSocket connections not associated with a sessionconnection含む場合、connection をその set から削除する

注記: これはいかなる セッションも終了しない。

UA が望む場合に listener を閉じられるようにするため、session の終了にフックする必要がある。

session が与えられたとき、close the WebSocket connections するには:

  1. sessionsession WebSocket connections 内の各 connection について:

    1. connectionWebSocket の終了ハンドシェイクを開始する

      注: これにより、connection に対して handle a connection closing のステップが実行されることになり、connection に関連付けられたリソースが クリーンアップされる。

4.1. 接続の確立

WebDriver クライアントは、値 true で WebSocket URL capability を要求することにより、 双方向接続にオプトインする。

この仕様によって定義される WebDriver new session algorithm は、 パラメーター sessioncapabilities、および flags を取り、次である:
  1. flags が "bidi" を含む場合、戻る。

  2. webSocketUrl を、capabilities から "webSocketUrl" という名前のプロパティを取得する結果とする。

  3. webSocketUrl が undefined である場合、戻る。

  4. Assert: webSocketUrl は true である。

  5. listener を、session が与えられたものとして start listening for a WebSocket connection した結果とする。

  6. webSocketUrl を、listener および sessionconstruct a WebSocket URL した結果に設定する。

  7. capabilities 上の "webSocketUrl" という名前のプロパティを webSocketUrl設定する

  8. sessionBiDi flag を true に設定する。

  9. "bidi" を flags に追加する。

実装は、HTTP Session ではない BiDi Session を クライアントが確立できるようにもするべきである。この場合、WebSocket サーバーへの URL は 帯域外で伝達される。これを許可する実装は supports BiDi-only sessions する。そのような実装が WebDriver セッションを開始する要求を 受け入れる準備ができた時点で、次を行わなければならない:

  1. null が与えられたものとして Start listening for a WebSocket connection する。

5. サンドボックス化されたスクリプト実行

自動化ツールに共通する要件は、文書の DOM に アクセスできるが、その文書を含む navigable 内で実行されるスクリプトによって DOM API に加えられた変更についての情報を持たないスクリプトを 実行することである。

BiDi sessionsandbox map を持ち、これは weak map であり、その キーは Window オブジェクト、値は文字列と SandboxWindowProxy オブジェクトの間の map である。

注: ここでのサンドボックスの定義は、既存実装の 振る舞いを成文化しようとするものである。これは、仕様では以前は内部的なものと みなされていた実装の一部、特にプラットフォームオブジェクトの内部状態 (これは通常、ブラウザーエンジンの主たる実装言語におけるネイティブオブジェクトとして 実装される)と ECMAScript から見える状態との区別を公開する。既存のサンドボックス 実装はエンジン内の低レベルで行われているため、実装が仕様のすべての詳細に 収束するには遅い過程になる可能性がある。当面の間、実装者には 仕様との差異について詳細な文書を提供することが推奨され、この機能の利用者には サンドボックス内で実行されるスクリプトがすべての実装で動作することを 明示的にテストすることが推奨される。

5.1. サンドボックスレルム

各サンドボックスは一意の ECMAScript Realm である。しかし、sandbox realm は Window realm 内の既存のプラットフォームオブジェクトへのアクセスを、 SandboxProxy オブジェクトを介して提供する。

name および navigable が与えられたとき、 get or create a sandbox realm するには:
  1. name が空文字列である場合、errorerror code invalid argument とともに返す。

  2. windownavigableactive window とする。

  3. sandbox mapwindow を含まない場合、sandbox map[window] を新しい map に設定する。

  4. sandboxessandbox map[window] とする。

  5. sandboxesname を含まない場合、 sandboxes[name] を navigablecreate a sandbox realm したものに設定する。

  6. data sandboxes[name] とともに success を返す。

windowcreate a sandbox realm するには:

sandbox realm の作成を定義する。これは window をラップする SandboxWindowProxy を返すことになる。

target realm が与えられたとき、get a sandbox name するには:

  1. realms maps を、sandbox map の値を取得するものとする。

  2. realms maps 内の各 realms map について:

    1. realms map 内の各 namerealm について:

      1. realmtarget realm である場合、name を返す。

  3. null を返す。

5.2. サンドボックスプロキシオブジェクト

SandboxProxy オブジェクトは、別の realm からの オブジェクトへのサンドボックス化されたアクセスを仲介する exotic object である。 Sandbox proxy objects は、次の制限を強制するように設計されている:

SandboxProxy interface object は存在しない。

SandboxProxy がどのように機能するかを詳細に定義する

unwrapped object を取得するには:
  1. objectSandboxProxy または SandboxWindowProxy である間、object をその wrapped object に設定する。

  2. object を返す。

5.3. SandboxWindowProxy

SandboxWindowProxy は、 Window オブジェクトを表す exotic object であり、それは SandboxProxy オブジェクトによってラップされる。これは、そのデータへのサンドボックス化された アクセスを Window global 内で提供する。

これがどのように機能するかを定義する。

6. ユーザーコンテキスト

user context は、remote end 内にある 0 個以上の top-level traversables の集合を表す。 各 user context は、 関連付けられた storage partition を持つため、remote end のデータは 異なる user contexts 間で共有されない。

これが user context の概念や storage との相互作用を形式的に定義する最良の方法であるかは不明である。

注: Infra 仕様は、user contexts と同じ概念を指すために "user agent" という用語を使用する。しかし、これは 複数の user contexts を持つ Web クライアント全体を意味する "user agent" という用語の用法と互換性がない。この違いは Web コンテンツからは 見えないが、WebDriver を介して観測されるため、この用語法の使用を避ける。

user contextuser context id を持ち、 これは user context の作成時に設定される一意の文字列である。

navigableassociated user context を持ち、これは user context である。

新しい top-level traversable が作成されると、その associated user contextset of user contexts 内の user context に設定される。

注: 場合によっては、 top-level traversable が作成されるときに user context が 仕様によって設定される。しかし、そのような要件が存在しない場合、 associated user context for a top-level traversable は implementation-defined である。

non-null の opener を持つ top-level traversables は、その opener と同じ associated user context を持つと指定すべきだろうか? これが既存実装で強制されているものか確認する必要がある。

child navigableassociated user context は、 その parentassociated user context である。

どの associated user context にもなっていない user context、 すなわちどの top-level traversable に対してもそうでないものは、empty user context である。

default user context は、user context であり、user context id "default" を持つ。

実装は set of user contexts を持ち、これは set of user contexts である。初期状態では、これは default user context を含む。

実装はいつでも、たとえばユーザー操作に応じて、新しい user contextsset of user contexts追加してもよい。

注: ここでいう「いつでも」には実装の 起動中も含まれるため、ある実装は常に set of user contexts 内に 複数のエントリーを持つことがある。

実装は、default user context を除き、任意の empty user contextset of user contexts からいつでも 削除してもよい。 ただし、そのような user contexts を削除する必要はない。 empty user contexts でない User contexts は、 set of user contexts から削除されてはならない。

BiDi sessionuser context to accept insecure certificates override map を持ち、これは user contexts と boolean の間の map である。

BiDi sessionuser context to proxy configuration map を持ち、これは user contextsproxy configuration の間の map である。

emulated network conditions struct は、次を持つ struct である:

BiDi sessionemulated network conditions を持ち、これは struct であり、 default network conditions という名前の item を持つ。これは emulated network conditions struct または null であり、また user context network conditions という名前の item を持つ。これは user contextsemulated network conditions struct の間の weak map であり、 さらに navigable network conditions という名前の item を持つ。これは navigablesemulated network conditions struct の間の weak map である。

user contextset of user contexts から削除されたとき、 remove user context subscriptions する。

remove user context subscriptions するには:

  1. active sessions 内の各 session について:

    1. subscriptions to removeset とする。

    2. sessionsubscriptions 内の各 subscription について:

      1. subscriptionuser context ids が、 navigableassociated user contextuser context id含む場合;

        1. navigableassociated user contextuser context id を、 subscriptionuser context ids から削除する

        2. subscriptionuser context ids が 空である場合:

          1. subscriptionsubscriptions to remove追加する

    3. subscriptions to removesessionsubscriptions から削除する

user context id が与えられたとき、 get user context するには:
  1. set of user contexts 内の各 user context について:

  2. user contextuser context iduser context id と等しい場合:

    1. user context を返す。

  3. null を返す。

user context ids が与えられたとき、get valid user contexts するには:

  1. result を空の set とする。

  2. user context ids の各 user context id について:

    1. user context を、user context idget user context したものに設定する。

    2. user context が null である場合、errorerror code no such user context とともに返す。

    3. user contextresult追加する

  3. result を返す。

7. モジュール

7.1. session モジュール

session モジュールは、remote end のステータスを監視するための コマンドおよびイベントを含む。

7.1.1. 定義

remote end definition

SessionCommand = (
    session.End //
    session.New //
    session.Status //
    session.Subscribe //
    session.Unsubscribe
    )

local end definition

SessionResult = (
    session.EndResult /
    session.NewResult /
    session.StatusResult /
    session.SubscribeResult /
    session.UnsubscribeResult
    )
session が与えられたとき、 end the session するには:
  1. sessionactive sessions から削除する。

  2. active sessionsである場合、 webdriver-active flag を false に設定する。

session が与えられたとき、cleanup the session するには:

  1. sessionClose the WebSocket connections する。

  2. set of user contexts 内の各 user context について:

    1. sessionuser context to accept insecure certificates override map[user context] を削除する

    2. sessionuser context to proxy configuration map[user context] を削除する

  3. sessionblocked request map 内の各 request id → (request, phase, response) について:

    1. "continue request"、request id および (response, "incomplete") で Resume する。

  4. sessionnetwork collectors 内の各 collector について:

    1. collector idcollectorcollector とする。

    2. collected network data 内の各 collected data について、collected data および collector idremove collector from data する。

  5. sessionスクリーンキャスト 記録マップ内の各screencast recordingについて:

    1. screencast recordingを与えて、スクリーンキャスト記録を停止する

    2. screencast recording除去するスクリーンキャスト記録マップから。

  6. active sessionsである場合、 cleanup remote end state する。

  7. 実装固有のクリーンアップステップを実行する。

cleanup remote end state するには。
  1. before request sent mapクリアする

  2. default cache behavior を "default" に設定する。

  3. navigable cache behavior mapクリアする

  4. 現在の remote end 設定で通常有効にされる 実装固有のリソースキャッシュを有効にするための、実装定義のステップを実行する。

7.1.2.

7.1.2.1. session.CapabilitiesRequest 型
session.CapabilitiesRequest = {
    ? alwaysMatch: session.CapabilityRequest,
    ? firstMatch: [*session.CapabilityRequest]
    }

session.CapabilitiesRequest 型は、セッションについて要求される capabilities を表す。

7.1.2.2. session.CapabilityRequest 型

remote end definition および local end definition

session.CapabilityRequest = {
  ? acceptInsecureCerts: bool,
  ? browserName: text,
  ? browserVersion: text,
  ? platformName: text,
  ? proxy: session.ProxyConfiguration,
  ? unhandledPromptBehavior: session.UserPromptHandler,
  Extensible
}

session.CapabilityRequest 型は、要求される capabilities の特定の集合を表す。

WebDriver BiDi は additional WebDriver capabilities を定義する。次の表は、各実装が WebDriver BiDi について サポートしなければならない capabilities を列挙する。

Capability: WebSocket URL
Key: "webSocketUrl"
Value type: boolean
Description: 現在のセッションが双方向接続をサポートすることを定義する。
"webSocketUrl" capability に対する additional capability deserialization algorithm は、パラメーター value を取り、次である:
  1. value が boolean でない場合、errorcode invalid argument とともに返す。

  2. data value とともに success を返す。

"webSocketUrl" capability に対する matched capability serialization algorithm は、パラメーター value を取り、次である:
  1. value が false である場合、data null とともに success を返す。

  2. data true とともに success を返す。

7.1.2.3. session.ProxyConfiguration 型

remote end definition および local end definition

session.ProxyConfiguration = {
   session.AutodetectProxyConfiguration //
   session.DirectProxyConfiguration //
   session.ManualProxyConfiguration //
   session.PacProxyConfiguration //
   session.SystemProxyConfiguration
}

session.AutodetectProxyConfiguration = (
   proxyType: "autodetect",
   Extensible
)

session.DirectProxyConfiguration = (
   proxyType: "direct",
   Extensible
)

session.ManualProxyConfiguration = (
   proxyType: "manual",
   ? httpProxy: text,
   ? sslProxy: text,
   ? session.SocksProxyConfiguration,
   ? noProxy: [*text],
   Extensible
)

session.SocksProxyConfiguration = (
   socksProxy: text,
   socksVersion: 0..255,
)

session.PacProxyConfiguration = (
   proxyType: "pac",
   proxyAutoconfigUrl: text,
   Extensible
)

session.SystemProxyConfiguration = (
   proxyType: "system",
   Extensible
)

7.1.2.4. session.UserPromptHandler 型

Remote end definition および local end definition

session.UserPromptHandler = {
    ? alert: session.UserPromptHandlerType,
    ? beforeUnload: session.UserPromptHandlerType,
    ? confirm: session.UserPromptHandlerType,
    ? default: session.UserPromptHandlerType,
    ? file: session.UserPromptHandlerType,
    ? prompt: session.UserPromptHandlerType,
    }

session.UserPromptHandler 型は、 user prompt handler の設定を表す。

注: file はファイルピッカーを処理する。"accept" および "dismiss" は ピッカーを閉じる。"ignore" はピッカーを開いたままにする。

7.1.2.5. session.UserPromptHandlerType 型

Remote end definition および local end definition

session.UserPromptHandlerType = "accept" / "dismiss" / "ignore";

session.UserPromptHandlerType 型は、 user prompt handler の振る舞いを表す。

7.1.2.6. session.Subscription 型
session.Subscription = text

session.Subscription 型は一意の subscription identifier を表す。

7.1.2.7. session.SubscribeParameters 型
session.SubscribeParameters = {
  events: [+text],
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

session.SubscribeParameters 型は、特定のイベント集合を 購読する要求を表す。

7.1.2.8. session.UnsubscribeByIDRequest 型
session.UnsubscribeByIDRequest = {
    subscriptions: [+session.Subscription],
    }

session.UnsubscribeByIDRequest 型は、subscription ID によって識別される event subscriptions を削除する要求を表す。

7.1.2.9. session.UnsubscribeByAttributesRequest 型
session.UnsubscribeByAttributesRequest = {
  events: [+text],
}

session.UnsubscribeByAttributesRequest 型は、 subscription attributes を用いて購読解除する要求を表す。

7.1.3. コマンド

7.1.3.1. session.status コマンド

session.status コマンドは、remote end が新しいセッションを 作成できる状態にあるかどうかについての情報を返し、 さらに実装固有の任意のメタ情報を含んでもよい。

これは static command である。

Command Type
session.Status = (
  method: "session.status",
  params: EmptyParams,
)
Return Type
session.StatusResult = {
  ready: bool,
  message: text,
}

session および command parameters が与えられたときの remote end steps は次である:

  1. body を、次のプロパティを持つ新しい map とする:

    "ready"
    remote endreadiness state
    "message"
    remote endreadiness state を説明する実装定義の文字列。
  2. data body とともに success を返す

7.1.3.2. session.new コマンド

session.new コマンドにより、新しい BiDi session を作成できる。

注: この方法で作成されたセッションは、 HTTP 経由ではアクセスできない。

これは static command である。

Command Type
session.New = (
    method: "session.new",
    params: session.NewParameters
    )

    session.NewParameters = {
    capabilities: session.CapabilitiesRequest
    }
Return Type
session.NewResult = {
  sessionId: text,
  capabilities: {
    acceptInsecureCerts: bool,
    browserName: text,
    browserVersion: text,
    platformName: text,
    setWindowRect: bool,
    userAgent: text,
    ? proxy: session.ProxyConfiguration,
    ? unhandledPromptBehavior: session.UserPromptHandler,
    ? webSocketUrl: text,
    Extensible
  }
}

session および command parameters が与えられたときの remote end steps は次である:

  1. session が null でない場合、error code session not created を持つ error を返す。

  2. 実装が何らかの理由で新しいセッションを開始できない場合、 error code session not created を持つ error を返す。

  3. flags を、"bidi" を含む set とする。

  4. capabilities json を、command parameters および flagsprocess capabilities することを試みた結果とする。

  5. capabilities を、capabilities jsonconvert a JSON-derived JavaScript value to an Infra value したものとする。

  6. session を、capabilities および flagscreate a session することを試みた結果とする。

  7. sessionBiDi flag を true に設定する。

    注: このセッションの connection は、 呼び出し元によって現在の connection に設定される。

  8. body を、session.NewResult 生成規則に一致する 新しい map とし、sessionId フィールドを sessionsession ID に設定し、 capabilities フィールドを capabilities に設定する。

  9. data body とともに success を返す。

7.1.3.3. session.end コマンド

session.end コマンドは現在の セッションを終了する。

Command Type
session.End = (
    method: "session.end",
    params: EmptyParams
    )

Return Type
session.EndResult = EmptyResult

session および command parameters が与えられたときの remote end steps は次である:

  1. sessionEnd the session する。

  2. data null とともに success を返し、並列に次の ステップを実行する:

    1. このコマンドへのレスポンスで Send a WebSocket message ステップが呼び出されるまで待つ。

      これは かなり不正確な表現だが、意図としては接続の シャットダウンを開始する前にコマンドへのレスポンスを送信する、ということが明確であることを期待している。

    2. sessionCleanup the session する。

7.1.3.4. session.subscribe コマンド

session.subscribe コマンドは、特定のイベントを グローバルに、または navigables の集合に対して有効にする。

これは realms でも機能するよう 一般化する必要がある。

Command Type
session.Subscribe = (
    method: "session.subscribe",
    params: session.SubscribeParameters
    )
Return Type
session.SubscribeResult = {
    subscription: session.Subscription,
    }
session および command parameters を伴う remote end steps は次である:
  1. event names を空の set とする。

  2. command parameters["events"] 内の各エントリー name について、 event names を、event names と、 nameobtain a set of event names することを 試みた結果との union とする。

  3. input user context ids を、command parameters[userContexts] で create a set したものとする。

  4. input context ids を、command parameters[contexts] で create a set したものとする。

  5. input user context ids が空でなく、かつ input context ids が空でない場合、 errorerror code invalid argument とともに返す。

  6. subscription navigablesset とする。

  7. top-level traversable context idsset とする。

  8. input context ids が空でない場合:

    1. navigables を、 input context idsget valid navigables by ids することを 試みた結果とする。

    2. subscription navigables を、navigablesget top-level traversables したものに設定する。

    3. subscription navigables 内の各 navigable について:

      1. navigablenavigable idtop-level traversable context ids追加する

  9. そうでなく、input user context ids が空でない場合:

    1. input user context ids の各 user context id について反復する:

      1. user context を、user context idget user context したものとする。

      2. user context が null である場合、errorerror code no such user context とともに返す。

      3. user context である associated user context を持つ、すべての top-level traversables のリスト内の 各 top-level traversable について反復する:

        1. top-level traversablesubscription navigables追加する

  10. そうでなければ、subscription navigables を、remote end 内のすべての top-level traversablesset に設定する。

  11. subscription を、 subscription idUUID の文字列表現に設定され、 event namesevent names に設定され、 top-level traversable idstop-level traversable context ids に設定され、 user context idsinput user context ids に設定された subscription とする。

  12. subscribe step events を新しい map とする。

  13. event names 内の各 event name について:

    1. event name event name を持つ eventremote end subscribe steps を定義していない場合、 continue する。

    2. existing navigables を、session および event nameset of top-level traversables for which an event is enabled したものとする。

    3. subscribe step events[event name] を、 subscription navigablesexisting navigablesdifference に設定する。

  14. subscriptionsessionsubscriptions に追加する。

  15. subscriptionsubscription idsessionknown subscription ids に追加する。

  16. subscribe step events を、キー event name one および event name two を持つ 2 つのエントリーが与えられたときの次の less than アルゴリズムを用いて昇順に並べ替える:

    1. event one を、名前 event name one を持つ event とする

    2. event two を、名前 event name two を持つ event とする

    3. event onesubscribe priorityevent two の subscribe priority より小さい場合は true を返し、そうでなければ false を返す。

  17. subscriptionglobal である場合、include global を true とし、 そうでなければ include global を false とする。

  18. subscribe step events 内の各 event namenavigables について:

    1. event name event name を持つ event について、 sessionnavigables および include global が与えられたものとして remote end subscribe steps を実行する。

  19. body を、session.SubscribeResult 生成規則に一致する 新しい map とし、 subscription フィールドを subscriptionsubscription id に設定する。

  20. data body とともに success を返す。

7.1.3.5. session.unsubscribe コマンド

session.unsubscribe コマンドは、イベントを グローバルに、または navigables の集合に対して無効にする。

これは realms でも機能するように 一般化する必要がある。

コマンド型
session.Unsubscribe = (
    method: "session.unsubscribe",
    params: session.UnsubscribeParameters,
    )

    session.UnsubscribeParameters = session.UnsubscribeByAttributesRequest / session.UnsubscribeByIDRequest
戻り値型
session.UnsubscribeResult = EmptyResult
session および command parameters を伴う remote end steps は次である:
  1. command parameters が "subscriptions" を含まない場合:

    注: この条件は、 command parameters が session.UnsubscribeByAttributesRequest 生成規則に一致することを意味する。

    1. event names を空の set とする。

    2. command parameters["events"] 内の各エントリー name について、 event names を、 event names と、nameobtain a set of event names することを 試みた結果との union とする。

    3. new subscriptionslist とする。

    4. matched eventsset とする。

    5. sessionsubscriptions の各 subscription について:

      1. subscriptionevent namesevent namesintersection が空の set である場合:

        1. subscriptionnew subscriptions追加する

        2. Continue する。

      2. subscriptionglobal でない場合:

        1. subscriptionnew subscriptions追加する

        2. Continue する。

      3. subscription event names を、subscriptionevent namesclone とする。

      4. event names の各 event name について:

        1. subscription event namesevent name含む場合:

          1. event namematched events追加する

          2. event namesubscription event names から削除する

      5. subscription event names が空でない場合:

        1. cloned subscription を、 subscription idsubscriptionsubscription id に設定され、 event namessubscription event names を含む新しい set に設定された subscription とする。

        2. cloned subscriptionnew subscriptions追加する

    6. matched eventsevent names等しくない場合、errorerror code invalid argument とともに返す。

    7. sessionsubscriptionsnew subscriptions に設定する。

  2. そうでなければ:

    1. subscriptions を、command parameters[subscriptions] で create a set したものとする。

    2. unknown subscription ids を、subscriptionssessionknown subscription ids の間の difference とする。

    3. unknown subscription ids が空でない場合:

      1. errorerror code invalid argument とともに返す。

    4. subscriptions to remove を空の set とする。

    5. sessionsubscriptions 内の各 subscription について:

      1. subscriptionssubscriptionsubscription id含む場合:

        1. subscriptionsubscriptions to remove追加する

    6. sessionknown subscription ids を、 sessionknown subscription idssubscriptions の間の difference に設定する。

    7. subscriptions to remove 内の各項目を sessionsubscriptions から削除する

  3. data null とともに success を返す。

7.2. browser モジュール

browser モジュールは、 remote end のブラウザープロセスを管理するためのコマンドを含む。

7.2.1. 定義

remote end definition

BrowserCommand = (
    browser.Close //
    browser.CreateUserContext //
    browser.GetClientWindows //
    browser.GetUserContexts //
    browser.RemoveUserContext //
    browser.SetClientWindowState //
    browser.SetDownloadBehavior
    )

local end definition

BrowserResult = (
    browser.CloseResult /
    browser.CreateUserContextResult /
    browser.GetClientWindowsResult /
    browser.GetUserContextsResult /
    browser.RemoveUserContextResult /
    browser.SetClientWindowStateResult /
    browser.SetDownloadBehaviorResult
    )

7.2.2. ウィンドウ

top-level traversable は単一の client window に関連付けられる。これは、その top-level traversableactive document を、その visibility state が "visible" であるときにレンダリングするために使用される viewport を含む矩形領域を表し、 traversable の表示に関連付けられたブラウザー固有のユーザーインターフェイス要素 (例: URL バー、ツールバー、または OS のウィンドウ装飾)も表す。

client windowclient window id を持ち、 これはそのウィンドウを一意に識別する文字列である。

client windowx-coordinate を持ち、これは web-exposed screen area の左端とウィンドウの左端との間の CSS ピクセル数、または特定のウィンドウについてそれが意味をなさない場合は ゼロである。

client windowy-coordinate を持ち、これは web-exposed screen area の上端とウィンドウの上端との間の CSS ピクセル数、または特定のウィンドウについてそれが意味をなさない場合は ゼロである。

client windowwidth を持ち、これは CSS ピクセルにおけるウィンドウ矩形の幅である。

client windowheight を持ち、これは CSS ピクセルにおけるウィンドウ矩形の高さである。

windowmaximize the client window を行うには、実装はプラットフォームにおける window の最大化の概念に対応する ステップを実行するか、 windowx-coordinate が可能な限り 0 に近くなり、 その y-coordinate が可能な限り 0 に近くなり、 その widthweb-exposed screen area の幅に可能な限り近くなり、その heightweb-exposed screen area の高さに可能な限り近くなるように window を配置するべきである。これらのいずれかの選択肢がサポートされる場合、 maximize client window is supported である。

windowminimize the client window を行うには、実装はプラットフォームにおける window の最小化の概念に対応する ステップを実行するか、 そうでなければ window に関連付けられた top-level traversables 内のすべての active documentsvisibility state が "hidden" になり、かつ windowwidth および height がどちらも可能な限り 0 に近くなるように、 window を隠すべきである。これらのいずれかの選択肢が サポートされる場合、minimize client window is supported である。

windowrestore the client window を行うには、実装はそれが プラットフォーム定義の最大化状態でも、プラットフォーム定義の 最小化状態でもなく、かつ window に関連付けられた 1 つ以上の top-level traversable が存在する場合は、そのうち少なくとも 1 つが "visible" 状態の active document を持つことを保証するべきである。 これがサポートされる場合、restore client window is supported である。

window が与えられたとき、get the client window state するには:

  1. documents を空の list とする。

  2. visible documents を空の list とする。

  3. top-level traversable traversable について:

    1. traversableclient windowwindow でない場合、 continue する。

    2. documenttraversableactive document とする。

    3. documentdocuments追加する

    4. documentvisibility state が "visible" である場合、 documentvisible documents追加する

  4. visible documents 内の各 document について:

    1. documentfullscreen element が null でない場合、 "fullscreen" を返す。

  5. visible documentsであるが documentsでない場合、または window がその他の OS 固有の 最小化状態にある場合、"minimized" を返す。

    注: これは通常、必ずしもそうとは限らないが、 windowwidth および height が 0 に等しいことを意味する。

  6. window が OS 固有の最大化状態にある場合、 "maximized" を返す。

    注: これは通常、必ずしもそうとは限らないが、 windowwidthweb-exposed screen area の幅に等しく、 windowheightweb-exposed screen area の高さに等しいことを意味する。

  7. "normal" を返す。

window および state が与えられたとき、set the client window state するには:

  1. current state を、windowget the client window state したものとする。

  2. current state が "fullscreen"、"maximized"、または "minimized" であり、かつ state と等しい場合、data null とともに success を返す。

  3. 次の条件と関連するステップのリストにおいて、 関連する条件が true である最初のステップ集合を実行する:

    "fullscreen"
    fullscreen is supported でない場合、errorerror code unsupported operation とともに返す。
    "normal"
    window について restore client window is supported でない場合、errorerror code unsupported operation とともに返す。
    "maximize"
    window について maximize client window is supported でない場合、errorerror code unsupported operation とともに返す。
    "minimize"
    window について minimize client window is supported でない場合、errorerror code unsupported operation とともに返す。
  4. documents を空の list とする。

  5. top-level traversable traversable について:

    1. traversable に関連付けられた client windowwindow でない場合、 continue する。

    2. documenttraversableactive document とする。

    3. documentdocuments に追加する。

  6. documentsである場合、 errorerror code no such client window とともに返す。

  7. current state が "fullscreen" である場合:

    1. documents 内の各 document について:

      1. documentFully exit fullscreen する。

        注: これは、 fullscreen でない window 内の文書に対しては何もしない。

  8. current state が "maximized" または "minimized" である場合:

    1. windowRestore the client window する。

  9. state の値について分岐する:

    "fullscreen"
    1. documents 内の各 document について:

      1. documentvisibility state が "visible" である場合、 documentdocument elementfullscreen an element する。

      2. Break する。

    "maximize"
    1. windowMaximize the client window する。
    "minimize"
    1. windowMinimize the client window する。
  10. data null とともに success を返す。

7.2.3.

7.2.3.1. browser.ClientWindow 型
browser.ClientWindow = text;

browser.ClientWindowclient window を一意に識別する。

7.2.3.2. browser.ClientWindowInfo 型
browser.ClientWindowInfo = {
  active: bool,
  clientWindow: browser.ClientWindow,
  height: js-uint,
  state: "fullscreen" / "maximized" / "minimized" / "normal",
  width: js-uint,
  x: js-int,
  y: js-int,
}

browser.ClientWindowInfo 型は、 client window のプロパティを表す。

client window が与えられたとき、 get the client window info するには:
  1. client window id を、client windowclient window id とする。

  2. state を、client windowget the client window state したものとする。

  3. client window がオペレーティングシステムから送られるキーボード入力を 受け取ることができる場合、active を true とし、そうでなければ active を false とする。

    注: これは、client window である client window を持つ top-level traversablesystem focus を持つことを意味する場合もあれば、 ブラウザー自体のユーザーインターフェイスが現在フォーカスを持つことを意味する場合もある。

  4. client window info を、 browser.ClientWindowsInfo 生成規則に一致する map とし、 clientWindow フィールドを client window id に、state フィールドを state に、x フィールドを client windowx-coordinate に、y フィールドを client windowy-coordinate に、width フィールドを client windowwidth に、height フィールドを client windowheight に、active フィールドを active に設定したものとする。

  5. client window info を返す

7.2.3.3. browser.UserContext 型
browser.UserContext = text;

browser.UserContextuser context を一意に識別する。

7.2.3.4. browser.UserContextInfo 型
browser.UserContextInfo = {
    userContext: browser.UserContext
    }

browser.UserContextInfo 型は user context のプロパティを表す。

7.2.4. コマンド

7.2.4.1. browser.close コマンド

browser.close コマンドは、すべての WebDriver セッションを終了し、remote browser instance 内の自動化状態をクリーンアップする。

コマンド型
browser.Close = (
    method: "browser.close",
    params: EmptyParams,
    )
戻り値型
browser.CloseResult = EmptyResult
session および command parameters を伴う remote end steps は次である:
  1. sessionEnd the session する。

  2. active sessionsでない場合、 実装は unable to close browsererror code を持つ error を返してもよく、その後 次のステップを並列に実行する:

    1. このコマンドへのレスポンスで Send a WebSocket message ステップが呼び出されるまで待つ。

    2. sessionCleanup the session する。

    注: ブラウザーが複数の自動化 セッションを持つ場合の挙動は、現在未指定である。任意のセッションが ブラウザーを閉じられるのか、最後に開かれたセッションだけが実際に ブラウザーを閉じられるのか、あるいは最初に開始されたセッションだけが可能なのかもしれない。この挙動は、 この仕様の将来のバージョンで完全に指定されるかもしれない。

  3. active sessions 内の各 active session について:

    1. active sessionEnd the session する。

    2. active sessionCleanup the session する

  4. data null とともに success を返し、次のステップを並列に実行する。

    1. このコマンドへのレスポンスで Send a WebSocket message ステップが呼び出されるまで待つ。

    2. sessionCleanup the session する。

    3. top-level traversables を、どれでも Close する。ただし prompting to unload しない。

    4. 自動化下の remote end に関連付けられたリソースを クリーンアップするための実装定義のステップを実行する。

      注: たとえばこれには、自動化下のブラウザーに関連付けられた OS レベルのプロセスを正常にシャットダウンすること、remote end が自動化下にある間に作成した ユーザープロファイルデータなどの一時状態を削除すること、または WebSocket Listener をシャットダウンすることが 含まれ得る。ブラウザーおよびオペレーティングシステムの違いにより、 local ends がここで依存できる正確な不変条件を 詳細に指定することはできない。

7.2.4.2. browser.createUserContext コマンド

browser.createUserContext コマンドは user context を作成する。

コマンド型
browser.CreateUserContext = (
  method: "browser.createUserContext",
  params: browser.CreateUserContextParameters,
)

browser.CreateUserContextParameters = {
  ? acceptInsecureCerts: bool,
  ? proxy: session.ProxyConfiguration,
  ? unhandledPromptBehavior: session.UserPromptHandler
}
戻り値型
browser.CreateUserContextResult = browser.UserContextInfo

session および command parameters を伴う remote end steps は次である:

  1. user context を新しい user context とする。

  2. command parameters が "acceptInsecureCerts" を含む場合:

    注: "acceptInsecureCerts" が 設定されている場合、それは accept insecure TLS flag の挙動を上書きする。

    1. acceptInsecureCertscommand parameters["acceptInsecureCerts"] とする:

    2. acceptInsecureCerts が true であり、endpoint node が insecure TLS connections の受け入れをサポートしていない場合、 unsupported operationerror code を持つ error を返す。

    3. sessionuser context to accept insecure certificates override map[user context] を acceptInsecureCerts設定する

  3. command parameters が "unhandledPromptBehavior" を含む場合、 unhandled prompt behavior overrides map[user context] を command parameters["unhandledPromptBehavior"] に設定する

  4. command parameters が "proxy" を含む場合:

    1. proxy configurationcommand parameters["proxy"] とする。

    2. remote enduser context ごとに proxy settings を構成できない場合、 または proxy configuration で proxy を構成できない場合、 unsupported operationerror code を持つ error を返す。

    3. sessionuser context to proxy configuration map[user context] を proxy configuration設定する

  5. user contextset of user contexts追加する

  6. user context info を、 browser.UserContextInfo 生成規則に一致する map とし、 userContext フィールドを user contextuser context id に設定したものとする。

  7. data user context info とともに success を返す。

7.2.4.3. browser.getClientWindows コマンド

browser.getClientWindows コマンドは、 client window のリストを返す。

コマンド型
browser.GetClientWindows = (
    method: "browser.getClientWindows",
    params: EmptyParams,
    )
戻り値型
browser.GetClientWindowsResult = {
    clientWindows: [ * browser.ClientWindowInfo]
    }

remote end steps は次である:

  1. client window ids を空の set とする。

  2. client windows を空の list とする。

  3. top-level traversable traversable について:

    1. client window を、traversable に関連付けられた client window とする

    2. client window id を、client windowclient window id とする。

    3. client window idsclient window id含む場合、continue する。

    4. client window idclient window ids追加する

    5. client window info を、client windowget the client window info したものとする。

    6. client window infoclient windows追加する

  4. result を、 browser.GetClientWindowsResult 生成規則に一致する map とし、 clientWindows フィールドを client windows に設定したものとする。

  5. data result とともに success を返す。

7.2.4.4. browser.getUserContexts コマンド

browser.getUserContexts コマンドは、 user context のリストを返す。

コマンド型
browser.GetUserContexts = (
    method: "browser.getUserContexts",
    params: EmptyParams,
    )
戻り値型
browser.GetUserContextsResult = {
    userContexts: [ + browser.UserContextInfo]
    }

remote end steps は次である:

  1. user contexts を空の list とする。

  2. set of user contexts 内の各 user context について:

    1. user context info を、 browser.UserContextInfo 生成規則に一致する map とし、 userContext フィールドを user contextuser context id に設定したものとする。

    2. user context infouser contexts追加する

  3. result を、 browser.GetUserContextsResult 生成規則に一致する map とし、 userContexts フィールドを user contexts に設定したものとする。

  4. data result とともに success を返す。

7.2.4.5. browser.removeUserContext コマンド

browser.removeUserContext コマンドは、 beforeunload ハンドラーを実行せずに、user context およびその中のすべての navigables を閉じる。

コマンド型
browser.RemoveUserContext = (
    method: "browser.removeUserContext",
    params: browser.RemoveUserContextParameters
    )

    browser.RemoveUserContextParameters = {
    userContext: browser.UserContext
    }
戻り値型
browser.RemoveUserContextResult = EmptyResult

command parameters を伴う remote end steps は次である:

  1. user context idcommand parameters["userContext"] とする。

  2. user context id"default" である場合、errorerror code invalid argument とともに返す。

  3. user context を、user context idget user context したものに設定する。

  4. user context が null である場合、errorerror code no such user context とともに返す。

  5. top-level traversable navigable について:

    1. navigableassociated user contextuser context である場合:

      1. navigable閉じる。ただし prompting to unload しない。

  6. user contextset of user contexts から削除する

  7. data null とともに success を返す。

7.2.4.6. browser.setClientWindowState コマンド

browser.setClientWindowState コマンドは、 client window の寸法を設定する。

コマンド型
browser.SetClientWindowState = (
    method: "browser.setClientWindowState",
    params: browser.SetClientWindowStateParameters
    )

    browser.SetClientWindowStateParameters = {
    clientWindow: browser.ClientWindow,
    (browser.ClientWindowNamedState // browser.ClientWindowRectState)
    }

    browser.ClientWindowNamedState = (
    state: "fullscreen" / "maximized" / "minimized"
    )

    browser.ClientWindowRectState = (
    state: "normal",
    ? width: js-uint,
    ? height: js-uint,
    ? x: js-int,
    ? y: js-int,
    )
戻り値型
browser.SetClientWindowStateResult = browser.ClientWindowInfo

session および command parameters を伴う remote end steps は次である:

  1. 実装が client window state の設定をまったくサポートしていない場合、 unsupported operationerror code を持つ error を返す。

  2. command parameters["clientWindow"] の client window id を持つ client window が存在する場合、client window をその client window とする。 そうでなければ、no such client windowerror code を持つ error を返す。

  3. client window および command parameters["state"] で set the client window state することを試みる

  4. command parameters["state"] が "normal" である場合:

    1. command parameters が "x" を含み、かつ実装が client windows の位置指定をサポートする場合、client windowx-coordinate を、 command parameters["x"] に可能な限り近い値に設定する。

    2. command parameters が "y" を含み、かつ実装が client windows の位置指定をサポートする場合、client windowy-coordinate を、 command parameters["y"] に可能な限り近い値に設定する。

    3. command parameters が "width" を含み、かつ実装が client windows のリサイズをサポートする場合、 client windowwidthcommand parameters["width"] に可能な限り近い値に設定する。

    4. command parameters が "width" を含み、かつ実装が client windows のリサイズをサポートする場合、 client windowwidthcommand parameters["width"] に可能な限り近い値に設定する。

  5. client window info を、client windowget the client window info したものとする。

  6. data client window info とともに success を返す。

注: 単純化のため、これはすべての client window 操作を 同期的なものとしてモデル化している。したがって、返される client window の寸法は、 window が新しい状態に到達した後のものになることが期待される。

7.2.4.7. browser.setDownloadBehavior コマンド

download behavior struct は、次を持つ struct である:

remote enddownload behavior を持ち、これは struct であり、 default download behavior という名前の item を持つ。これは download behavior struct または null であり、さらに user context download behavior という名前の item を持つ。これは user contextsdownload behavior struct の間の weak map である。

コマンド型
browser.SetDownloadBehavior = (
  method: "browser.setDownloadBehavior",
  params: browser.SetDownloadBehaviorParameters
)

browser.SetDownloadBehaviorParameters = {
  downloadBehavior: browser.DownloadBehavior / null,
  ? userContexts: [+browser.UserContext]
}

browser.DownloadBehavior = {
  (
    browser.DownloadBehaviorAllowed //
    browser.DownloadBehaviorDenied
  )
}

browser.DownloadBehaviorAllowed = (
  type: "allowed",
  destinationFolder: text
)

browser.DownloadBehaviorDenied = (
  type: "denied"
)
戻り値型
browser.SetDownloadBehaviorResult = EmptyResult
navigable が与えられたとき、 get download behavior するには:
  1. user contextnavigableassociated user context とする。

  2. download behavioruser context download behavioruser context含む場合、download behavioruser context download behavior[user context] を返す。

  3. download behaviordefault download behavior を返す。

session および command parameters を伴う remote end steps は次である:

  1. command parameters["downloadBehavior"] が null である場合、 download behavior を null とする。

  2. そうでなければ:

    1. command parameters["downloadBehavior"]["type"] が "allowed" である場合、allowed を true とし、そうでなければ allowed を false とする。

    2. command parameters["downloadBehavior"] が "destinationFolder" を含む場合、destinationFoldercommand parameters["downloadBehavior"]["destinationFolder"] とし、 そうでなければ destinationFolder を null とする。

    3. download behavior を、allowedallowed に設定され、 destinationFolderdestinationFolder に設定された download behavior struct とする。

  3. 実装が要求された download behavior をサポートしていない場合、 errorerror code unsupported operation とともに返す。

  4. command parametersuserContexts フィールドが存在する場合:

    1. user contexts を、 command parameters["userContexts"] で get valid user contexts することを試みた結果とする。

    2. user contexts の各 user context について:

      1. download behavior が null である場合、user contextdownload behavioruser context download behavior から削除する

      2. そうでなければ、download behavioruser context download behavior[user context] を download behavior設定する

  5. そうでなければ、download behaviordefault download behaviordownload behavior に設定する。

  6. data null とともに success を返す。

7.3. browsingContext モジュール

browsingContext モジュールは、navigables に関係するコマンドおよび イベントを含む。

注: 歴史的な理由により、このモジュールは navigable ではなく browsingContext と呼ばれ、プロトコルは navigables を指すために context という用語を使用する。これは特にコマンドおよび レスポンスパラメーター内のフィールドとして用いられる。

ナビゲーションの進行状況は、次の items を持つ、 不変の struct WebDriver BiDi navigation status を用いて伝達される:

id
ナビゲーションの navigation id、または進行する前にナビゲーションが 取り消された場合は null。
status
"canceled"、 "pending"、または "complete" のいずれかであるステータスコード。
url
ナビゲーションで読み込まれている URL
suggestedFilename
ナビゲーションがダウンロードである場合は提案されるファイル名、そうでなければ null。
downloadedFilepath
ナビゲーションが完了済みのダウンロードであり、ダウンロードされたファイルが 利用可能である場合は、そのダウンロードファイルの絶対ファイルパス、そうでなければ null。
downloadResponse
ナビゲーションがダウンロードである場合は、response、 そうでなければ null。

7.3.1. 定義

remote end definition

BrowsingContextCommand = (
  browsingContext.Activate //
  browsingContext.CaptureScreenshot //
  browsingContext.Close //
  browsingContext.Create //
  browsingContext.GetTree //
  browsingContext.HandleUserPrompt //
  browsingContext.LocateNodes //
  browsingContext.Navigate //
  browsingContext.Print //
  browsingContext.Reload //
  browsingContext.SetBypassCSP //
  browsingContext.SetViewport //
  browsingContext.StartScreencast //
  browsingContext.StopScreencast //
  browsingContext.TraverseHistory
)

local end definition

BrowsingContextResult = (
  browsingContext.ActivateResult /
  browsingContext.CaptureScreenshotResult /
  browsingContext.CloseResult /
  browsingContext.CreateResult /
  browsingContext.GetTreeResult /
  browsingContext.HandleUserPromptResult /
  browsingContext.LocateNodesResult /
  browsingContext.NavigateResult /
  browsingContext.PrintResult /
  browsingContext.ReloadResult /
  browsingContext.SetBypassCSPResult /
  browsingContext.SetViewportResult /
  browsingContext.StartScreencastResult /
  browsingContext.StopScreencastResult /
  browsingContext.TraverseHistoryResult
)

BrowsingContextEvent = (
  browsingContext.ContextCreated //
  browsingContext.ContextDestroyed //
  browsingContext.DomContentLoaded //
  browsingContext.DownloadEnd //
  browsingContext.DownloadWillBegin //
  browsingContext.FragmentNavigated //
  browsingContext.HistoryUpdated //
  browsingContext.Load //
  browsingContext.NavigationAborted //
  browsingContext.NavigationCommitted //
  browsingContext.NavigationFailed //
  browsingContext.NavigationStarted //
  browsingContext.UserPromptClosed //
  browsingContext.UserPromptOpened
)

remote enddevice pixel ratio overrides を持ち、これは navigables と device pixel ratio overrides の間の weak map である。 これは初期状態では空である。

注: この map は最後のセッションが終了しても クリアされない。すなわち device pixel ratio overrides はどの WebDriver セッションよりも長く存続する。

viewport dimensions は、次を持つ struct である:

viewport configuration は、次を持つ struct である:

unhandled prompt behavior struct は、次を持つ struct である:

remote endviewport overrides map を持ち、これは user contextsviewport configuration の間の weak map である。

remote endlocale overrides map を持ち、これは navigables または user contexts と string の間の weak map である。

screen settingsstruct であり、 height という名前の item を持つ。これは integer であり、 width という名前の item を持つ。これは integer であり、 x という名前の item を持つ。これは integer であり、 y という名前の item を持つ。これは integer である。

remote endscreen settings overrides を持ち、これは struct であり、 user context screen settings という名前の item を持つ。これは user contextsscreen settings の間の weak map であり、 さらに navigable screen settings という名前の item を持つ。これは navigablesscreen settings の間の weak map である。

remote endtimezone overrides map を持ち、これは navigables または user contexts と string の間の weak map である。

remote endunhandled prompt behavior overrides map を持ち、これは user contextsunhandled prompt behavior struct の間の weak map である。

remote endscripting enabled overrides map を持ち、これは navigables または user contexts と boolean の間の weak map である。

リモートエンドは、ダウンロード ID マップを持つ。これは responseとダウンロード ID の間の weak map である。これは初期状態では空である。

スクリーンキャストストリームは、 トップレベル辿可能のビューポートの抽象ストリームであり、映像トラック から成り、これはトップレベル辿可能の文書のビューポートのレンダリングされた視覚出力を含み、 また任意で、トップレベル辿可能の文書の音声出力を含む 音声トラックを含む。

BiDi セッションは、スクリーンキャスト 記録マップを持つ。これはマップであり、 そのキーはUUID、値はスクリーンキャスト記録である。 これは構造体であり、 streamという名前の 項目を持ち、これはスクリーンキャストストリームであり、 pathという名前の 項目を持ち、これは文字列であり、 stateという名前の 項目を持ち、これは "recording", "stopping", "stopped" のいずれかであり、 writeErrorという名前の 項目を持ち、これは文字列または null である。

スクリーンキャスト記録 recordingmime type が与えられたとき、スクリーンキャスト記録を開始するには:
  1. 以下の手順を並列に実行する:

    1. mime typeを用いてrecordingstreamの符号化を開始し、 符号化済みデータの連続するチャンクをバイト シーケンスとして生成する。 recordingstateが "recording" である間、 実装定義の間隔で新しいチャンクを生成する。

    2. recordingについて生成された各チャンク bytes について、以下の手順を実行する:

      1. bytesrecordingpathにあるファイルに追加する。 これが失敗した場合:

        1. recordingwriteErrorを、 書き込み失敗を説明する実装定義の文字列に設定する。

        2. recordingが与えられたとして、スクリーンキャスト記録を停止する

スクリーンキャスト記録 recording が与えられたとき、スクリーンキャスト記録を停止するには:
  1. recordingstateが "recording" でないなら、 戻る。

  2. recordingstateを "stopping" に設定する。

  3. recordingについて新しいチャンクを生成することを停止し、残っている符号化済み データを最終チャンクとしてフラッシュし(スクリーンキャスト 記録を開始するの場合と同様に処理される)、 recordingstreamからのキャプチャを停止し、 その 映像トラックと、存在する場合はその 音声トラックを解放し、その後 recordingstateを "stopped" に設定する。

  4. recordingstateが "stopped" になるまで待つ。

7.3.2.

7.3.2.1. browsingContext.BrowsingContext 型

remote end definition および local end definition

browsingContext.BrowsingContext = text;

navigable は、関連付けられた navigable id を持つ。 これは、その navigable を一意に識別する string である。これは navigable が作成されるときに暗黙的に設定される。関連付けられた WebDriver window handle を持つ navigables については、navigable idwindow handle と同じでなければならない。

navigable は、associated storage partition も持つ。 これは、その navigable がデータを永続化するために使用する storage partition である。

navigable は、関連付けられた original opener も持つ。 これは、その navigable を開かせた navigable または null であり、初期状態では null に設定される。

navigable id が与えられたとき、 get a navigable するには:
  1. navigable id が null である場合、data null とともに success を返す。

  2. navigable id navigable id を持つ navigable が存在しない場合、 no such frameerror code を持つ error を返す

  3. navigable を、id navigable id を持つ navigable とする。

  4. data navigable とともに success を返す。

7.3.2.2. browsingContext.Info 型

local end definition

browsingContext.InfoList = [*browsingContext.Info]

browsingContext.Info = {
  children: browsingContext.InfoList / null,
  clientWindow: browser.ClientWindow,
  context: browsingContext.BrowsingContext,
  originalOpener: browsingContext.BrowsingContext / null,
  url: text,
  userContext: browser.UserContext,
  ? parent: browsingContext.BrowsingContext / null,
}

browsingContext.Info 型は navigable のプロパティを表す。

navigable が与えられたとき、 get the child navigables するには:

TODO: これが文書順のリストを返すようにする

  1. child navigables を、navigablechild navigable であるすべての navigables を含む set とする。

  2. child navigables を返す。

navigablemax depth および include parent id が与えられたとき、 get the navigable info するには:
  1. navigable id を、navigablenavigable id とする。

  2. parent navigablenavigableparent とする。

  3. parent navigable が null でない場合、parent idparent navigablenavigable id とする。 そうでなければ、 parent id を null とする。

  4. documentnavigableactive document とする。

  5. url を、documentURL が与えられたものとして URL serializer を実行した結果とする。

    注: これは URL の fragment component を含む。

  6. child infos を null とする。

  7. max depth が null である、または max depth が 0 より大きい場合:

    1. child navigables を、navigable が与えられたものとして get the child navigables したものとする。

    2. max depth が null でない場合、child depthmax depth - 1 とし、そうでなければ null とする。

    3. child infos を空の list に設定する。

    4. child navigables の各 child navigable について:

      1. info を、 child navigablechild depth および false が与えられたものとして get the navigable info した結果とする。

      2. infochild infos に追加する

  8. user contextnavigableassociated user context とする。

  9. navigableoriginal opener が null でない場合、 opener idnavigableoriginal openernavigable id とし、 そうでなければ null とする。

  10. top-level traversablenavigabletop-level traversable とする。

  11. client window id を、top-level traversable に関連付けられた client windowclient window id とする。

  12. navigable info を、 browsingContext.Info 生成規則に一致する map とし、context フィールドを navigable id に、include parent idtrue である場合は parent フィールドを parent id に設定し、そうでなければ未設定とし、 url フィールドを url に、userContext フィールドを user contextuser context id に、originalOpener フィールドを opener id に、children フィールドを child infos に、 clientWindow フィールドを client window id に設定したものとする。

  13. navigable info を返す。

navigablerequestwait condition、および任意で history handling(デフォルト: "default")と ignore cache(デフォルト: false)が 与えられたとき、await a navigation するには:
  1. navigation id を、真のランダムまたは擬似ランダムな数値に基づく UUID の文字列表現とする。

  2. navigable を resource requestnavigate し、source Document として navigableactive document を用い、 navigation id navigation id および history handling behavior history handling を用いる。ignore cache が true である場合、 そのナビゲーションは HTTP cache からリソースを読み込んではならない。

    ignore cache flag がどのように機能するかを適切に指定する必要がある。これは、リソースの最初の読み込みだけが cache をバイパスするのか (すなわち、最初に cache をクリアして通常どおり進むのと同様であるか)、 または HTML parser によって直接読み込まれないリソース (例: scripts または stylesheets によって開始される読み込み)も cache をバイパスするのかを考慮する必要がある。

  3. (event received, navigation status) を、 «"navigation started", "navigation failed", "fragment navigated"» および navigation id が与えられたものとして await したものとする。

  4. Assert: navigation statusidnavigation id である。

  5. navigation statusstatus が "complete" である場合:

    1. body を、 browsingContext.NavigateResult 生成規則に一致する map とし、 navigation フィールドを navigation id に、url フィールドを navigation statusurl が与えられたものとして URL serializer を実行した結果に設定したものとする。

    2. data body とともに success を返す。

    注: これは、そのナビゲーションが fragment の変更だけを 引き起こした場合である。

  6. navigation statusstatus が "canceled" である場合、 unknown errorerror code を持つ error を返す。

    TODO: ここでエラーを扱うにはこれが正しい方法か?

  7. Assert: navigation statusstatus は "pending" であり、navigation id は null でない。

  8. wait condition が "committed" である場合、event name を "committed" とする。

  9. そうでなく、wait condition が "interactive" である場合、event name を "domContentLoaded" とする。

  10. そうでなければ、event name を "load" とする。

  11. (event received, status) を、 «event name, "download started", "navigation aborted", "navigation failed"» および navigation id が与えられたものとして await したものとする。

  12. event received が "navigation failed" である場合、 unknown errorerror code を持つ error を返す。

    ここでの error により、何が失敗し、なぜ失敗したのかについて十分な情報を 表面化できているか? どの error code が望ましいか? local ends が実装定義の文字列を 解析して、実際に何が問題だったのかを把握しようとする問題は生じるか?

  13. body を、 browsingContext.NavigateResult 生成規則に一致する map とし、 navigation フィールドを status の id に、 url フィールドを status の url が与えられたものとして URL serializer を実行した結果に設定したものとする。

  14. data body とともに success を返す。

7.3.2.3. browsingContext.Locator 型

remote end definition および local end definition

browsingContext.Locator = (
   browsingContext.AccessibilityLocator /
   browsingContext.CssLocator /
   browsingContext.ContextLocator /
   browsingContext.InnerTextLocator /
   browsingContext.XPathLocator
)

browsingContext.AccessibilityLocator = {
   type: "accessibility",
   value: {
    ? name: text,
    ? role: text,
   }
}

browsingContext.CssLocator = {
   type: "css",
   value: text
}

browsingContext.ContextLocator = {
  type: "context",
  value: {
    context: browsingContext.BrowsingContext,
  }
}

browsingContext.InnerTextLocator = {
   type: "innerText",
   value: text,
   ? ignoreCase: bool
   ? matchType: "full" / "partial",
   ? maxDepth: js-uint,
}

browsingContext.XPathLocator = {
   type: "xpath",
   value: text
}

browsingContext.Locator 型は、文書内の node を特定するための strategy についての詳細を提供する。

7.3.2.4. browsingContext.Navigation 型

remote end definition および local end definition

browsingContext.Navigation = text;

browsingContext.Navigation 型は、進行中の navigation を識別する一意の string である。

TODO: HTML 仕様内の定義へリンクする。

7.3.2.5. browsingContext.Download 型

remote end 定義 および local end 定義

browsingContext.Download = text;

browsingContext.Download 型は、ダウンロードを識別する一意な文字列である。

7.3.2.6. browsingContext.NavigationInfo 型

local end 定義:

browsingContext.BaseNavigationInfo = (
  context: browsingContext.BrowsingContext,
  navigation: browsingContext.Navigation / null,
  timestamp: js-uint,
  url: text,
  ? userContext: browser.UserContext,
)

browsingContext.NavigationInfo = {
  browsingContext.BaseNavigationInfo
}

browsingContext.NavigationInfo 型は、進行中の navigation の詳細を提供する。

navigable navigable および navigation status navigation status が与えられたとき、 get the navigation info するには:
  1. navigable id を、navigablenavigable id とする。

  2. navigation idnavigation statusid とする。

  3. timestamp を、UTC での現在の日付および時刻を表す time value とする。

  4. urlnavigation statusurl とする。

  5. user context id を、navigableassociated user contextuser context id とする。

  6. browsingContext.NavigationInfo 生成規則に一致する map を返す。 context フィールドは navigable id に、navigation フィールドは navigation id に、timestamp フィールドは timestamp に、 url フィールドは url が与えられたものとして URL serializer を実行した結果に、 userContext フィールドは user context id に設定される。

7.3.2.7. browsingContext.ReadinessState 型
browsingContext.ReadinessState = "none" / "interactive" / "complete"

browsingContext.ReadinessState 型は、ナビゲーションコマンドが戻る 文書読み込みの段階を表す。

7.3.2.8. browsingContext.UserPromptType 型

remote end 定義 および local end 定義

browsingContext.UserPromptType = "alert" / "beforeunload" / "confirm" / "prompt";

browsingContext.UserPromptType 型は、可能なユーザー プロンプト型を表す。

7.3.3. コマンド

7.3.3.1. browsingContext.activate コマンド

browsingContext.activate コマンドは、 指定された top-level traversable をアクティブ化し、フォーカスする。

コマンド型
browsingContext.Activate = (
    method: "browsingContext.activate",
    params: browsingContext.ActivateParameters
    )

    browsingContext.ActivateParameters = {
    context: browsingContext.BrowsingContext
    }
戻り値型
browsingContext.ActivateResult = EmptyResult

command parameters を伴う remote end steps は次である:

  1. navigable idcommand parameters["context"] フィールドの値とする。

  2. navigable を、navigable idget a navigable することを試みた結果とする。

  3. navigabletop-level traversable でない場合、 invalid argumenterror code を持つ error を返す。

  4. navigableactivate a navigable した結果を返す。

navigable が与えられたとき、 activate a navigable するには:
  1. navigablesystem visibility statevisible になるように、実装固有のステップを実行する。 これが不可能である場合、error code unsupported operation を持つ error を返す。

    注: これは、現在 visible である navigableshidden にする副作用を持ち得る。

    注: これは、window を最小化解除すること、または system visibility state の変更に関連するその他の副作用により、 基礎となる OS 状態を変更し得る。

  2. navigable がフォーカスされていない場合、navigablesystem focus を設定するための実装固有のステップを実行する。

    注: これは、他の仕様で義務付けられている場合を除き、 focused area of the document を変更しない。

  3. data null とともに success を返す。

7.3.3.2. browsingContext.captureScreenshot コマンド

browsingContext.captureScreenshot コマンドは、 指定された navigable の画像をキャプチャし、それを Base64 エンコードされた文字列として返す。

コマンド型
browsingContext.CaptureScreenshot = (
  method: "browsingContext.captureScreenshot",
  params: browsingContext.CaptureScreenshotParameters
)

browsingContext.CaptureScreenshotParameters = {
  context: browsingContext.BrowsingContext,
  ? origin: ("viewport" / "document") .default "viewport",
  ? format: browsingContext.ImageFormat,
  ? clip: browsingContext.ClipRectangle,
}

browsingContext.ImageFormat = {
   type: text,
   ? quality: 0.0..1.0,
}

browsingContext.ClipRectangle = (
  browsingContext.BoxClipRectangle /
  browsingContext.ElementClipRectangle
)

browsingContext.ElementClipRectangle = {
  type: "element",
  element: script.SharedReference
}

browsingContext.BoxClipRectangle = {
   type: "box",
   x: float,
   y: float,
   width: float,
   height: float
}
戻り値型
browsingContext.CaptureScreenshotResult = {
  data: text
}
rect が与えられたとき、 normalize rect するには:

注: これは、結果の rect が正の width dimension および height dimension を持つことを保証する。

  1. xrectx coordinate とする。

  2. yrecty coordinate とする。

  3. widthrectwidth dimension とする。

  4. heightrectheight dimension とする。

  5. width が 0 未満である場合、xx + width に設定し、 その後 width を -width に設定する。

  6. height が 0 未満である場合、yy + height に設定し、 その後 height を -height に設定する。

  7. x coordinate xy coordinate ywidth dimension width および height dimension height を持つ新しい DOMRectReadOnly を返す。

rect1 および rect2 が与えられたとき、 rectangle intersection するには
  1. rect1 を、rect1normalize rect したものとする。

  2. rect2 を、rect2normalize rect したものとする。

  3. x1_0rect1x coordinate とする。

  4. x2_0rect2x coordinate とする。

  5. x1_1 を、rect1x coordinaterect1width dimension を加えたものとする。

  6. x2_1 を、rect2x coordinaterect2width dimension を加えたものとする。

  7. x_0 を «x1_0, x2_0» の最大要素とする。

  8. x_1 を «x1_1, x2_1» の最小要素とする。

  9. y1_0rect1y coordinate とする。

  10. y2_0rect2y coordinate とする。

  11. y1_1 を、rect1y coordinaterect1height dimension を加えたものとする。

  12. y2_1 を、rect2y coordinaterect2height dimension を加えたものとする。

  13. y_0 を «y1_0, y2_0» の最大要素とする。

  14. y_1 を «y1_1, y2_1» の最小要素とする。

  15. x_1x_0 未満である場合、width を 0 とする。そうでなければ widthx_1 - x_0 とする。

  16. y_1y_0 未満である場合、height を 0 とする。そうでなければ heighty_1 - y_0 とする。

  17. x coordinate x_0y coordinate y_0width dimension width および height dimension height を持つ新しい DOMRectReadOnly を返す。

document および rect が与えられたとき、 render document to a canvas するには:
  1. ratio を、documentdefault view が与えられたものとして determine the device pixel ratio したものとする。

  2. paint width を、rectwidth dimensionratio を掛け、 最も近い整数に丸めたものとする。これにより device pixels における rect の幅と一致する。

  3. paint height を、rectheight dimensionratio を掛け、 最も近い整数に丸めたものとする。これにより device pixels における rect の高さと一致する。

  4. canvas を、width paint width および height paint height を持つ新しい HTMLCanvasElement とする。

  5. canvas context を、canvas および null で 2D context creation algorithm を実行した結果とする。

  6. canvascontext mode2D に設定する。

  7. rect により覆われる document の領域を表す framebuffer の領域を canvas context に描画することと等価な、実装固有のステップを完了する。 その際、framebuffer 内の各 pixel は canvas context 内の pixel に対応し、viewport coordinates における (rectx coordinate, recty coordinate) が canvas context 内の (0,0) に対応し、(rectx coordinate + rectwidth dimension, recty coordinate + rectheight dimension) が (paint width, paint height) に対応するようにする。

  8. canvas を返す。

canvas および format が与えられたとき、 encode a canvas as Base64 するには:
  1. format が null でない場合、typeformattype フィールドとし、qualityformatquality フィールドとする。

  2. そうでなければ、type を "image/png" とし、qualityundefined とする。

  3. file を、type および quality を伴う canvasa serialization of the bitmap as a file とする。

  4. encoded stringfileforgiving-base64 encode とする。

  5. data encoded string とともに success を返す。

document および origin が与えられたとき、 get the origin rectangle するには:
  1. origin"viewport" である場合:

    1. viewportdocumentvisual viewport とする。

    2. viewport rect を、 x coordinate viewportpage lefty coordinate viewportpage topwidth dimension viewport width、および height dimension viewport height を持つ DOMRectReadOnly とする。

    3. data viewport rect とともに success を返す。

  2. Assert: origin"document" である。

  3. document elementdocumentdocument element とする。

  4. document rect を、x coordinate 0、y coordinate 0、width dimension document elementscroll height、 および height dimension document elementscroll width を持つ DOMRectReadOnly とする。

  5. data document rect とともに success を返す。

session および command parameters を伴う remote end steps は次である:

  1. navigable id を、 command parameterscontext フィールドが存在する場合はその値とし、 そうでなければ null とする。

  2. navigable を、navigable idget a navigable することを試みた結果とする。

  3. 実装が何らかの理由で navigable の screenshot をキャプチャできない場合、 unsupported operationerror code を持つ error を返す。

  4. documentnavigableactive document とする。

  5. document について、次に run the animation frame callbacks algorithm が 呼び出された直後:

    これは update rendering algorithm に、より明示的な方法で統合されるべきである。

  6. origin を、command parameterscontext フィールドが存在する場合はその値とし、そうでなければ "viewport" とする。

  7. origin rect を、origin および document が与えられたものとして get the origin rectangle することを試みた結果とする。

  8. clip rectorigin rect とする。

  9. command parameters が "clip" を含む場合:

    1. clipcommand parameters["clip"] とする。

    2. 最初に一致する条件の下のステップを実行する:

      clipbrowsingContext.ElementClipRectangle 生成規則に一致する:
      1. environment settings を、その relevant global objectassociated Documentdocument である environment settings object とする。

      2. realm を、environment settingsrealm execution context の Realm component とする。

      3. element を、clip["element"]、 realm および sessiondeserialize remote reference することを試みた結果とする。

      4. elementElement を実装していない場合、no such elementerror code を持つ error を返す。

      5. elementnode documentdocument でない場合、no such elementerror code を持つ error を返す。

      6. viewport rect を、"viewport" および document が 与えられたものとして get the origin rectangle したものとする。

      7. element rect を、 element について get the bounding box したものとする。

      8. clip rect を、 x coordinate element rect["x"] + viewport rect["x"]、 y coordinate element rect["y"] + viewport rect["y"]、width element rect["width"], および height element rect["height"] を持つ DOMRectReadOnly とする。

      clipbrowsingContext.BoxClipRectangle 生成規則に一致する:
      1. clip x を、clip["x"] に origin rectx coordinate を加えたものとする。

      2. clip y を、clip["y"] に origin recty coordinate を加えたものとする。

      3. clip rect を、 x coordinate clip xy coordinate clip y、width clip["width"]、および height clip["height"] を持つ DOMRectReadOnly とする。

  10. 注: すべての座標はここで文書の原点から測定される。

  11. rectorigin rectclip rectrectangle intersection とする。

  12. rectwidth dimension が 0 である、または rectheight dimension が 0 である場合、 error code unable to capture screen を持つ error を返す。

  13. canvas を、document および rectrender document to a canvas したものとする。

  14. formatcommand parametersformat フィールドとする。

  15. encoding result を、canvas および formatencode a canvas as Base64 することを試みた結果とする。

  16. body を、 browsingContext.CaptureScreenshotResult 生成規則に一致する map とし、 data フィールドを encoding result に設定したものとする。

  17. data body とともに success を返す。

7.3.3.3. browsingContext.close コマンド

browsingContext.close コマンドは top-level traversable を閉じる。

コマンド型
browsingContext.Close = (
  method: "browsingContext.close",
  params: browsingContext.CloseParameters
)

browsingContext.CloseParameters = {
  context: browsingContext.BrowsingContext,
  ? promptUnload: bool .default false
}
戻り値型
browsingContext.CloseResult = EmptyResult
command parameters を伴う remote end steps は次である:
  1. navigable idcommand parameterscontext フィールドの値とする。

  2. prompt unloadcommand parameterspromptUnload フィールドの値とする。

  3. navigable を、navigable idget a navigable することを試みた結果とする。

  4. Assert: navigable は null でない。

  5. navigabletop-level traversable でない場合、 invalid argumenterror code を持つ error を返す。

  6. prompt unload が true である場合:

    1. navigable閉じる

  7. そうでなければ:

    1. Close navigable without prompting to unload.

  8. data null とともに success を返す。

最後の top-level traversable を閉じるときの挙動について、 未解決の議論がある。ブラウザーを閉じること、セッションを閉じること、またはこれを実装に委ねることが 期待され得る。[w3c/webdriver-bidi Issue #170]

7.3.3.4. browsingContext.create コマンド

browsingContext.create コマンドは、新しい navigable を、新しいタブまたは新しいウィンドウのいずれかに作成し、その navigable id を返す。

コマンド型
browsingContext.Create = (
  method: "browsingContext.create",
  params: browsingContext.CreateParameters
)

browsingContext.CreateType = "tab" / "window"

browsingContext.CreateParameters = {
  type: browsingContext.CreateType,
  ? referenceContext: browsingContext.BrowsingContext,
  ? background: bool .default false,
  ? userContext: browser.UserContext
}
戻り値型
browsingContext.CreateResult = {
    context: browsingContext.BrowsingContext,
    ? userContext: browser.UserContext
    }
command parameters を伴う remote end steps は次である:
  1. typeを、command parameterstypeフィールドの値とする。

  2. reference navigable idを、存在する場合はcommand parametersreferenceContextフィールドの値、そうでなければ null とする。

  3. reference navigable idが null でない場合、reference navigableを、 reference navigable id試行してnavigable を取得する結果とする。 そうでなければ、reference navigableを null とする。

  4. reference navigableが null でなく、かつトップレベル辿可能でない場合、 エラーを、エラー コードinvalid argumentで返す。

  5. 実装が何らかの理由で新しいトップレベル辿可能を作成できない場合、 エラーを、エラー コードunsupported operationで返す。

  6. user contextを、reference navigableが null である場合は既定のユーザーコンテキスト、 そうでなければreference navigable関連付けられたユーザー コンテキストとする。

  7. user context idを、存在する場合はcommand parametersuserContextフィールドの値、そうでなければ null とする。

  8. user context idが null でない場合、user contextを、 user context id試行してユーザーコンテキストを取得する結果に設定する。

  9. user contextが null である場合、エラーを、エラーコードそのようなユーザー コンテキストはないで返す。

  10. 実装が何らかの理由で、トップレベル辿可能関連付けられたユーザーコンテキスト user context とともに新しく作成できない場合、 エラーを、エラー コードunsupported operationで返す。

  11. traversableを、null と空文字列で新しいトップレベル辿可能を作成する 手順を試行し、 新しく作成された関連付けられたユーザーコンテキストトップレベル辿可能について user context に設定する結果とする。 新しいトップレベル辿可能がどの OS ウィンドウに作成されるかは、 typereference navigableによって決まる:

    • typeが "tab" であり、実装が同じ OS ウィンドウ内の複数のトップレベル辿可能をサポートする場合:

      • 新しいトップレベル辿可能は、 既存の OS ウィンドウがあれば、それを再利用するべきである。

      • reference navigableが null でない場合、新しいトップレベル辿可能は、 reference navigableを含むウィンドウがあれば、それを再利用するべきである。OS ウィンドウ内の トップレベル辿可能たちに明確な順序がある場合、 新しいトップレベル辿可能は、その順序において reference navigableトップレベル辿可能の直後にあるべきである。

    • typeが "window" であり、実装が別々の OS ウィンドウ内の複数のトップレベル辿可能をサポートする場合、作成された トップレベル辿可能は新しい OS ウィンドウ内にあるべきである。

    • そうでなければ、トップレベル辿可能がユーザーにどのように提示されるかの詳細は、 実装定義である。

  12. command parametersbackgroundフィールドの値が false である場合:

    1. activate resultを、新しく作成されたnavigablenavigable を有効化する結果とする。

    2. activate resultエラーである場合、 activate resultを返す。

    注記: backgroundが true である場合、作成された navigable に対してフォーカス手順を呼び出してはならない。

  13. bodyを、contextフィールドがtraversablenavigable IDに設定され、 userContextプロパティがtraversable関連付けられたユーザーコンテキストユーザー コンテキスト IDに設定された、 browsingContext.CreateResult 生成規則に一致するマップとする。

  14. 成功をデータ body とともに返す。

7.3.3.5. browsingContext.getTree コマンド

browsingContext.getTree コマンドは、指定された親自身を含む すべての子孫 navigables の tree、または親が提供されない場合はすべての top-level contexts を返す。

コマンド型
browsingContext.GetTree = (
    method: "browsingContext.getTree",
    params: browsingContext.GetTreeParameters
    )

    browsingContext.GetTreeParameters = {
    ? maxDepth: js-uint,
    ? root: browsingContext.BrowsingContext,
    }
戻り値型
browsingContext.GetTreeResult = {
    contexts: browsingContext.InfoList
    }
session および command parameters を伴う remote end steps は次である:
  1. root id を、command parametersroot フィールドが存在する場合は その値とし、そうでなければ null とする。

  2. max depth を、command parametersmaxDepth フィールドが存在する場合はその値とし、そうでなければ null とする。

  3. navigables を空の list とする。

  4. root id が null でない場合、 root id が与えられたものとして get a navigable することを試みた結果を navigables に追加する。 そうでなければ、すべての top-level traversablesnavigables に追加する。

  5. navigables infos を空の list とする。

  6. navigables の各 navigable について:

    1. info を、 navigablemax depth、および true が与えられたものとして get the navigable info した結果とする。

    2. infonavigables infos に追加する

  7. body を、browsingContext.GetTreeResult 生成規則に一致する map とし、contexts フィールドを navigables infos に設定したものとする。

  8. data body とともに success を返す。

7.3.3.6. browsingContext.handleUserPrompt コマンド

browsingContext.handleUserPrompt コマンドは、開いている prompt を閉じられるようにする

コマンド型
browsingContext.HandleUserPrompt = (
  method: "browsingContext.handleUserPrompt",
  params: browsingContext.HandleUserPromptParameters
)

browsingContext.HandleUserPromptParameters = {
  context: browsingContext.BrowsingContext,
  ? accept: bool,
  ? userText: text,
}
戻り値型
browsingContext.HandleUserPromptResult = EmptyResult

session および command parameters を伴う remote end steps は次である:

  1. navigable idcommand parameterscontext フィールドの値とする。

  2. navigable を、navigable idget a navigable することを試みた結果とする。

  3. accept を、 command parametersaccept フィールドが存在する場合はその値とし、 そうでなければ true とする。

  4. userText を、 command parametersuserText フィールドが存在する場合はその値とし、 そうでなければ空文字列とする。

  5. navigable が現在、alert の呼び出しによる simple dialog を表示している場合、 prompt を acknowledge する。

    そうでなく、navigable が現在 confirm の呼び出しによる simple dialog を表示している場合、 accept が true なら肯定的に応答し、 accept が false なら否定的に応答する。

    そうでなく、navigable が現在 prompt の呼び出しによる simple dialog を表示している場合、 accept が true なら文字列値 userText で応答し、accept が false なら中止する。

    そうでなく、navigable が現在 prompt to unload steps の一部として prompt を表示している場合、 accept が true なら navigation を確認し、そうでなければ navigation を拒否する。

    そうでなければ、no such alerterror code を持つ error を返す。

  6. data null とともに success を返す。

7.3.3.7. browsingContext.locateNodes コマンド

browsingContext.locateNodes コマンドは、指定された locator に一致するすべての nodes のリストを返す。

コマンド型
browsingContext.LocateNodes = (
    method: "browsingContext.locateNodes",
    params: browsingContext.LocateNodesParameters
    )

    browsingContext.LocateNodesParameters = {
    context: browsingContext.BrowsingContext,
    locator: browsingContext.Locator,
    ? maxNodeCount: (js-uint .ge 1),
    ? serializationOptions: script.SerializationOptions,
    ? startNodes: [ + script.SharedReference ]
    }
戻り値型
browsingContext.LocateNodesResult = {
        nodes: [ * script.NodeRemoteValue ]
    }
与えられた navigablecontext nodesselectormaximum returned node count、および sessionlocate nodes using CSS するには:
  1. returned nodes を空の list とする。

  2. parse result を、selector が与えられたものとして parse a selector した結果とする。

  3. parse result が failure である場合、invalid selectorerror code を持つ error を返す。

  4. context nodes の各 context node について:

    1. elements を、 parse result および navigableactive documentroot を用い、 scoping root context node を用いて match a selector against a tree した結果とする。

    2. elements 内の各 element について:

      1. elementreturned nodes追加する

      2. maximum returned node count が null でなく、かつ returned nodessizemaximum returned node count に等しい場合、 data returned nodes とともに success を返す。

  5. data returned nodes とともに success を返す。

navigable が与えられたとき、 locate the container element するには:
  1. returned nodes を空の list とする。

  2. navigablecontainer が null でない場合、 navigablecontainerreturned nodes に追加する。

  3. returned nodes を返す。

与えられた navigablecontext nodesselector、および maximum returned node countlocate nodes using XPath するには:

注: XPath 仕様が保守されていない状態であるため、 このアルゴリズムは XPath DOM APIs への呼び出しを行うかのように記述されている。 しかしこれは、ECMAScript runtime を経由せずに、基礎となるアルゴリズムへ直接アクセスする 仕様内部の呼び出しと等価であると理解されるべきである。

  1. returned nodes を空の list とする。

  2. context nodes の各 context node について:

    1. evaluate result を、navigableactive document 上で、引数 selectorcontext node、null、 ORDERED_NODE_SNAPSHOT_TYPE、 および null を用いて evaluate を呼び出した結果とする。 これが "SyntaxError" DOMException を投げる場合、 invalid selectorerror code を持つ error を返す; そうでなく、これが他の例外を投げる場合、unknown errorerror code を持つ error を返す。

    2. index を 0 とする。

    3. length を、evaluate result から snapshotLength プロパティを 取得した結果とする。

    4. indexlength 未満である間、繰り返す:

      1. node を、evaluate result を this とし、index を引数として snapshotItem を呼び出した結果とする。

      2. nodereturned nodes追加する

      3. maximum returned node count が null でなく、かつ returned nodessizemaximum returned node count に等しい場合、 data returned nodes とともに success を返す。

      4. indexindex + 1 に設定する。

  3. data returned nodes とともに success を返す。

与えられた context nodesselectormax depthmatch typeignore case、および maximum returned node countlocate nodes using inner text するには:
  1. selector が空文字列である場合、 invalid selectorerror code を持つ error を返す。

  2. returned nodes を空の list とする。

  3. ignore case が false である場合、search textselector とする。そうでなければ、 search text を、Unicode Default Case Conversion algorithm に従って、 selectortoUppercase した結果とする。

  4. context nodes 内の各 context node について:

    1. context nodeDocument または DocumentFragment を実装している場合:

      注: document または document fragment をたどるとき、documentdocument.documentElement で検索結果が等価になるように、 max depth は意図的に減らされない。

      1. child nodes を空の list とする。

      2. context nodechildren 内の各 node child について。

        1. childchild nodes追加する

      3. child nodesselectormax depthmatch typeignore case、および maximum returned node countlocate nodes using inner text することを試みた結果で returned nodes拡張する

    2. context nodeHTMLElement を実装していない場合、continue する。

    3. node inner text を、 context nodethis 値として innerText getter steps を呼び出した結果とする。

    4. ignore case が false である場合、node textnode inner text とする。そうでなければ、 node text を、Unicode Default Case Conversion algorithm に従って、 node inner texttoUppercase した結果とする。

    5. search textnode textcode point substring である場合、 次のステップを実行する:

      1. child nodes を空の list とし、 context nodechildren 内の各 node child について:

        1. childchild nodes追加する

      2. child nodessize が 0 に等しい、または max depth が 0 に等しい場合、 次のステップを実行する:

        1. match type"full" であり、node textsearch text である場合、 context nodereturned nodes追加する

        2. そうでなく、match type"partial" である場合、 context nodereturned nodes追加する

      3. そうでなければ、次のステップを実行する:

        1. max depth が null である場合、child max depth を null とし、 そうでなければ max depth - 1 とする。

        2. child node matches を、 child nodesselectorchild max depthmatch typeignore case、および maximum returned node countlocate nodes using inner text した結果とする。

        3. child node matchessize が 0 に等しく、かつ match type"partial" である場合、context nodereturned nodes に追加する。そうでなければ、 child node matchesreturned nodes拡張する

  5. maximum returned node count が null でない場合、returned nodes 内で index が maximum returned node count 以上であるすべての entries を削除する

  6. data returned nodes とともに success を返す。

与えられた context nodesselectormaximum returned node count、および returned nodescollect nodes using accessibility attributes するには:
  1. returned nodes が null である場合:

    1. returned nodes を空の list に設定する。

  2. context nodes 内の各 context node について:

    1. match を true とする。

    2. context nodeElement を実装している場合:

      1. selector が "role" を含む場合:

        1. rolecontext nodecomputed role とする。

        2. selector["role"] が role でない場合:

          1. match を false に設定する。

      2. selector が "name" を含む場合:

        1. namecontext nodeaccessible name とする。

        2. selector["name"] が name でない場合:

          1. match を false に設定する。

    3. そうでなければ、match を false に設定する。

    4. match が true である場合:

      1. maximum returned node count が null でなく、かつ returned nodessizemaximum returned node count に等しい場合、 break する。

      2. context nodereturned nodes追加する

    5. child nodes を空の list とし、 context nodechildren 内の各 node child について:

      1. childElement を実装している場合、 childchild nodes追加する

    6. child nodesselectormaximum returned node count、および returned nodescollect nodes using accessibility attributes することを試みる

  3. returned nodes を返す。

与えられた context nodesselector、および maximum returned node countlocate nodes using accessibility attributes するには:
  1. selector が "role" を含まず、 かつ selector が "name" を含まない場合、 invalid selectorerror code を持つ error を返す。

  2. context nodesselectormaximum returned node count、および null で collect nodes using accessibility attributes した結果を返す。

session および command parameters を伴う remote end steps は次である:
  1. navigable idcommand parameters["context"] とする。

  2. navigable を、navigable idget a navigable することを試みた結果とする。

  3. Assert: navigable は null でない。

  4. realm を、 navigablenavigable id および null で get a realm from a navigable することを試みた結果とする。

  5. locatorcommand parameters["locator"] とする。

  6. command parameters が "startNodes" を含む場合、 start nodes parametercommand parameters["startNodes"] とする。 そうでなければ、start nodes parameter を null とする。

  7. command parameters が "maxNodeCount" を含む場合、 maximum returned node countcommand parameters["maxNodeCount"] とする。 そうでなければ、maximum returned node count を null とする。

  8. context nodes を空の list とする。

  9. start nodes parameter が null である場合、navigableactive documentcontext nodes追加する。 そうでなければ、start nodes parameter 内の各 serialized start node について:

    1. start node を、 serialized start noderealm、および session が与えられたものとして deserialize shared reference することを試みた結果とする。

    2. start nodecontext nodes追加する

  10. context nodessize が 0 より大きいことを Assert する。

  11. typelocator["type"] とする。

  12. 次の条件と関連するステップのリストにおいて、関連する条件が true である最初の ステップセットを実行する:

    type が文字列 "css" である
    1. selectorlocator["value"] とする。

    2. result nodes を、navigablecontext nodesselector、および maximum returned nodes が与えられたものとして locate nodes using css することを試みた結果とする。

    type が文字列 "xpath" である
    1. selectorlocator["value"] とする。

    2. result nodes を、navigablecontext nodesselector、および maximum returned nodes が与えられたものとして locate nodes using xpath することを試みた結果とする。

    type が文字列 "innerText" である
    1. selectorlocator["value"] とする。

    2. locatormaxDepth含む場合、max depthlocator["maxDepth"] とする。そうでなければ、max depth を null とする。

    3. locatorignoreCase含む場合、 ignore caselocator["ignoreCase"] とする。そうでなければ、ignore case を false とする。

    4. locatormatchType含む場合、 match typelocator["matchType"] とする。そうでなければ、match type を "full" とする。

    5. result nodes を、 context nodesselectormax depthmatch typeignore case および maximum returned node count が与えられたものとして locate nodes using inner text することを試みた結果とする。

    type が文字列 "accessibility" である
    1. selectorlocator["value"] とする。

    2. result nodes を、 context nodesselector、および maximum returned node count が与えられたものとして locate nodes using accessibility attributes したものとする。

    type が文字列 "context" である
    1. start nodes parameter が null でない場合、 error code "invalid argument" を持つ error を返す。

    2. selectorlocator["value"] とする。

    3. context idselector["context"] とする。

    4. child navigable を、 context idget a navigable することを試みた結果とする。

    5. child navigableparentnavigable でない場合、 error code "invalid argument" を持つ error を返す。

    6. result nodes を、child navigable が与えられたものとして locate the container element したものとする。

    7. Assert: result nodes 内の各 node について、 nodenode navigablenavigable である。

  13. Assert: maximum returned node count は null である、または result nodessizemaximum returned node count 以下である。

  14. command parameters が "serializationOptions" を含む場合、 serialization optionscommand parameters["serializationOptions"] とする。 そうでなければ、serialization options を、 フィールドを既定値に設定した script.SerializationOptions 生成規則に一致する map とする。

  15. result ownership を "none" とする。

  16. serialized nodes を空の list とする。

  17. result nodes 内の各 result node について:

    1. serialized node を、 result nodeserialization optionsresult ownership、 serialization internal map としての新しい maprealm および sessionserialize as a remote value した結果とする。

    2. serialized nodeserialized nodes追加する

  18. result を、 browsingContext.LocateNodesResult 生成規則に一致する map とし、nodes フィールドを serialized nodes に設定したものとする。

  19. data result とともに success を返す。

7.3.3.8. browsingContext.navigate コマンド

browsingContext.navigate コマンドは、 navigable を指定された URL へナビゲートする。

コマンド型
browsingContext.Navigate = (
  method: "browsingContext.navigate",
  params: browsingContext.NavigateParameters
)

browsingContext.NavigateParameters = {
  context: browsingContext.BrowsingContext,
  url: text,
  ? wait: browsingContext.ReadinessState,
}
戻り値型
browsingContext.NavigateResult = {
  navigation: browsingContext.Navigation / null,
  url: text,
}
session および command parameters を伴う remote end steps は次である:
  1. navigable idcommand parameterscontext フィールドの値とする。

  2. navigable を、navigable idget a navigable することを試みた結果とする。

  3. Assert: navigable は null でない。

  4. wait condition を "committed" とする。

  5. command parameterswait含み、 かつ command parameters[wait] が "none" でない場合、 wait conditioncommand parameters[wait] に設定する。

  6. urlcommand parametersurl フィールドの値とする。

  7. documentnavigableactive document とする。

  8. basedocumentbase URL とする。

  9. url record を、base URL baseurlURL parser を適用した結果とする。

  10. url record が failure である場合、invalid argumenterror code を持つ error を返す。

  11. request を、URL が url record である新しい request とする。

  12. navigablerequest および wait conditionawait a navigation した結果を返す。

7.3.3.9. browsingContext.print コマンド

browsingContext.print コマンドは、 document のページ分割された表現を作成し、それを Base64 エンコードされた文字列として表される PDF document として返す。

コマンド型
browsingContext.Print = (
  method: "browsingContext.print",
  params: browsingContext.PrintParameters
)

browsingContext.PrintParameters = {
  context: browsingContext.BrowsingContext,
  ? background: bool .default false,
  ? margin: browsingContext.PrintMarginParameters,
  ? orientation: ("portrait" / "landscape") .default "portrait",
  ? page: browsingContext.PrintPageParameters,
  ? pageRanges: [*(js-uint / text)],
  ? scale: (0.1..2.0) .default 1.0,
  ? shrinkToFit: bool .default true,
}

browsingContext.PrintMarginParameters = {
  ? bottom: (float .ge 0.0) .default 1.0,
  ? left: (float .ge 0.0) .default 1.0,
  ? right: (float .ge 0.0) .default 1.0,
  ? top: (float .ge 0.0) .default 1.0,
}

; Minimum size is 1pt x 1pt. Conversion follows from
; https://www.w3.org/TR/css3-values/#absolute-lengths
browsingContext.PrintPageParameters = {
  ? height: (float .ge 0.0352) .default 27.94,
  ? width: (float .ge 0.0352) .default 21.59,
}
戻り値型
browsingContext.PrintResult = {
  data: text
}

sessionおよびcommand parametersを伴うリモートエンド手順は次のとおりである:

  1. navigable idを、command parameterscontextフィールドの値とする。

  2. navigableを、navigable id試行してnavigable を取得する 結果とする。

  3. 実装が何らかの理由でnavigableのページ分割された表現を提供できない場合、 エラーを、エラーコード unsupported operationで返す。

  4. marginを、存在する場合はcommand parametersmarginフィールドの値、そうでなければ フィールドが既定値に設定された browsingContext.PrintMarginParametersに一致する マップとする。

  5. page sizeを、存在する場合はcommand parameterspageフィールドの値、そうでなければ フィールドが既定値に設定された browsingContext.PrintPageParametersに一致する マップとする。

注記: 最小ページサイズは 1 ポイントであり、これは 絶対長に従うと (2.54 / 72) cm である。

  1. page rangesを、存在する場合は command parameterspageRangesフィールドの値、そうでなければ空のリストとする。

  2. documentを、navigableアクティブ文書とする。

  3. documentに対するアニメーションフレームコールバックを実行する アルゴリズムの次の呼び出しの直後に:

    これは、 より明示的な方法でレンダリング更新アルゴリズムに統合されるべきである。

    1. pdf dataを、UA 固有の手順を実行してdocumentの ページ分割された表現を生成した結果とする。このとき、CSS のメディア型printに設定され、PDF として符号化され、以下の用紙設定を用いる:

      プロパティ
      幅(cm) command parameters["orientation"] が "portrait" である場合はpage size["width"]、 そうでなければpage size["height"]
      高さ(cm) command parameters["orientation"] が "portrait" である場合はpage size["height"]、 そうでなければpage size["width"]
      上余白(cm) margin["top"]
      下余白(cm) margin["bottom"]
      左余白(cm) margin["left"]
      右余白(cm) margin["right"]

      加えて、UA は以下の整形ヒントを適用するべきである:

      command parameters["scale"] が 1と等しくない場合:
      コンテンツのサイズをcommand parameters["scale"] 倍でズームする
      command parameters["background"] が false である場合:
      背景画像の出力を抑制する
      command parameters["shrinkToFit"] が true である場合:
      コンテンツ内で指定されたページ幅を上書きし、ページ幅に合わせてコンテンツのサイズを変更する
    2. page rangesでない場合、 pagesを、page rangesおよびpdf dataに含まれるページ数で 試行してページ範囲をパースする結果とし、その後、1 から始まるインデックスが pagesに含まれないページをpdf dataから除去する。

    3. encoding resultを、pdf dataに対して Base64 Encodeを呼び出した結果とする。

    4. encoded dataを、encoding resultの data とする。

    5. bodyを、dataフィールドがencoded dataに設定された browsingContext.PrintResult生成規則に一致する マップとする。

    6. 成功をデータ body とともに返す。

7.3.3.10. browsingContext.reload コマンド

browsingContext.reload コマンドは navigable を再読み込みする。

コマンド型
browsingContext.Reload = (
  method: "browsingContext.reload",
  params: browsingContext.ReloadParameters
)

browsingContext.ReloadParameters = {
  context: browsingContext.BrowsingContext,
  ? ignoreCache: bool,
  ? wait: browsingContext.ReadinessState,
}
戻り値型
browsingContext.ReloadResult = browsingContext.NavigateResult
command parameters を伴う remote end steps は次である:
  1. navigable idcommand parameterscontext フィールドの値とする。

  2. navigable を、navigable idget a navigable することを試みた結果とする。

  3. Assert: navigable は null でない。

  4. ignore cache を、command parametersignoreCache フィールドが存在する場合はその値とし、 そうでなければ false とする。

  5. wait condition を "committed" とする。

  6. command parameterswait含み、 かつ command parameters[wait] が "none" でない場合、 wait conditioncommand parameters[wait] に設定する。

  7. documentnavigableactive document とする。

  8. urldocumentURL とする。

  9. request を、URL が url である新しい request とする。

  10. navigablerequestwait condition、history handling "reload"、および ignore cache ignore cacheawait a navigation した結果を返す。

7.3.3.11. browsingContext.setBypassCSP コマンド

browsingContext.setBypassCSP コマンドは、 Content Security Policy の適用をバイパスできるようにする。

注: CSP bypass が有効である場合、 eval()、new Function()、inline scripts、および resource loading を通常ブロックするものを含め、 すべての CSP directives がバイパスされる。

コマンド型
browsingContext.SetBypassCSP = (
  method: "browsingContext.setBypassCSP",
  params: browsingContext.SetBypassCSPParameters
)

browsingContext.SetBypassCSPParameters = {
  bypass: true / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
browsingContext.SetBypassCSPResult = EmptyResult

remote endbypass CSP configuration を持ち、これは associated type boolean を持つ WebDriver configuration である。

navigable navigable が与えられたとき、 WebDriver BiDi CSP is bypassed steps は次である:

  1. top-level traversablenavigabletop-level traversable とする。

  2. bypass CSP enabled を、top-level traversable についての bypass CSP configurationget WebDriver configuration value の結果とする。

  3. Assert: bypass CSP enabledtrue または unset である。

  4. bypass CSP enabledunset である場合、false を返す。

  5. true を返す。

command parameters が与えられたときの remote end steps は次である:

  1. bypasscommand parameters["bypass"] とする。

  2. bypass が null である場合、bypassunset に設定する。

  3. command parameters について、 bypass CSP configuration bypassstore WebDriver configuration することを試みる

  4. data null とともに success を返す。

7.3.3.12. browsingContext.setViewport コマンド

browsingContext.setViewport コマンドは、指定された top-level traversable 上の特定の viewport 特性(例: viewport width および viewport height)を変更する。

コマンド型
browsingContext.SetViewport = (
  method: "browsingContext.setViewport",
  params: browsingContext.SetViewportParameters
)

browsingContext.SetViewportParameters = {
  ? context: browsingContext.BrowsingContext,
  ? viewport: browsingContext.Viewport / null,
  ? devicePixelRatio: (float .gt 0.0) / null,
  ? userContexts: [+browser.UserContext],
}

browsingContext.Viewport = {
  width: js-uint,
  height: js-uint,
}
戻り値型
browsingContext.SetViewportResult = EmptyResult
navigable および device pixel ratio が与えられたとき、 set device pixel ratio override するには:
  1. device pixel ratio が null でない場合:

    1. 指定された navigable に現在読み込まれている document について:

      1. select an image source from a source set steps が実行されるとき、画像を選択する際に 実装の pixel density が device pixel ratio に設定されたかのように振る舞う。

      2. resolution media feature の目的では、 実装の resolution が page zoom によってスケールされた device pixel ratio dppx であるかのように振る舞う。

    2. device pixel ratio overrides[navigable] を device pixel ratio設定する

      注: これは § 8.3.1 Determine the device pixel ratio のパッチにより効果を持つ。

  2. そうでなければ:

    1. 指定された navigable に現在読み込まれている document について:

      1. select an image source from a source set steps が実行されるとき、 これらのステップの以前の呼び出しによって行われた変更なしに、 実装の既定の挙動を使用する。

      2. resolution media feature の目的では、 これらのステップの以前の呼び出しによって行われた変更なしに、 実装の既定の挙動を使用する。

    2. device pixel ratio overrides から navigable削除する

  3. 指定された navigable に現在読み込まれている document について evaluate media queries and report changes を実行する。

navigable navigable および viewport viewport が与えられたとき、 set viewport するには:
  1. viewport が null でない場合、navigablelayout viewport の width を CSS pixels における viewportwidth に設定し、 navigablelayout viewport の height を CSS pixels における viewportheight に設定する。

  2. そうでなければ、navigablelayout viewport を 実装定義の既定値に設定する。

新しい navigable navigable に document を作成した後、かつ run WebDriver BiDi preload scripts algorithm が 呼び出される前:

TODO: 代わりに html spec の hook として移動する。

  1. user contextnavigableassociated user context とする。

  2. navigabletop-level traversable である場合:

    1. navigable について Update geolocation override する。

    2. navigable について Update emulated forced colors theme する。

    3. screen orientation overrides mapuser context含む場合、 navigable および screen orientation overrides map[user context] で set emulated screen orientation する。

  3. viewport overrides mapuser context含む場合:

    1. navigabletop-level traversable であり、かつ viewport overrides map[user context] の viewport が null でない場合:

      1. navigable および viewport overrides map[user context] の viewportSet viewport する。

    2. viewport overrides map[user context] の devicePixelRatio が null でない場合:

      1. navigable および viewport overrides map[user context] の devicePixelRatioSet device pixel ratio override する。

  4. navigable について Update scrollbar type override する。

command parameters を伴う remote end steps は次である:

  1. 実装が何らかの理由で、指定された command parameters を用いて layout viewport parameters を調整できない場合、 unsupported operationerror code を持つ error を返す。

  2. command parameters が "userContexts" を含み、 かつ command parameters が "context" を含む場合、 invalid argumenterror code を持つ error を返す。

  3. navigablesset とする。

  4. command parameterscontext フィールドが存在する場合:

    1. navigable idcommand parameterscontext フィールドの値とする。

    2. navigable を、 navigable idget a navigable することを試みた結果とする。

    3. navigabletop-level traversable でない場合、 invalid argumenterror code を持つ error を返す。

    4. navigablenavigables追加する

  5. そうでなく、command parametersuserContexts フィールドが存在する場合:

    1. user contexts を、 command parameters["userContexts"] で get valid user contexts することを試みた結果とする。

    2. user contexts の各 user context について:

      1. viewport overrides map[user context] を struct に設定する

      2. command parameters が "viewport" を含む場合:

        1. viewport overrides map[user context] の viewportcommand parameters["viewport"] に設定する。

      3. command parameters が "devicePixelRatio" を含む場合:

        1. viewport overrides map[user context] の devicePixelRatiocommand parameters["devicePixelRatio"] に設定する。

      4. For each user contextassociated user context である すべての top-level traversables のリストの 各 top-level traversable について:

        1. top-level traversablenavigables追加する

  6. そうでなければ、invalid argumenterror code を持つ error を返す。

  7. command parametersviewport フィールドを含む場合:

    1. viewportcommand parameters["viewport"] とする。

    2. navigables の各 navigable について:

      1. navigable および viewportSet viewport する。

      2. navigableactive documentCSSOM View § 13.1 Resizing viewports steps を実行する。

  8. command parametersdevicePixelRatio フィールドを含む場合:

    1. device pixel ratiocommand parameters["devicePixelRatio"] とする。

    2. navigables の各 navigable について:

      1. navigable およびすべての descendant navigables について:

        1. navigable および device pixel ratioSet device pixel ratio override する。

  9. data null とともに success を返す。

7.3.3.13. browsingContext.startScreencast コマンド

browsingContext.startScreencast コマンドは、 指定された navigable のスクリーンキャストを開始し、それをファイルに書き込む。

注記: リモートエンドは スクリーンキャストファイルを作成して書き込むが、それを削除しない。 ファイルのクリーンアップはローカルエンドに委ねられる。いくつかの構成では、これは 不可能かもしれない — たとえば、リモートエンドが ファイルシステムへの読み書きアクセス権を持つが、 ローカルエンドは読み取り専用アクセス権しか持たない場合である。

コマンド型
browsingContext.StartScreencast = (
  method: "browsingContext.startScreencast",
  params: browsingContext.StartScreencastParameters
)

browsingContext.StartScreencastParameters = {
  context: browsingContext.BrowsingContext,
  ? mimeType: text,
  ? video: browsingContext.MediaTrackConstraints,
  ? audio: bool .default false,
}

browsingContext.MediaTrackConstraints = {
   ? width: js-uint,
   ? height: js-uint,
   ? frameRate: js-uint,
}

戻り値型
browsingContext.StartScreencastResult = {
   screencast: browsingContext.Screencast,
   path: text
}

browsingContext.Screencast = text
session および command parameters が与えられた リモートエンド手順 は次の通りである:
  1. navigable idcommand parameters["context"] とする。

  2. navigable を、navigable idnavigable を 取得することを 試行する結果とする。

  3. navigableトップレベルトラバーサブルでない場合、エラーエラーコード invalid argument で返す。

  4. command parametersmimeType フィールドを 含む場合:

    1. mime typecommand parameters["mimeType"] とする。

  5. それ以外の場合、mime type を実装定義のデフォルト形式に設定する。

  6. 何らかの理由で実装が navigable のスクリーンキャストを記録できない場合、エラーエラー コード unsupported operation で返す。

  7. stream を、navigable 用の新しい スクリーンキャストストリームとし、次のように構築する:

    1. ブラウザー表示サーフェス、 すなわち関連するグローバルオブジェクト関連付けられた `Document`navigableビューポートのライブキャプチャでなければならない video track を作成する。

    2. command parameters が "video" を含む場合:

      1. videocommand parameters["video"] とする。

      2. videowidth含む場合:

        1. ユーザーエージェントは、ハードウェアの能力 および指定されたその他の制約を考慮して、video["width"] に 可能な限り近い幅を持つメディアの取得を試みなければならない。

      3. videoheight含む場合:

        1. ユーザーエージェントは、ハードウェアの能力 および指定されたその他の制約を考慮して、video["height"] に 可能な限り近い高さを持つメディアの取得を試みなければならない。

      4. videoframeRate含む場合:

        1. ユーザーエージェントは、ハードウェアの能力 および指定されたその他の制約を考慮して、video["frameRate"] に 可能な限り近いフレームレートを持つメディアの取得を試みなければならない。

    3. video trackstream[video track] に設定する

    4. command parameters["audio"] が true である場合:

      1. 関連するグローバルオブジェクト関連付けられた `Document`navigableアクティブ文書、および関連するグローバルオブジェクト関連付けられた `Document`navigable の入れ子の閲覧コンテキスト内にあるすべてのアクティブ文書 からなる文書群の和によって生成される結合音声を含む audio track を作成する。

      2. audio trackstream[audio track] に設定する

    5. 実装が stream を生成できない場合、エラーエラーコード unknown error で返す。

  8. path を、記録が保存される実装定義のファイルパスとする。

  9. screencastUUID の文字列表現とする。

  10. recording を、スクリーンキャスト記録である新しいものとし、 streamstreampathpathstate は "recording"、 writeError は null とする。

  11. sessionスクリーンキャスト記録マップ[screencast] を recording に設定する。

  12. recording および mime type が与えられたものとして、スクリーンキャスト記録を開始する

  13. body を、screencast フィールドが screencast に設定され、 path フィールドが path に設定された browsingContext.StartScreencastResult に一致する新しいマップとする。

  14. body をデータとして 成功を返す。

7.3.3.14. browsingContext.stopScreencast コマンド

browsingContext.stopScreencast コマンドは、 スクリーンキャストを停止する。

コマンド型
browsingContext.StopScreencast = (
  method: "browsingContext.stopScreencast",
  params: browsingContext.StopScreencastParameters
)

browsingContext.StopScreencastParameters = {
  screencast: browsingContext.Screencast
}
戻り値型
browsingContext.StopScreencastResult = {
   path: text,
   ? error: text
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. screencastを、command parameters内の "screencast" フィールドの値とする。

  2. sessionスクリーンキャスト記録マップscreencast含まない場合、エラーエラーコード そのような スクリーンキャストはないで返す。

  3. screencast recordingを、sessionスクリーンキャスト 記録マップ[screencast]とする。

  4. screencast recordingが与えられたとして、スクリーンキャスト記録を停止する

  5. screencastsessionスクリーンキャスト記録マップから除去する

  6. errorscreencast recordingwriteErrorとする。

  7. pathscreencast recordingpathとする。

  8. bodyを、pathフィールドがpathに設定され、 errorが null でない場合はerrorフィールドが errorに設定され、そうでなければ省略された、 browsingContext.StopScreencastResultに一致する新しいマップとする。

  9. 成功をデータ body とともに返す。

7.3.3.15. browsingContext.traverseHistory コマンド

browsingContext.traverseHistory コマンドは、 指定された navigable の履歴を delta だけ走査する。

コマンド型
browsingContext.TraverseHistory = (
  method: "browsingContext.traverseHistory",
  params: browsingContext.TraverseHistoryParameters
)

browsingContext.TraverseHistoryParameters = {
  context: browsingContext.BrowsingContext,
  delta: js-int,
}
戻り値型
browsingContext.TraverseHistoryResult = EmptyResult
command parametersを伴うリモートエンド手順は次のとおりである:
  1. navigableを、command parameters["context"]で試行してnavigable を取得する 結果とする。

  2. navigableトップレベル辿可能でない場合、エラーエラーコード invalid argumentで返す。

  3. 表明:navigableは null でない。

  4. deltacommand parameters["delta"]とする。

  5. resume idを一意な文字列とする。

  6. navigableセッション履歴走査キュー上で、以下の手順を実行するタスクをキューする

    1. all stepsを、navigableについて使用されているすべての履歴ステップを取得する結果とする。

    2. current indexを、all steps内におけるnavigable現在のセッション履歴ステップのインデックスとする。

    3. target indexを、current indexdeltaを加えたものとする。

    4. valid entryを、all steps[target index]が存在しない場合は false、 そうでなければ true とする。

    5. "check history"、resume id、および valid entry再開する

  7. is valid entryを、«"check history"» および resume idawaitしたものとする。

  8. is valid entryが false である場合、エラーコードそのような履歴エントリーはないを伴うエラーを返す。

  9. deltaおよびnavigableが与えられたとして、履歴をデルタだけ走査する

    書かれているとおりのアルゴリズムには、 競合状態がある。なぜなら、ターゲットセッション履歴エントリーにナビゲートしようとする時点で、それが 存在しない可能性があるためである。履歴のナビゲーションを待機することをサポートすれば、これを より堅牢に処理できる。

  10. TODO:履歴走査の完了を待機することをサポートする。

  11. bodyを、 browsingContext.TraverseHistoryResult生成規則に一致する マップとする。

  12. 成功をデータ body とともに返す。

context および navigation status navigation status が与えられたとき、 WebDriver BiDi page show steps は次である:

`browsingContext.pageShow event を公開したいか?その場合、 これを bfcache restore の時だけでなく、`pageshow` が発火されようとするたびに呼び出す必要があり、 また persisted status を data に追加する必要がある。

  1. navigation idnavigation statusid とする。

  2. "page show"、navigation id、および navigation statusResume する。

context および navigation status navigation status が与えられたとき、 WebDriver BiDi pop state steps は次である:

  1. navigation idnavigation statusid とする。

  2. "pop state"、navigation id、および navigation statusResume する。

7.3.4. イベント

7.3.4.1. browsingContext.contextCreated イベント
イベント型
browsingContext.ContextCreated = (
    method: "browsingContext.contextCreated",
    params: browsingContext.Info
    )

session および navigable が与えられたとき、 Recursively emit context created events するには:

  1. session および navigableEmit a context created event する。

  2. navigable の各 child navigable child について:

    1. session および child が与えられたものとして Recursively emit context created events する。

session および navigable が与えられたとき、 Emit a context created event するには:

  1. params を、navigable、0、および true が与えられたものとして get the navigable info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.ContextCreated 生成規則に一致する map とする。

  3. session および bodyEmit an event する。

remote end event trigger は、 navigable navigable および navigable opener navigable が与えられたときの WebDriver BiDi navigable created steps である:

  1. opener navigable が提供されている場合、navigableoriginal openeropener navigable に設定する。

  2. navigable についての navigable cache behavior が "bypass" である場合、 navigable から発生する network requests について、実装固有の resource caches を無効にする実装定義のステップを実行する。

  3. related navigables を、navigable を含む set とする。

  4. "browsingContext.contextCreated" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および navigable が与えられたものとして Emit a context created event する。

sessionnavigables および include global が与えられたとき、 subscribe priority 1 を伴う remote end subscribe steps は次である:

  1. navigables 内の各 navigable について:

    1. session および navigable が与えられたものとして Recursively emit context created events する。

7.3.4.2. browsingContext.contextDestroyed イベント
イベント型
browsingContext.ContextDestroyed = (
    method: "browsingContext.contextDestroyed",
    params: browsingContext.Info
    )
remote end event trigger は次である:

remote end event trigger は、 navigable navigable が与えられたときの WebDriver BiDi navigable destroyed steps である:

  1. params を、navigable、null、および true が与えられたものとして get the navigable info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.ContextDestroyed 生成規則に一致する map とする。

  3. related navigables を、navigableparent が null でない場合はそれを含む set とし、そうでなければ空の set とする。

  4. "browsingContext.contextDestroyed" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

    2. subscriptions to remove を空の set とする。

    3. sessionsubscriptions 内の各 subscription について:

      1. subscriptiontop-level traversable idsnavigablenavigable id含む場合:

        1. navigablenavigable idsubscriptiontop-level traversable ids から削除する

        2. subscriptiontop-level traversable ids が空である場合:

          1. subscriptionsubscriptions to remove追加する

    4. subscriptions to removesessionsubscriptions から削除する

このイベントを active documents を持つ browsing contexts に対してのみ発火すべきかは不明である。navigation によって、contexts が アクセス不能になるが、bfcache のためまだ破棄されないこともある。

7.3.4.3. browsingContext.navigationStarted イベント
イベント型
browsingContext.NavigationStarted = (
    method: "browsingContext.navigationStarted",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi navigation started steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.NavigationStarted 生成規則に一致する map とする。

  3. navigation idnavigation statusid とする。

  4. related navigablesnavigable を含む set とする。

  5. "navigation started"、navigation id、および navigation statusResume する。

  6. "browsingContext.navigationStarted" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.4. browsingContext.fragmentNavigated イベント
イベント型
browsingContext.FragmentNavigated = (
    method: "browsingContext.fragmentNavigated",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi fragment navigated steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.FragmentNavigated 生成規則に一致する map とする。

  3. navigation idnavigation statusid とする。

  4. related navigable を、navigable を含む set とする。

  5. "fragment navigated"、navigation id、および navigation statusResume する。

  6. "browsingContext.fragmentNavigated" および related navigable が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.5. browsingContext.historyUpdated イベント
イベント型
browsingContext.HistoryUpdated = (
  method: "browsingContext.historyUpdated",
  params: browsingContext.HistoryUpdatedParameters
)

browsingContext.HistoryUpdatedParameters = {
  context: browsingContext.BrowsingContext,
  timestamp: js-uint,
  url: text,
  ? userContext: browser.UserContext
}
リモートエンドイベントトリガーは、 navigable navigable が与えられたときのWebDriver BiDi 履歴更新手順である:
  1. urlを、navigableアクティブブラウジングコンテキストアクティブ文書URLが与えられたとして、URL シリアライザーを実行した結果とする。

  2. user context idを、navigable関連付けられたユーザー コンテキストユーザー コンテキスト IDとする。

  3. timestampを、UTC における現在の日付と時刻を表す時刻値とする。

  4. paramsを、urlフィールドがurlに設定され、 timestampフィールドがtimestampに設定され、 contextフィールドがnavigablenavigable IDに設定され、 userContextフィールドがuser context idに設定された、 browsingContext.HistoryUpdatedParameters生成規則に一致するマップとする。

  5. bodyを、paramsフィールドがparamsに設定された browsingContext.HistoryUpdated生成規則に一致する マップとする。

  6. related browsing contextsを、navigableアクティブブラウジングコンテキストを含む集合とする。

  7. "browsingContext.historyUpdated" と related browsing contexts が与えられたとして、 イベントが有効化されている セッションの集合内の各sessionについて:

    1. sessionおよびbodyイベントを 発行する

7.3.4.6. browsingContext.domContentLoaded イベント
イベント型
browsingContext.DomContentLoaded = (
    method: "browsingContext.domContentLoaded",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi DOM content loaded steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.DomContentLoaded 生成規則に一致する map とする。

  3. related navigables を、navigable を含む set とする。

  4. navigation idnavigation statusid とする。

  5. "domContentLoaded"、navigation id、および navigation statusResume する。

  6. "browsingContext.domContentLoaded" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.7. browsingContext.load イベント
イベント型
browsingContext.Load = (
    method: "browsingContext.load",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi load complete steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、params フィールドを params に設定した、 browsingContext.Load 生成規則に一致する map とする。

  3. related navigables を、navigable を含む set とする。

  4. navigation idnavigation statusid とする。

  5. "load"、navigation id および navigation statusResume する。

  6. "browsingContext.load" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.8. browsingContext.downloadWillBegin イベント
イベント型
browsingContext.DownloadWillBegin = (
 method: "browsingContext.downloadWillBegin",
 params: browsingContext.DownloadWillBeginParams
)

browsingContext.DownloadWillBeginParams = {
  download: browsingContext.Download,
  suggestedFilename: text,
  browsingContext.BaseNavigationInfo
}
リモートエンドイベントトリガーは、 navigable navigable および ナビゲーションステータス navigation status が与えられたときのWebDriver BiDi ダウンロード開始予定手順である:
  1. navigation infoを、navigableおよびnavigation statusが 与えられたとしてナビゲーション 情報を取得する結果とする。

  2. downloadを、UUIDの文字列表現とする。

  3. 設定するダウンロード ID マップ[navigation statusdownloadResponse]を downloadに。

  4. paramsを、 contextフィールドがnavigation info["context"]に設定され、 navigationフィールドがnavigation info["navigation"]に設定され、 timestampフィールドが navigation info["timestamp"]に設定され、urlフィールドが navigation info["url"]に設定され、downloadフィールドが downloadに設定され、 suggestedFilenameフィールドが navigation statussuggestedFilenameに設定された、 browsingContext.DownloadWillBeginParams生成規則に一致するマップとする。

  5. bodyを、 paramsフィールドがparamsに設定された browsingContext.DownloadWillBegin生成規則に一致するマップとする。

  6. navigation idを、navigation statusidとする。

  7. related navigablesを、navigableを含む集合とする。

  8. "download started"、navigation id、および navigation status再開する

  9. "browsingContext.downloadWillBegin" と related navigables が与えられたとして、 イベントが有効化されている セッションの集合内の各sessionについて:

    1. sessionおよびbodyイベントを 発行する

  10. download behaviorを、navigableダウンロード動作を取得する結果とする。

  11. download behaviorを返す。

7.3.4.9. browsingContext.downloadEnd イベント
イベント型
browsingContext.DownloadEnd = (
  method: "browsingContext.downloadEnd",
  params: browsingContext.DownloadEndParams
)

browsingContext.DownloadEndParams = {
  (
    browsingContext.DownloadCanceledParams //
    browsingContext.DownloadCompleteParams
  )
}

browsingContext.DownloadCanceledParams = (
  status: "canceled",
  download: browsingContext.Download,
  browsingContext.BaseNavigationInfo
)

browsingContext.DownloadCompleteParams = (
  status: "complete",
  download: browsingContext.Download,
  filepath: text / null,
  browsingContext.BaseNavigationInfo
)
リモートエンドイベントトリガーは、WebDriver BiDi ダウンロード終了手順であり、 navigable navigable および ナビゲーション ステータス navigation status が与えられる:
  1. navigation infoを、navigableおよびnavigation statusが 与えられたとしてナビゲーション 情報を取得する結果とする。

  2. 表明:navigation info["status"] は "complete" または "canceled" のいずれかに等しい。

  3. download responseを、navigation statusdownloadResponseとする。

  4. ダウンロード ID マップdownload response含む場合、downloadダウンロード ID マップ[download response]とし、そうでなければdownloadUUIDの文字列表現とする。

  5. navigation info["status"] が "complete" である場合、 paramsを、downloadフィールドが downloadに設定され、filepathフィールドが navigation statusdownloadedFilepathに設定され、 contextフィールドがnavigation info["context"]に設定され、 navigationフィールドがnavigation info["navigation"]に設定され、 timestampフィールドが navigation info["timestamp"]に設定され、urlフィールドが navigation info["url"]に設定された、 browsingContext.DownloadCompleteParams生成規則に一致するマップとする。

    注記: filepathは、 何らかの理由でファイルパスが利用できない場合、完了したダウンロードについて null になりうる。

  6. そうでなければ、paramsを、downloadフィールドが downloadに設定され、contextフィールドがnavigation info["context"]に設定され、 navigationフィールドがnavigation info["navigation"]に設定され、 timestampフィールドが navigation info["timestamp"]に設定され、urlフィールドが navigation info["url"]に設定された、 browsingContext.DownloadCanceledParams生成規則に一致するマップとする。

  7. bodyを、 paramsフィールドがparamsに設定された browsingContext.DownloadEnd生成規則に一致するマップとする。

  8. related navigablesを、navigableを含む集合とする。

  9. "browsingContext.downloadEnd" と related navigables が与えられたとして、 イベントが有効化されている セッションの集合内の各sessionについて:

    1. sessionおよびbodyイベントを 発行する

7.3.4.10. browsingContext.navigationAborted イベント
イベント型
browsingContext.NavigationAborted = (
    method: "browsingContext.navigationAborted",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi navigation aborted steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.NavigationAborted 生成規則に一致する map とする。

  3. navigation idnavigation statusid とする。

  4. related navigables を、navigable を含む set とする。

  5. "navigation aborted"、navigation id、および navigation statusResume する。

  6. "browsingContext.navigationAborted" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.11. browsingContext.navigationCommitted イベント
イベント型
browsingContext.NavigationCommitted = (
    method: "browsingContext.navigationCommitted",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi navigation committed steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.NavigationCommitted 生成規則に一致する map とする。

  3. related navigables を、navigable を含む set とする。

  4. navigation idnavigation statusid とする。

  5. "navigation committed"、navigation id、および navigation statusResume する。

  6. "browsingContext.navigationCommitted" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.12. browsingContext.navigationFailed イベント
イベント型
browsingContext.NavigationFailed = (
    method: "browsingContext.navigationFailed",
    params: browsingContext.NavigationInfo
    )
remote end event trigger は、 navigable navigable および navigation status navigation status が与えられたときの WebDriver BiDi navigation failed steps である:
  1. params を、navigable および navigation status が与えられたものとして get the navigation info した結果とする。

  2. body を、 params フィールドを params に設定した、 browsingContext.NavigationFailed 生成規則に一致する map とする。

  3. navigation idnavigation statusid とする。

  4. related navigables を、navigable を含む set とする。

  5. "navigation failed"、navigation id、および navigation statusResume する。

  6. "browsingContext.navigationFailed" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.13. browsingContext.userPromptClosed イベント
イベント型
browsingContext.UserPromptClosed = (
  method: "browsingContext.userPromptClosed",
  params: browsingContext.UserPromptClosedParameters
)

browsingContext.UserPromptClosedParameters = {
  context: browsingContext.BrowsingContext,
  accepted: bool,
  type: browsingContext.UserPromptType,
  ? userContext: browser.UserContext,
  ? userText: text
}
remote end event trigger は、 Window window、文字列 type、boolean accepted、および省略可能な text user text (既定値: null)が与えられたときの WebDriver BiDi user prompt closed steps である。
  1. navigablewindownavigable とする。

  2. navigable idnavigablenavigable id とする。

  3. user context id を、navigableassociated user contextuser context id とする。

  4. params を、 context フィールドを navigable id に、userContext フィールドを user context id に、accepted フィールドを accepted に、 type フィールドを type に設定し、かつ user text が null でなければ userText フィールドを user text に設定し、そうでなければ省略した、 browsingContext.UserPromptClosedParameters 生成規則に一致する map とする。

  5. body を、 params フィールドを params に設定した、 BrowsingContextUserPromptClosedEvent 生成規則に一致する map とする。

  6. related navigables を、navigable を含む set とする。

  7. "browsingContext.userPromptClosed" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

7.3.4.14. browsingContext.userPromptOpened イベント
イベント型
browsingContext.UserPromptOpened = (
  method: "browsingContext.userPromptOpened",
  params: browsingContext.UserPromptOpenedParameters
)

browsingContext.UserPromptOpenedParameters = {
  context: browsingContext.BrowsingContext,
  handler: session.UserPromptHandlerType,
  message: text,
  type: browsingContext.UserPromptType,
  ? userContext: browser.UserContext,
  ? defaultValue: text
}
type および navigable が与えられたとき、 get navigable’s user prompt handler するには:
  1. user contextnavigableassociated user context とする。

  2. unhandled prompt behavior overrides mapuser context含む場合:

    1. unhandled prompt behavior overrideunhandled prompt behavior overrides map[user context] とする。

    2. unhandled prompt behavior override[type] が null でない場合、 unhandled prompt behavior override[type] を返す。

    3. unhandled prompt behavior override["default"] が null でない場合、 unhandled prompt behavior override["default"] を返す。

  3. handler configuration を、typeget the prompt handler したものとする。

  4. handler configurationhandler を返す。

remote end event trigger は、 Window window、文字列 type、文字列 message、および省略可能な text default value (既定値: null)が与えられたときの WebDriver BiDi user prompt opened steps である。
  1. navigablewindownavigable とする。

  2. navigable idnavigablenavigable id とする。

  3. user context id を、navigableassociated user contextuser context id とする。

  4. handler を、type および navigableget navigable’s user prompt handler したものとする。

  5. params を、 context フィールドを navigable id に、userContext フィールドを user context id に、type フィールドを type に、 message フィールドを message に、defaultValue フィールドを default value が null でなければ default value に設定し、 そうでなければ省略し、 かつ handler フィールドを handler に設定した、 browsingContext.UserPromptOpenedParameters 生成規則に一致する map とする。

  6. body を、 params フィールドを params に設定した、 browsingContext.UserPromptOpened 生成規則に一致する map とする。

  7. related navigables を、navigable を含む set とする。

  8. "browsingContext.userPromptOpened" および related navigables が与えられたものとして、 set of sessions for which an event is enabled 内の各 session について:

    1. session および bodyEmit an event する。

  9. handler が "ignore" である場合、handler を "none" に設定する。

  10. handler を返す。

7.4. emulation モジュール

emulation モジュールは、ブラウザー API のエミュレーションに関するコマンドおよびイベントを含む。

7.4.1. 定義

remote end definition

EmulationCommand = (
    emulation.SetForcedColorsModeThemeOverride //
    emulation.SetGeolocationOverride //
    emulation.SetLocaleOverride //
    emulation.SetNetworkConditions //
    emulation.SetScreenOrientationOverride //
    emulation.SetScreenSettingsOverride //
    emulation.SetScriptingEnabled //
    emulation.SetScrollbarTypeOverride //
    emulation.SetTimezoneOverride //
    emulation.SetTouchOverride //
    emulation.SetUserAgentOverride
    )

EmulationResult = (
    emulation.SetForcedColorsModeThemeOverrideResult /
    emulation.SetGeolocationOverrideResult /
    emulation.SetLocaleOverrideResult /
    emulation.SetScreenOrientationOverrideResult /
    emulation.SetScriptingEnabledResult /
    emulation.SetScrollbarTypeOverrideResult /
    emulation.SetTimezoneOverrideResult /
    emulation.SetTouchOverrideResult /
    emulation.SetUserAgentOverrideResult
    )

BiDi セッションは、エミュレートされたユーザーエージェントを持つ。これは 構造体であり、 既定のユーザーエージェントという名前の 項目を持ち、これは文字列または null であり、 ユーザーコンテキストのユーザーエージェントという名前の 項目を持ち、これはユーザーコンテキストと 文字列の間の weak map であり、また navigable のユーザーエージェントという名前の 項目を持ち、これはnavigableと文字列の間の weak map である。

BiDi セッションは、エミュレートされた maxTouchPointsを持つ。これは構造体であり、 既定という名前の項目を持ち、これは整数または null であり、初期状態では null である; ユーザーコンテキストという名前の項目を持ち、これはユーザーコンテキストと整数の間の weak map であり、 初期状態では空である; また、navigableという名前の項目を持ち、これはnavigableと整数の間の weak map であり、初期状態では空である。

画面向き オーバーライドは、以下を持つ構造体である:

リモートエンドは、画面向きオーバーライドマップを持つ。これは ユーザーコンテキスト画面 向きオーバーライドの間の weak map である。

7.4.2. コマンド

7.4.2.1. emulation.setForcedColorsModeThemeOverride コマンド

emulation.setForcedColorsModeThemeOverride コマンドは、指定された top-level traversables または user contexts 上の forced colors mode のテーマ特性を変更する。

コマンド型
emulation.SetForcedColorsModeThemeOverride = (
  method: "emulation.setForcedColorsModeThemeOverride",
  params: emulation.SetForcedColorsModeThemeOverrideParameters
)

emulation.SetForcedColorsModeThemeOverrideParameters = {
  theme: emulation.ForcedColorsModeTheme / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.ForcedColorsModeTheme = "light" / "dark"
戻り値型
emulation.SetForcedColorsModeThemeOverrideResult = EmptyResult

注: CSS 仕様における対応する enum mapping については、ForcedColorsModeAutomationTheme を参照すること。

remote endforced colors mode theme override configuration を持つ。これは associated type string を持つ WebDriver configuration である。

navigable navigable について update emulated forced colors theme するには:
  1. theme を、navigable についての forced colors mode theme override configurationget WebDriver configuration value の結果とする。

  2. Assert: theme は "light"、"dark" または unset である。

  3. themeunset である場合、theme を "none" に設定する。

  4. navigable および themeSet emulated forced colors theme data する。

command parametersを伴うリモートエンド手順は次のとおりである:

  1. themecommand parameters["theme"]とする。

  2. themeが null である場合、theme未設定に設定する。

  3. 実装がthemeの設定をサポートしない場合、エラーエラー コード unsupported operationで返す。

  4. affected navigablesを、command parametersについて forced colors mode theme override configuration theme試行してWebDriver 構成を格納する結果とする。

  5. affected navigablesの各navigableについて:

    1. navigableについてエミュレートされた forced colors テーマを更新する

  6. 成功をデータ null とともに返す。

7.4.2.2. emulation.setGeolocationOverride コマンド

emulation.setGeolocationOverride コマンドは、 指定された top-level traversables または user contexts 上の geolocation 特性を変更する。

コマンド型
emulation.SetGeolocationOverride = (
  method: "emulation.setGeolocationOverride",
  params: emulation.SetGeolocationOverrideParameters
)

emulation.SetGeolocationOverrideParameters = {
  (
    (coordinates: emulation.GeolocationCoordinates / null) //
    (error: emulation.GeolocationPositionError)
  ),
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.GeolocationCoordinates = {
   latitude: -90.0..90.0,
   longitude: -180.0..180.0,
   ? accuracy: (float .ge 0.0) .default 1.0,
   ? altitude: float / null .default null,
   ? altitudeAccuracy: (float .ge 0.0) / null .default null,
   ? heading: (0.0...360.0) / null .default null,
   ? speed: (float .ge 0.0) / null .default null,
}

emulation.GeolocationPositionError = {
   type: "positionUnavailable"
}
戻り値型
emulation.SetGeolocationOverrideResult = EmptyResult

位置情報 オーバーライドは、以下を持つ構造体である:

リモートエンドは、位置情報オーバーライド構成を持つ。これは、 位置情報オーバーライド関連付けられた型として持つWebDriver 構成である。

navigable navigableについて位置情報 オーバーライドを更新するには:
  1. emulated position dataを、navigableについて 位置情報オーバーライド構成WebDriver 構成値を取得する結果とする。

  2. emulated position data未設定である場合、emulated position dataを null に設定する。

  3. navigableおよびemulated position dataエミュレートされた位置データを設定する

command parameters によるリモートエンド手順は次の通りである:

  1. command parameters が "coordinates" を含みcommand parameters["coordinates"] が "altitudeAccuracy" を含み、 かつ command parameters["coordinates"] が "altitude" を含まない場合、 エラーエラーコード invalid argument で返す。

  2. command parameters が "error" を含む場合:

    1. command parameters["error"]["type"] が "positionUnavailable" と等しいことを表明する。

    2. emulated position data を、マップ とし、これは GeolocationPositionError 生成規則に一致し、code フィールドは POSITION_UNAVAILABLE に設定され、 message フィールドは空文字列に設定されるものとする。

      注: message は、 geolocation 仕様に従って実装により無視される。

  3. それ以外の場合、emulated position datacommand parameters["coordinates"] とする。

  4. emulated position data が null である場合、emulated position dataunset に設定する。

  5. affected navigables を、command parameters に対して geolocation override configuration emulated position dataWebDriver 設定を保存することを試行する結果とする。

  6. affected navigables の各 navigable について:

    1. navigable について geolocation override を更新する

  7. データ null で 成功を返す。

7.4.2.3. emulation.setLocaleOverride コマンド

emulation.setLocaleOverride コマンドは、 指定された top-level traversables または user contexts 上の locale を変更する。

コマンド型
emulation.SetLocaleOverride = (
  method: "emulation.setLocaleOverride",
  params: emulation.SetLocaleOverrideParameters
)

emulation.SetLocaleOverrideParameters = {
  locale: text / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetLocaleOverrideResult = EmptyResult

環境設定オブジェクト environment settings が与えられた WebDriver BiDi エミュレート言語手順:

  1. related navigables を、 environment settings が与えられた 関連する navigable を取得する結果とする。

  2. related navigables の各 navigable について:

    1. top-level traversablenavigableトップレベルトラバーサブルとする。

    2. user contexttop-level traversable関連付けられた ユーザーコンテキストとする。

    3. ロケールオーバーライドマップtop-level traversable含む場合、 ロケールオーバーライドマップ[top-level traversable] を返す。

    4. ロケールオーバーライドマップuser context含む場合、 ロケールオーバーライドマップ[user context] を返す。

  3. null を返す

command parameters によるリモートエンド手順は次の通りである:

  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. command parameters が "userContexts" を含まず、 かつ command parameters が "contexts" を含まない場合、 エラーエラー コード invalid argument で返す。

  3. emulated localecommand parameters["locale"] とする。

  4. emulated locale が null でなく、かつ IsStructurallyValidLanguageTag(emulated locale) が false を返す場合、エラーエラー コード invalid argument で返す。

  5. navigables集合とする。

  6. command parameterscontexts フィールドが存在する場合:

    1. navigables を、 command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

  7. それ以外の場合:

    1. command parametersuserContexts フィールドが存在することを表明する。

    2. user contexts を、command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    3. user contexts の各 user context について:

      1. emulated locale が null である場合、削除する user contextロケールオーバーライドマップから。

      2. それ以外の場合、設定する ロケール オーバーライドマップ[user context] を emulated locale に。

      3. トップレベルトラバーサブルのうち、その関連付けられたユーザーコンテキストuser context であるものすべてのリストの各 top-level traversable について:

        1. top-level traversablenavigables付加する

  8. navigables の各 navigable について:

    1. emulated locale が null である場合、削除する navigableロケールオーバーライドマップから。

    2. それ以外の場合、設定する ロケールオーバーライドマップ[navigable] を emulated locale に。

  9. データ null で 成功を返す。

7.4.2.4. emulation.setNetworkConditions コマンド

emulation.setNetworkConditions コマンドは、 指定された browsing context または user context に対して特定の network conditions をエミュレートする。

コマンド型
emulation.SetNetworkConditions = (
  method: "emulation.setNetworkConditions",
  params: emulation.SetNetworkConditionsParameters
)

emulation.SetNetworkConditionsParameters = {
  networkConditions: emulation.NetworkConditions / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.NetworkConditions = emulation.NetworkConditionsOffline

emulation.NetworkConditionsOffline = {
  type: "offline"
}
戻り値型
emulation.SetNetworkConditionsResult = EmptyResult

apply network conditions するには:

  1. WebSocket object webSocket について:

    1. realmwebSocketrelevant Realm とする。

    2. environment settings を、その realm execution context の Realm component が realm である environment settings object とする。

    3. environment settingsWebDriver BiDi network is offline した結果が true である場合:

      1. webSocket について Fail the WebSocket connection する。

  2. WebTransport object webTransport について:

    1. realmwebSocketrelevant Realm とする。

    2. environment settings を、その realm execution context の Realm component が realm である environment settings object とする。

    3. environment settingsWebDriver BiDi network is offline した結果が true である場合:

      1. webTransport について Cleanup WebTransport する。

command parameters および session によるリモートエンド手順は次の通りである:

  1. command parameters が "userContexts" を含み、 かつ command parameters が "context" を含む場合、 エラーエラー コード invalid argument で返す。

  2. emulated network conditions を null とする。

  3. command parameters["networkConditions"] が null でなく、かつ command parameters["networkConditions"]["type"] が "offline" に等しい場合、emulated network conditions を、 エミュレートされたネットワーク条件構造体である新しいものに設定し、 offline を true に設定する。

  4. command parameterscontexts フィールドが存在する場合:

    1. navigables を、command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

    2. navigables の各 navigable について:

      1. emulated network conditions が null である場合、 sessionエミュレートされたネットワーク 条件navigable network conditions から navigable削除する

      2. それ以外の場合、sessionエミュレートされたネットワーク 条件navigable network conditions[navigable] を emulated network conditions設定する

  5. command parametersuserContexts フィールドが存在する場合:

    1. user contexts を、command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    2. user contexts の各 user context について:

      1. emulated network conditions が null である場合、 sessionエミュレートされたネットワーク 条件user context network conditions から user context削除する

      2. それ以外の場合、sessionエミュレートされたネットワーク 条件user context network conditions[user context] を emulated network conditions設定する

  6. command parameters が "userContexts" を含まず、 かつ command parameters が "context" を含まない場合、 sessionエミュレートされたネットワーク条件デフォルトネットワーク 条件emulated network conditions設定する

  7. ネットワーク条件を適用する

  8. データ null で 成功を返す。

7.4.2.5. emulation.setScreenSettingsOverride コマンド

emulation.setScreenSettingsOverride コマンドは、 指定された top-level traversables または user contexts の web-exposed screen area および web-exposed available screen area をエミュレートする。

コマンド型
emulation.SetScreenSettingsOverride = (
  method: "emulation.setScreenSettingsOverride",
  params: emulation.SetScreenSettingsOverrideParameters
)

emulation.ScreenArea = {
  width: js-uint,
  height: js-uint
}

emulation.SetScreenSettingsOverrideParameters = {
  screenArea: emulation.ScreenArea / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetScreenSettingsOverrideResult = EmptyResult

navigable navigable が与えられた WebDriver BiDi のエミュレートされた利用可能な画面 領域手順:

  1. top-level traversablenavigableトップレベルトラバーサブルとする。

  2. user contexttop-level traversable関連付けられたユーザー コンテキストとする。

  3. 画面設定オーバーライドtop-level traversable含む場合、 画面設定オーバーライド[top-level traversable] を返す。

  4. 画面設定オーバーライドuser context を含む場合、 画面設定オーバーライド[user context] を返す。

  5. null を返す

navigable navigable が与えられた WebDriver BiDi のエミュレートされた合計画面領域手順:

  1. top-level traversablenavigableトップレベルトラバーサブルとする。

  2. user contexttop-level traversable関連付けられたユーザー コンテキストとする。

  3. 画面設定オーバーライドtop-level traversable を含む場合、 画面設定オーバーライド[top-level traversable] を返す。

  4. 画面設定オーバーライドuser context を含む場合、 画面設定オーバーライド[user context] を返す。

  5. null を返す

command parameters によるリモートエンド手順は次の通りである:

  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. command parameters が "userContexts" を含まず、 かつ command parameters が "contexts" を含まない場合、 エラーエラー コード invalid argument で返す。

  3. emulated screen areacommand parameters["screenArea"] とする。

  4. emulated screen area が null でない場合:

    1. emulated screen area["x"] を 0 に設定する

    2. emulated screen area["y"] を 0 に設定する

  5. navigables集合とする。

  6. command parameterscontexts フィールドが存在する場合:

    1. navigables を、 command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

    2. targetnavigable 画面 設定とする。

    3. navigables の各 navigable について:

      1. emulated screen area が null である場合、 navigabletarget から削除する

      2. それ以外の場合、target[navigable] を emulated screen area設定する

    4. データ null で 成功を返す。

  7. それ以外の場合:

    1. command parametersuserContexts フィールドが存在することを表明する。

    2. user contexts を、command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    3. targetユーザーコンテキスト 画面設定とする。

    4. user contexts の各 user context について:

      1. emulated screen area が null である場合、 user contexttarget から削除する

      2. それ以外の場合、target[user context] を emulated screen area設定する

    5. データ null で 成功を返す。

7.4.2.6. emulation.setScreenOrientationOverride コマンド

emulation.setScreenOrientationOverride コマンドは、 指定されたトップレベル辿可能またはユーザーコンテキストの画面の向きをエミュレートする。

コマンド型
emulation.SetScreenOrientationOverride = (
  method: "emulation.setScreenOrientationOverride",
  params: emulation.SetScreenOrientationOverrideParameters
)

emulation.ScreenOrientationNatural = "portrait" / "landscape"
emulation.ScreenOrientationType = "portrait-primary" / "portrait-secondary" / "landscape-primary" / "landscape-secondary"

emulation.ScreenOrientation = {
  natural: emulation.ScreenOrientationNatural,
  type: emulation.ScreenOrientationType
}

emulation.SetScreenOrientationOverrideParameters = {
  screenOrientation: emulation.ScreenOrientation / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetScreenOrientationOverrideResult = EmptyResult

navigableおよび emulated screen orientationが与えられたとき、エミュレートされた 画面の向きを設定するには:

このアルゴリズムを Screen Orientation 仕様へ移動すること。

  1. emulated screen orientationが null である場合:

    1. navigable現在の向きの角度を 実装定義の既定値に設定する。

    2. navigable現在の向きの型を 実装定義の既定値に設定する。

  2. そうでなければ:

    1. emulated orientation typeemulated screen orientation["type"]とする。

    2. emulated orientation angleを、画面の向き値 リストで定義される、emulated screen orientation["natural"]の向きを持つ画面について emulated orientation typeに関連付けられた角度とする。

    3. 現在の向きの角度emulated orientation angleに設定する。

    4. 現在の向きの型emulated orientation typeに設定する。

  3. navigableアクティブ文書で、画面の向き変更手順を実行する。

command parameters によるリモートエンド手順は次の通りである:

  1. 実装が、何らかの理由で、与えられた command parameters によって 画面の向き パラメーターを調整できない場合、エラーエラー コード unsupported operation で返す。

  2. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  3. command parameters が "userContexts" を含まず、 かつ command parameters が "contexts" を含まない場合、 エラーエラー コード invalid argument で返す。

  4. emulated screen orientationcommand parameters["screenOrientation"] とする。

  5. navigables集合とする。

  6. command parameterscontexts フィールドが存在する場合:

    1. navigables を、 command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

  7. それ以外で、command parametersuserContexts フィールドが 存在する場合:

    1. user contexts を、command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    2. user contexts の各 user context について:

      1. emulated screen orientation が null である場合、 user context画面の向きオーバーライド マップから削除する

      2. それ以外の場合、画面の向きオーバーライド マップ[user context] を emulated screen orientation設定する

      3. すべてのトップレベルトラバーサブルのリストのうち、 その関連付けられたユーザーコンテキストuser context である各 top-level traversable について:

        1. top-level traversablenavigables付加する

  8. navigables の各 navigable について:

    1. user contextnavigable関連付けられた ユーザーコンテキストとする。

    2. emulated screen orientation が null であり、かつ 画面の向きオーバーライドマップuser context含む場合、navigable および 画面の向きオーバーライド マップ[user context] で エミュレートされた画面の向きを設定する

    3. それ以外の場合、navigable および emulated screen orientationエミュレートされた画面の向きを設定する

  9. データ null で 成功を返す。

7.4.2.7. emulation.setUserAgentOverride コマンド

emulation.setUserAgentOverride コマンドは、 指定されたトップレベル辿可能、ユーザーコンテキスト、またはグローバルにおける User-Agent を変更する。

コマンド型
emulation.SetUserAgentOverride = (
  method: "emulation.setUserAgentOverride",
  params: emulation.SetUserAgentOverrideParameters
)

emulation.SetUserAgentOverrideParameters = {
  userAgent: text / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetUserAgentOverrideResult = EmptyResult
環境設定オブジェクト environment settingsが与えられたときのWebDriver BiDi エミュレートされた User-Agent手順は次のとおりである:
  1. related navigablesを、environment settings関連する navigable を取得する結果とする。

  2. related navigablesの各navigableについて:

    1. top-level navigableを、navigableトップレベル辿可能とする。

    2. user contextを、top-level navigable関連付けられた ユーザーコンテキストとする。

    3. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされたユーザーエージェントnavigable ユーザー エージェントtop-level navigableを含む場合、sessionエミュレートされたユーザーエージェントnavigable ユーザー エージェント[top-level navigable]を返す。

    4. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされたユーザーエージェントユーザーコンテキストのユーザー エージェントuser contextを含む場合、sessionエミュレートされたユーザーエージェントユーザーコンテキストのユーザー エージェント[user context]を返す。

  3. アクティブ BiDi セッション内の各sessionについて:

    1. default emulated user agentを、sessionエミュレートされたユーザーエージェント既定のユーザーエージェントとする。

    2. default emulated user agentが null でない場合、 default emulated user agentを返す。

  4. null を返す。

session および command parameters が与えられたリモートエンド手順は次の通りである:

  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. emulated user agentcommand parameters["userAgent"] とする。

  3. command parameters が "contexts" を含む場合:

    1. navigables を、 command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

    2. navigables の各 navigable について:

      1. emulated user agent が null である場合、 navigablesessionエミュレートされたユーザーエージェントnavigable user agentから削除する

      2. それ以外の場合、sessionエミュレートされたユーザーエージェントnavigable user agent[navigable] を emulated user agent設定する

    3. データ null で 成功を返す。

  4. command parameters が "userContexts" を含む場合:

    1. user contexts を、 command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    2. user contexts の各 user context について:

      1. emulated user agent が null である場合、 user contextsessionエミュレートされたユーザーエージェントuser context user agentから削除する

      2. それ以外の場合、sessionエミュレートされたユーザーエージェントuser context user agent[user context] を emulated user agent設定する

    3. データ null で 成功を返す。

  5. sessionエミュレートされたユーザー エージェントdefault user agentemulated user agent設定する

  6. データ null で 成功を返す。

7.4.2.8. emulation.setScriptingEnabled コマンド

emulation.setScriptingEnabled コマンドは、 ウェブページ上で JavaScript が無効化されることをエミュレートする。

コマンド型
emulation.SetScriptingEnabled = (
  method: "emulation.setScriptingEnabled",
  params: emulation.SetScriptingEnabledParameters
)

emulation.SetScriptingEnabledParameters = {
  enabled: false / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetScriptingEnabledResult = EmptyResult

注記: 無効化された Javascript のエミュレーションのみが サポートされる。

環境設定オブジェクト settingsが与えられたときのWebDriver BiDi スクリプトが有効か手順は次のとおりである:
  1. navigableを、settings関連する大域オブジェクト関連付けられたDocumentノード navigableとする。

  2. top-level traversableを、navigableトップレベル辿可能とする。

  3. スクリプト有効化オーバーライドマップtop-level traversableを含む場合、 スクリプト有効化オーバーライド マップ[top-level traversable]を返す

  4. user contextを、top-level traversable関連付けられたユーザー コンテキストとする。

  5. スクリプト有効化オーバーライドマップuser contextを含む場合、 スクリプト有効化オーバーライドマップ[user context]を返す。

  6. true を返す。

command parameters によるリモートエンド手順は次の通りである:

  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. command parameters が "userContexts" を含まず、 かつ command parameters が "contexts" を含まない場合、 エラーエラー コード invalid argument で返す。

  3. emulated scripting enabled statuscommand parameters["enabled"] とする。

  4. command parameterscontexts フィールドが存在する場合:

    1. navigables を、 command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

    2. navigables の各 navigable について:

      1. emulated scripting enabled status が null である場合、 navigableスクリプト有効オーバーライド マップから削除する

      2. それ以外の場合、スクリプト有効オーバーライド マップ[navigable] を emulated scripting enabled status設定する

  5. command parametersuserContexts フィールドが存在する場合:

    1. user contexts を、 command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    2. user contexts の各 user context について:

      1. emulated scripting enabled status が null である場合、 user contextスクリプト有効オーバーライド マップから削除する

      2. それ以外の場合、スクリプト有効オーバーライド マップ[user context] を emulated scripting enabled status設定する

  6. データ null で 成功を返す。

7.4.2.9. emulation.setScrollbarTypeOverride コマンド

emulation.setScrollbarTypeOverride コマンドは、 指定されたトップレベル辿可能、ユーザーコンテキスト、またはグローバルにおける スクロールバー型を変更する。

コマンド型
emulation.SetScrollbarTypeOverride = (
  method: "emulation.setScrollbarTypeOverride",
  params: emulation.SetScrollbarTypeOverrideParameters
)

emulation.SetScrollbarTypeOverrideParameters = {
  scrollbarType: "classic" / "overlay" / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetScrollbarTypeOverrideResult = EmptyResult

リモートエンドは、スクロールバー型オーバーライド構成を持つ。これは string を関連付けられた型として持つWebDriver 構成である。

navigable navigableについてスクロールバー型 オーバーライドを更新するには:
  1. scrollbar type overrideを、navigableについて スクロールバー型オーバーライド構成WebDriver 構成値を取得する結果とする。

  2. 表明:scrollbar type overrideは "classic"、 "overlay"、または 未設定である。

  3. scrollbar type overrideが "classic" である場合、navigableアクティブ文書classic scrollbarsを使用させるための実装定義の手順を実行して戻る。

  4. scrollbar type overrideが "overlay" である場合、navigableアクティブ文書overlay scrollbarsを使用させるための実装定義の 手順を実行して戻る。

  5. 表明:scrollbar type override未設定である。

  6. navigableアクティブ文書実装定義の既定スクロールバー型を使用させるための 実装定義の手順を実行する。

command parametersが与えられたときのリモートエンド手順は次のとおりである:

  1. scrollbar type overridecommand parameters["scrollbarType"]とする。

  2. scrollbar type overrideが null である場合、scrollbar type override未設定に設定する。

  3. 実装がscrollbar type overrideの設定をサポートしない場合、エラーエラーコード unsupported operationで返す。

  4. affected navigablesを、command parametersについて スクロールバー型オーバーライド 構成 scrollbar type override試行してWebDriver 構成を格納する結果とする。

  5. affected navigablesの各navigableについて:

    1. navigableについてスクロールバー型オーバーライドを更新する

  6. 成功をデータ null とともに返す。

7.4.2.10. emulation.setTimezoneOverride コマンド

emulation.setTimezoneOverride コマンドは、 指定されたトップレベル辿可能またはユーザーコンテキストにおける タイムゾーンを変更する。

コマンド型
emulation.SetTimezoneOverride = (
  method: "emulation.setTimezoneOverride",
  params: emulation.SetTimezoneOverrideParameters
)

emulation.SetTimezoneOverrideParameters = {
  timezone: text / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetTimezoneOverrideResult = EmptyResult
SystemTimeZoneIdentifier アルゴリズムは実装定義である。 WebDriver-BiDi リモートエンド は、次の手順を実行する実装を 持たなければならない:
  1. emulated timezone を null とする。

  2. realm現在の Realm Record とする。

  3. environment settings を、 環境設定オブジェクトであって、その レルム実行コンテキストの Realm コンポーネントが realm であるものとする。

  4. related navigables を、 environment settings が与えられた 関連する navigable を取得する結果とする。

  5. related navigables の各 navigable について:

    1. top-level traversablenavigableトップレベルトラバーサブルとする。

    2. user contexttop-level traversable関連付けられた ユーザーコンテキストとする。

    3. タイムゾーンオーバーライドマップtop-level traversable含む場合、emulated timezoneタイムゾーンオーバーライドマップ[top-level traversable] に設定する。

    4. それ以外で、タイムゾーンオーバーライドマップuser context含む場合、emulated timezoneタイムゾーンオーバーライドマップ[user context] に設定する。

  6. emulated timezone が null でない場合、emulated timezone を返す。

  7. SystemTimeZoneIdentifier 仕様の要件に従った、 実装定義の手順の結果を返す。

command parameters によるリモートエンド手順は次の通りである:

  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. command parameters が "userContexts" を含まず、 かつ command parameters が "contexts" を含まない場合、 エラーエラー コード invalid argument で返す。

  3. emulated timezonecommand parameters["timezone"] とする。

  4. emulated timezone が null でなく、かつ IsTimeZoneOffsetString(emulated timezone) が false を返し、かつ AvailableNamedTimeZoneIdentifiersemulated timezone含まない場合、エラーエラーコード invalid argument で返す。

  5. navigables集合とする。

  6. command parameterscontexts フィールドが存在する場合:

    1. navigables を、 command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

  7. それ以外の場合:

    1. command parametersuserContexts フィールドが存在することを表明する。

    2. user contexts を、command parameters["userContexts"] を用いて 有効なユーザーコンテキストを取得することを 試行する結果とする。

    3. user contexts の各 user context について:

      1. emulated timezone が null である場合、 user contextタイムゾーンオーバーライドマップから削除する

      2. それ以外の場合、タイムゾーン オーバーライドマップ[user context] を emulated timezone設定する

      3. すべてのトップレベルトラバーサブルのリストのうち、 その関連付けられたユーザーコンテキストuser context である各 top-level traversable について:

        1. top-level traversablenavigables付加する

  8. navigables の各 navigable について:

    1. emulated timezone が null である場合、 navigableタイムゾーンオーバーライドマップから削除する

    2. それ以外の場合、タイムゾーン オーバーライドマップ[navigable] を emulated timezone設定する

  9. データ null で 成功を返す。

7.4.2.11. emulation.setTouchOverride コマンド

emulation.setTouchOverride コマンドは、 ウェブページ上でタッチ入力が有効化されることをエミュレートする。

コマンド型
emulation.SetTouchOverride = (
  method: "emulation.setTouchOverride",
  params: emulation.SetTouchOverrideParameters
)

emulation.SetTouchOverrideParameters = {
  maxTouchPoints: (js-uint .ge 1) / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
戻り値型
emulation.SetTouchOverrideResult = EmptyResult
環境設定オブジェクト environment settingsが与えられたときのWebDriver BiDi エミュレートされた最大タッチポイント数手順は次のとおりである:
  1. related navigablesを、environment settings関連する navigable を取得する結果とする。

  2. related navigablesの各navigableについて:

    1. top-level navigableを、navigableトップレベル辿可能とする。

    2. user contextを、top-level navigable関連付けられた ユーザーコンテキストとする。

    3. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされた maxTouchPointsnavigabletop-level navigableを含む場合、 sessionエミュレートされた maxTouchPointsnavigable[top-level navigable]を返す。

    4. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされた maxTouchPointsユーザーコンテキストuser contextを含む場合、sessionエミュレートされた maxTouchPointsユーザー コンテキスト[user context]を返す。

  3. アクティブ BiDi セッション内の各sessionについて:

    1. emulated maxTouchPointsを、sessionエミュレートされた maxTouchPoints既定とする。

    2. emulated maxTouchPointsが null でない場合、emulated maxTouchPointsを返す。

  4. null を返す。

sessionおよびcommand parametersを伴うリモートエンド手順は次のとおりである:

注記: レガシーなレガシータッチイベント API を公開する仕組みがあり、 これは、ユーザーエージェントがタッチ対応の「モバイル」デバイスであることを示すシグナルとして、一部の既存の ウェブコンテンツによって現在も使用されることがある。API はレガシーであるものの、ユーザーエージェントは レガシータッチイベント API を公開するにおいて、 エミュレートされた maxTouchPoints状態を尊重するための実装定義の手順を実行することがある。

  1. command parameters含み "userContexts" かつ command parameters含む "contexts" 場合、エラーエラー コード invalid argument で返す。

  2. maxTouchPointscommand parameters["maxTouchPoints"]とする。

  3. command parameterscontextsフィールドが存在する場合:

    1. navigablesを、 command parameters["contexts"]で試行して ID により有効なトップレベル 辿可能を取得する 結果とする。

    2. navigablesの各navigableについて:

      1. maxTouchPointsが null である場合、 navigablesessionエミュレートされた maxTouchPointsnavigableから除去する

      2. そうでなければ、sessionエミュレートされた maxTouchPointsnavigable[navigable]を maxTouchPoints設定する

    3. 成功をデータ null とともに返す。

  4. command parametersuserContextsフィールドが存在する場合:

    1. user contextsを、 command parameters["userContexts"]で試行して 有効なユーザーコンテキストを取得する結果とする。

    2. user contextsの各user contextについて:

      1. maxTouchPointsが null である場合、 user contextsessionエミュレートされた maxTouchPointsユーザーコンテキストから除去する

      2. そうでなければ、sessionエミュレートされた maxTouchPointsユーザー コンテキスト[user context]をmaxTouchPoints設定する

    3. 成功をデータ null とともに返す。

  5. sessionエミュレートされた maxTouchPoints既定maxTouchPointsに設定する。

  6. 成功をデータ null とともに返す。

7.5. network モジュール

network モジュールは、ネットワークリクエストに関係するコマンドとイベントを 含む。

7.5.1. 定義

remote end definition

NetworkCommand = (
  network.AddDataCollector //
  network.AddIntercept //
  network.ContinueRequest //
  network.ContinueResponse //
  network.ContinueWithAuth //
  network.DisownData //
  network.FailRequest //
  network.GetData //
  network.ProvideResponse //
  network.RemoveDataCollector //
  network.RemoveIntercept //
  network.SetCacheBehavior //
  network.SetExtraHeaders
)

local end definition

NetworkResult = (
  network.AddDataCollectorResult /
  network.AddInterceptResult /
  network.ContinueRequestResult /
  network.ContinueResponseResult /
  network.ContinueWithAuthResult /
  network.DisownDataResult /
  network.FailRequestResult /
  network.GetDataResult /
  network.ProvideResponseResult /
  network.RemoveDataCollectorResult /
  network.RemoveInterceptResult /
  network.SetCacheBehaviorResult /
  network.SetExtraHeadersResult
)

NetworkEvent = (
    network.AuthRequired //
    network.BeforeRequestSent //
    network.FetchError //
    network.ResponseCompleted //
    network.ResponseStarted
)

リモートエンドは、before request sent マップを持つ。これは初期状態では 空のマップである。これは、network.beforeRequestSentイベントがすでに送信された ネットワークイベントを追跡するために使用される。

リモートエンドは、文字列である既定のキャッシュ挙動を持つ。これは 初期状態では "default" である。

リモートエンドは、navigable キャッシュ挙動マップを持つ。これは トップレベル辿可能とキャッシュ挙動を表す文字列の間の weak map である。これは初期状態では空である。

BiDi セッションは、追加ヘッダーを持つ。これは、 既定の ヘッダーという名前の項目を持つ構造体である。 これはヘッダー リスト(初期状態では空のヘッダーリストに設定される)であり、 ユーザーコンテキストヘッダーという名前の項目を持ち、 これはユーザーコンテキストヘッダーリストの間の weak map であり、また navigable ヘッダーという名前の項目を持ち、 これはnavigableヘッダー リストの間の weak map である。

7.5.2. ネットワークデータ収集

ネットワークデータは、以下を持つ構造体である:

collectorは、以下を持つ構造体である:

注記: 最大 エンコード済み項目サイズは項目(レスポンスまたはリクエスト)ごとの上限を定義し、 特定の collector によって収集されるサイズを制限しない。収集されるすべてのリソースの総サイズは 最大総収集サイズによって制限される。

BiDi セッションは、ネットワーク collectorを持つ。 これは network.Collectorcollectorの間のマップである。これは 初期状態では空である。

リモートエンドは、収集されたネットワークデータを持つ。これは ネットワークデータのリストである。これは初期状態では 空である。

リモートエンドは、最大総収集サイズを持つ。これは 収集されたネットワークデータでネットワークデータを収集するために割り当てられる サイズを表す js-uint である。その値は実装定義である。

注記: これにより、実装はリソース使用量の 制限を設定できる。 その制限は十分に大きく、ウェブページで使用される画像やフォントなど、 ブラウザーによって完全にデコードされ処理されるデータを収集できるとユーザーが期待できるものとされる。

request が与えられたとき、get navigable for request するには:
  1. navigable を null とする。

  2. requestclientenvironment settings object である場合:

    1. environment settingsrequestclient とする

    2. environment settingsglobal objectactive window である navigable が存在する場合、 navigable をその navigable に設定する。

  3. navigable を返す。

collector および navigable が与えられたとき、 match collector for navigable するには:
  1. collectorcontextsでない場合:

    1. collectorcontextsnavigablenavigable id含む場合、true を返す。

    2. そうでなければ、false を返す。

  2. collectoruser contextsでない場合:

    1. user contextnavigableassociated user context とする。

    2. collectoruser contextsuser contextuser context id含む場合、true を返す。

    3. そうでなければ、false を返す。

  3. true を返す。

request request が与えられたときの WebDriver BiDi clone network request body steps は次である:
  1. requestbody が null である場合、戻る。

  2. active BiDi sessions 内の各 session について:

    1. sessionnetwork collectorsでない場合:

      1. collected data を、 network data とし、 bytes を null に設定し、 cloned bodyrequestbodyclone に設定し、 collectors を空の list に設定し、 pending を true に設定し、 requestrequestrequest id に設定し、 size を null に設定し、 type を "request" に設定したものとする。

      2. collected datacollected network data追加する

      3. 戻る。

request および response body が与えられたときの WebDriver BiDi clone network response body steps は次である:
  1. response body が null である場合、戻る。

  2. active BiDi sessions 内の各 session について:

    1. sessionnetwork collectorsでない場合:

      1. collected data を、 network data とし、 bytes を null に設定し、 cloned bodyresponse bodyclone に設定し、 collectors を空の list に設定し、 pending を true に設定し、 requestrequestrequest id に設定し、 size を null に設定し、 type を "response" に設定したものとする。

      2. collected datacollected network data追加する

      3. 戻る。

request id および data type が与えられたとき、 get collected data するには。
  1. collected network data の各 collected data について:

    1. collected datarequestrequest id であり、 かつ collected datatypedata type である場合、 collected data を返す。

  2. null を返す。

request が与えられたとき、 maybe abort network response body collection するには:
  1. collected data を、requestrequest id および "response" で get collected data したものとする。

  2. collected data が null である場合、戻る。

  3. collected datapending を false に設定する。

  4. "network data collected" および (requestrequest id, "response") で Resume する。

request が与えられたとき、 maybe collect network request body するには:
  1. collected data を、requestrequest id および "request" で get collected data したものとする。

  2. collected data が null である場合、戻る。

    注: これは、request が作成されたときに collectors が設定されておらず、 WebDriver BiDi clone network request body が対応する body を clone しない場合に起こり得る。 または、そもそも body が null であった場合にも起こり得る。

  3. requestcollected data、null、および "request" で Maybe collect network data する。

request および response が与えられたとき、 maybe collect network response body するには:
  1. responsestatusredirect status である場合、戻る。

    注: redirects については、最終 response body のみが保存される。

  2. collected data を、requestrequest id および "response" で get collected data したものとする。

  3. collected data が null である場合、戻る。

    注: これは、response が作成されたときに collectors が設定されておらず、 WebDriver BiDi clone network response body が対応する body を clone しない場合に起こり得る。 または、そもそも body が null であった場合にも起こり得る。

  4. size を、responseresponse body infoencoded size とする。

    注: fetch stream から取得される bytes は decoded data に対応するが、size limits を計算するためには encoded (network) size が使用される、 という不一致がある。実装は、getData で clients に返される data が decoded data と同一である限り、 decoded data を保存するよりも少ない size を使用する storage model を採用してもよい。 storage と performance の潜在的な tradeoff は実装次第である。

  5. requestcollected datasize および "response" で Maybe collect network data する。

request requestnetwork data collected data、js-uint size および network.DataType data type が与えられたとき、 maybe collect network data するには:
  1. collected datapending を false に設定する。

  2. navigable を、 requestget navigable for request したものとする。

  3. navigable が null である場合:

    1. collected datacollected network data から削除する

    2. "network data collected" および (requestrequest id, data type) で Resume する。

    3. 戻る。

    これは navigable に関係しない data の収集を防ぐ。 collector configuration に照らして確認するために navigable を取得する必要はまだあるが、 ここで null を受け入れることもできる。

  4. top-level navigablenavigabletop-level traversable とする。

  5. collectors を空の list とする。

  6. active BiDi sessions 内の各 session について:

    1. sessionnetwork collectors 内の各 collector について:

      1. collectordata typesdata type含み、かつ collector および top-level navigablematch collector for navigable した場合:

        1. collectorcollectors追加する

  7. collectorsである場合:

    1. collected datacollected network data から削除する

    2. "network data collected" および (requestrequest id, data type) で Resume する。

    3. 戻る。

  8. bytes を null とする。

  9. nullOrBytes が与えられたときの processBody を、このステップとする:

    1. nullOrBytes が null でない場合:

      1. bytes を、 nullOrBytesserialize protocol bytes した結果に設定する。

      2. size が null である場合、sizebyteslength に設定する。

  10. processBodyError を、このステップとする: 何もしない。

  11. processBody および processBodyError が与えられたものとして、collected datacloned bodyFully read する。

  12. bytes が null でない場合:

    1. collectors 内の各 collector について:

      1. sizecollectormax encoded item size 以下である場合、 collectorcollectorcollected datacollectors追加する

    2. collected datacollectorsでない場合:

      1. size が与えられたものとして Allocate size to record data する。

      2. collected databytesbytes に設定する。

      3. collected datasizesize に設定する。

    3. そうでなければ、collected datacollected network data から削除する

  13. "network data collected" および (requestrequest id, data type) で Resume する。

size が与えられたとき、allocate size to record data するには:
  1. available sizemax total collected size とする。

  2. already collected data を空の list とする。

  3. collected network data 内の各 collected data について:

    1. collected databytes が null でない場合:

      1. available sizecollected datasize だけ減らす。

      2. collected dataalready collected data追加する

  4. sizeavailable size より大きい場合:

    1. already collected data 内の各 collected data について:

      1. available sizecollected datasize だけ増やす。

      2. collected databytes field を null に設定する。

      3. collected datasize field を null に設定する。

      4. available sizesize 以上である場合、戻る。

collected data および collector id が与えられたとき、 remove collector from data するには:
  1. collected datacollectorscollector id含む場合:

    1. collector idcollected datacollectors から削除する

    2. collected datacollectorsである場合:

      1. collected datacollected network data から削除する

7.5.3. ネットワークインターセプト

ネットワークインターセプト は、リモートエンドがネットワークリクエストおよびレスポンスをインターセプトし、 変更できるようにする仕組みである。

BiDi セッションは、インターセプトマップを持つ。これは intercept id と、アクティブなネットワークインターセプトのプロパティを定義する url patternsphases、およびcontextsフィールドを持つ構造体との間の マップ である。これは初期状態では空である。

BiDi セッションは、ブロックされたリクエスト マップを持ち、アクティブにブロックされている リクエストを追跡するために使用される。これはリクエスト ID と、requestphase、および responseフィールドを持つ構造体 との間のマップである。 これは初期状態では空である。

sessioneventrequest、および navigable idが与えられたとき、ネットワーク インターセプトを取得するには:

  1. session interceptsを、sessionインターセプトマップとする。

  2. interceptsを空のリストとする。

  3. 最初に一致する条件の下の手順を実行する:

    event is "network.beforeRequestSent"
    phaseを "beforeRequestSent" に設定する。
    event is "network.responseStarted"
    phaseを "responseStarted" に設定する。
    event is "network.authRequired"
    phaseを "authRequired" に設定する。
    event is "network.responseCompleted"
    interceptsを返す。
  4. urlを、requestURLURL シリアライザーを実行した結果とする。

  5. session interceptsの各intercept idinterceptについて:

    1. interceptcontextsが null でない場合:

      1. interceptcontextsnavigable id含まない場合:

        1. 続行する。

    2. interceptphasesphase含む場合:

      1. url patternsを、intercepturl patternsとする。

      2. url patternsである場合:

        1. intercept idintercepts付加する

        2. 続行する。

      3. url patterns内の各url patternについて:

        1. url patternおよびurlURL パターンに一致する場合:

          1. intercept idintercepts付加する

          2. 中断する。

  6. interceptsを返す。

sessioncommand、およびcommand parametersが与えられたとき、 response を更新するには:
  1. blocked requestsを、sessionブロックされたリクエストマップとする。

  2. request idを、command parameters["request"]とする。

  3. blocked requestsrequest id含まない 場合、エラーエラー コード no such requestで返す。

  4. (request, phase, response)を、blocked requests[request id]とする。

  5. phaseが "beforeRequestSent" であり、かつcommandが "continueResponse" である場合、エラーエラーコード "invalid argument"で返す。

    TODO: 別のエラーを検討する

  6. responseが null である場合:

    1. 表明:phaseは "beforeRequestSent" である。

    2. responseを新しいresponseに設定する。

  7. command parametersが "statusCode"を含む場合:

    1. responsesstatuscommand parameters["statusCode"]に設定する。

  8. command parametersが "reasonPhrase"を含む場合:

    1. responsesstatus messageを、 command parameters["reasonPhrase"]でUTF-8 encodeしたものに設定する。

  9. command parametersが "headers"を含む場合:

    1. headersを、 command parameters["headers"]で試行して ヘッダーリストを作成する結果とする。

    2. responseヘッダーリストheadersに設定する。

  10. command parametersが "cookies"を含む場合:

    1. command parametersが "headers" を含む場合、 headersresponseヘッダーリストとする。

      そうでなければ:

      1. headersを空のヘッダーリストとする。

      2. responseheaders list内の各headerについて:

        1. nameheaderの name とする。

        2. namebyte-lowercaseしたものが `set-cookie`でない場合:

          1. headerheadersに付加する

    2. command parameters["cookies"]内の各cookieについて:

      1. header valueを、cookieset-cookie ヘッダーを直列化する 結果とする。

      2. (`Set-Cookie`, header value)を headersに付加する。

      3. responseヘッダーリストheadersに設定する。

  11. command parametersが "credentials"を含む場合:

    これには 認証をキャンセルする方法がない。

    1. credentialsを、command parameters["credentials"]とする。

    2. 表明:credentials["type"]は "password" である。

    3. responseの authentication credentials を (credentials["username"], credentials["password"]) に設定する

  12. responseを返す

7.5.4.

7.5.4.1. network.AuthChallenge 型
network.AuthChallenge = {
  scheme: text,
  realm: text,
}

response が与えられたとき、extract challenges するには:

realm 以外の parameters も含めるべきか?

  1. responsestatus が 401 である場合、header name を `WWW-Authenticate` とする。そうでなく、responsestatus が 407 である場合、 header name を `Proxy-Authenticate` とする。そうでなければ null を返す。

  2. challenges を新しい list とする。

  3. responseheader list 内の各 (name, value) について:

    Fetch と同様に、 複数 headers、parsing issues などを処理する正しい方法であるかどうかは不明である。

    1. nameheader name に対する byte-case-insensitive match である場合:

      1. header challenges を、value を challenges の list に parse した結果とする。各 challenge は scheme および parameters の list からなり、 各 parameter は tuple (name, value) であり、[RFC9110] の規則に従う。

      2. header challenges 内の各 header challenge について:

        1. schemeheader challenge の scheme とする。

        2. realm を空文字列とする。

        3. header challenge の parameters 内の各 (param name, param value) について:

          1. param name が `realm` と等しい場合、 realmparam valueUTF-8 decode した結果とする。

        4. challenge を、 scheme field を scheme に設定し、 realm field を realm に設定した、 network.AuthChallenge production に一致する新しい map とする。

      3. challengechallenges追加する

  4. challenges を返す。

7.5.4.2. network.AuthCredentials 型
network.AuthCredentials = {
  type: "password",
  username: text,
  password: text,
}

network.AuthCredentials 型は、authorization credentials に対する request への response を表す。

7.5.4.3. network.BaseParameters 型
network.BaseParameters = (
    context: browsingContext.BrowsingContext / null,
    isBlocked: bool,
    navigation: browsingContext.Navigation / null,
    redirectCount: js-uint,
    request: network.RequestData,
    timestamp: js-uint,
    ? userContext: browser.UserContext / null,
    ? intercepts: [+network.Intercept]
)

network.BaseParameters 型は、すべての network events に共通する data を表す抽象型である。

context に加えて、 request を開始した document node の `sharedId` を含めることを検討する。

sessionevent、および request が与えられたとき、 process a network event するには:
  1. request data を、requestget the request data した結果とする。

  2. navigationrequestnavigation id とする。

  3. navigable id を null とする。

  4. top-level navigable id を null とする。

  5. user context id を null とする。

  6. requestclientenvironment settings object である場合:

    1. environment settingsrequestclient とする。

    2. environment settingsglobal objectactive window である navigable が存在する場合、navigable id をその navigable の navigable id に設定し、top-level navigable id をその navigable の top-level traversablenavigable id に設定し、 user context id をその navigable の associated user contextuser context id に設定する。

  7. intercepts を、 sessioneventrequest、および top-level navigable idget the network intercepts した結果とする。

  8. redirect countrequestredirect count とする。

  9. timestamp を、UTC における現在の日付と時刻を表す time value とする。

  10. interceptsでない場合、 is blocked を true とし、そうでなければ is blocked を false とする。

  11. params を、network.BaseParameters production に一致する map とし、 request field を request data に設定し、 navigation field を navigation に設定し、context field を navigable id に設定し、userContext field を user context id に設定し、timestamp field を timestamp に設定し、 redirectCount field を redirect count に設定し、 isBlocked field を is blocked に設定し、is blocked が true である場合は intercepts field を intercepts に設定し、そうでなければ省略する。

  12. params を返す

7.5.4.4. network.BytesValue 型
network.BytesValue = network.StringValue / network.Base64Value;

network.StringValue = {
  type: "string",
  value: text,
}

network.Base64Value = {
  type: "base64",
  value: text,
}

network.BytesValue 型は、network を通じて送信される binary data を表す。 valid UTF-8 は network.StringValue 型で表され、 その他の data は Base64-encoded form として network.Base64Value で表される。

protocol bytes が与えられたとき、deserialize protocol bytes するには:

注: これは network.BytesValue として encode された bytes を受け取り、 byte sequence を返す。

  1. protocol bytesnetwork.StringValue production に一致する場合、 bytes を、protocol bytes["value"] で UTF-8 encode した結果とする。

  2. そうでなく、protocol bytesnetwork.Base64Value production に一致する場合、bytes を、protocol bytes["value"] で forgiving-base64 decode した結果とする。

  3. bytes を返す。

bytesが与えられたとき、プロトコル バイトを直列化するには:

注記: これはバイト列を受け取り、 network.BytesValueを返す。

  1. textを、bytesBOM なしで UTF-8 デコードまたは失敗 した結果とする。

  2. textが failure である場合、valuebytesforgiving-base64 encodeしたものに設定された、 network.Base64Value生成規則に一致するマップを返す。

  3. valuetextに設定された、network.StringValue生成規則に一致する マップを返す。

7.5.4.5. network.Collector 型

リモートエンド定義 および ローカルエンド定義

network.Collector = text

network.Collector 型は、collectorの ID を表す。

7.5.4.6. network.CollectorType 型

リモートエンド定義 および ローカルエンド定義

network.CollectorType = "blob"

注記: 将来的には、ストリームを介して指定された collector により 収集されたデータを読み取りたいクライアント向けに、"stream" collector 型もサポートする可能性がある。

network.CollectorType 型は、追加できるデータ collector のさまざまな型を表す。

リモートエンド定義 および ローカルエンド定義

network.SameSite = "strict" / "lax" / "none" / "default"


network.Cookie = {
    name: text,
    value: network.BytesValue,
    domain: text,
    path: text,
    size: js-uint,
    httpOnly: bool,
    secure: bool,
    sameSite: network.SameSite,
    ? expiry: js-uint,
    Extensible,
}

network.Cookie 型は Cookie を表す。

stored cookieが与えられたとき、Cookie を直列化する には:
  1. nameを、stored cookieの name フィールドでUTF-8 decodeした結果とする。

  2. valueを、stored cookieの value でプロトコルバイトを直列化する結果とする。

  3. domainを、stored cookieの domain フィールドとする。

  4. pathを、stored cookieの path フィールドとする。

  5. expiryを、stored cookieの expiry-time フィールドが設定されている場合は unix タイムスタンプとして表したもの、そうでなければ null とする。

  6. sizeを、stored cookieCookieヘッダー内で表されるものとして直列化した結果のバイト長とする。

  7. http onlyを、stored cookieの http-only-flag が true であれば true、 そうでなければ false とする。

  8. secureを、stored cookieの secure-only-flag が true であれば true、 そうでなければ false とする。

  9. same siteを、stored cookieの same-site-flag が "None" であれば "none"、"Lax" であれば "lax"、 "Strict" であれば "strict"、 "Default" であれば "default" とする

  10. network.Cookie生成規則に一致するマップを返す。 そのnameフィールドはnameに、valueフィールドは valueに、domainフィールドはdomainに、 pathフィールドはpathに、expiryフィールドは expiryが null でなければexpiryに設定され、そうでなければ省略され、 sizeフィールドはsizeに、httpOnlyフィールドはhttp onlyに、 secureフィールドはsecureに、そしてsameSite フィールドはsame siteに設定される。

7.5.4.8. network.CookieHeader 型

リモートエンド定義

network.CookieHeader = {
    name: text,
    value: network.BytesValue,
}

network.CookieHeader 型は、Cookieリクエストヘッダー内にある Cookie データの部分集合を表す。

protocol cookieが与えられたとき、Cookie ヘッダーを直列化するには:
  1. nameを、protocol cookie["name"]をUTF-8 encodeしたものとする。

  2. valueを、protocol cookie["value"]でプロトコルバイトを逆直列化する結果とする。

  3. header valueを、name、 `=`、およびvalueを連結して形成されるバイト列とする

  4. header valueを返す。

7.5.4.9. network.DataType 型

リモートエンド定義 および ローカルエンド定義

network.DataType = "request" / "response"

network.DataType 型は、収集できるネットワークデータのさまざまな型を表す。

7.5.4.10. network.FetchTimingInfo 型

リモートエンド定義 および ローカルエンド定義

network.FetchTimingInfo = {
    timeOrigin: float,
    requestTime: float,
    redirectStart: float,
    redirectEnd: float,
    fetchStart: float,
    dnsStart: float,
    dnsEnd: float,
    connectStart: float,
    connectEnd: float,
    tlsStart: float,

    requestStart: float,
    responseStart: float,

    responseEnd: float,
}

network.FetchTimingInfo 型は、requestclienttime originを基準とした、リクエストの各部分の時刻を表す。

requestが与えられたとき、fetch タイミングを取得するには:
  1. globalを、requestclientとする。

  2. globalが null である場合、すべてのフィールドが 0 に設定された network.FetchTimingInfo生成規則に一致するマップを返す。

  3. time originを、globaltime origin timestamp を取得する結果とする。

  4. timingsを、requestfetch timing infoとする。

  5. connection timingを、timingsfinal connection timing infoが null でなければそれとし、そうでなければ新しいconnection timing infoとする。

  6. request timeを、timingsstart timeおよびglobalが与えられたとして fetch timestamp を変換する結果とする。

  7. redirect startを、timingsredirect start timeおよび globalが与えられたとしてfetch timestamp を変換する結果とする。

  8. redirect endを、timingsredirect end timeおよび globalが与えられたとしてfetch timestamp を変換する結果とする。

  9. fetch startを、timingspost-redirect start timeおよび globalが与えられたとしてfetch timestamp を変換する結果とする。

  10. DNS startを、connection timingdomain lookup start time およびglobalが与えられたとしてfetch timestamp を変換する結果とする。

  11. DNS endを、connection timingdomain lookup end timeおよび globalが与えられたとしてfetch timestamp を変換する結果とする。

  12. TLS startを、connection timingsecure connection start timeおよびglobalが与えられたとしてfetch timestamp を変換する結果とする。

  13. connect startを、connection timingconnection start timeおよび globalが与えられたとしてfetch timestamp を変換する結果とする。

  14. connect endを、connection timingconnection end timeおよび globalが与えられたとしてfetch timestamp を変換する結果とする。

  15. request startを、timingsfinal network-request start timeおよびglobalが与えられたとしてfetch timestamp を変換する結果とする。

  16. response startを、timingsfinal network-response start timeおよびglobalが与えられたとしてfetch timestamp を変換する結果とする。

  17. response endを、timingsend timeおよびglobalが与えられたとしてfetch timestamp を変換する結果とする。

  18. timeOriginフィールドがtime originに、 requestTimeフィールドがrequest timeに、 redirectStartフィールドがredirect startに、 redirectEndフィールドがredirect endに、 fetchStartフィールドがfetch startに、 dnsStartフィールドがDNS startに、dnsEnd フィールドがDNS endに、connectStartフィールドがconnect startに、connectEndフィールドがconnect endに、 tlsStartフィールドがTLS startに、 requestStartフィールドがrequest startに、 responseStartフィールドがresponse startに、そして responseEndフィールドがresponse endに設定された、 network.FetchTimingInfo生成規則に一致するマップを返す。

TODO: service worker フィールドを追加する

7.5.4.11. network.Header 型

リモートエンド定義 および ローカルエンド定義

network.Header = {
  name: text,
  value: network.BytesValue,
}

network.Header 型は単一のリクエストヘッダーを表す。

name bytesおよびvalue bytesが与えられたとき、ヘッダーを直列化する には:
  1. nameを、name bytesUTF-8 decodeした結果とする。

    表明:ヘッダー名は ASCII のみに制約されているため、これは失敗しない。

  2. valueを、value bytesプロトコルバイトを直列化する結果とする。

  3. nameフィールドがnameに、valueフィールドが valueに設定された、network.Header生成規則に一致するマップを返す。

protocol headerが与えられたとき、ヘッダーを 逆直列化するには:
  1. nameを、protocol header["name"]をUTF-8 encodeしたものとする。

  2. valueを、protocol header["value"]でプロトコルバイトを逆直列化する結果とする。

  3. header (name, value) を返す。

protocol headersが与えられたとき、ヘッダー リストを作成するには:
  1. headersを空のヘッダーリストとする。

  2. protocol headers内の各headerについて:

    1. deserialized headerを、headerヘッダーを逆直列化する結果とする。

    2. deserialized headerの name がfield-name token 生成規則に一致しない場合、エラーエラーコード "invalid argument"で返す。

    3. deserialized headerの value がヘッダー 値 生成規則に一致しない場合、エラーエラーコード "invalid argument"で返す。

    4. deserialized headerheadersに付加する。

  3. 成功をデータheadersとともに返す

7.5.4.12. network.Initiator 型

リモートエンド定義 および ローカルエンド定義

network.Initiator = {
    ? columnNumber: js-uint,
    ? lineNumber: js-uint,
    ? request: network.Request,
    ? stackTrace: script.StackTrace,
    ? type: "parser" / "script" / "preflight" / "other"
}

network.Initiator 型は、ネットワークリクエストの発生源を表す。

注記: typeフィールドは後方互換性のために 定義に含まれているが、initiator を取得する手順によって設定されることはなくなっており、 この仕様の将来の改訂で削除される予定である。その使用は network.RequestData上のinitiatorTypeおよびdestinationに 置き換えられることが期待される。

注記: requestフィールドは後方互換性のために 定義に含まれているが、initiator を取得する手順によって設定されることはなくなっており、 この仕様の将来の改訂で削除される予定である。 network.Initiatorは、同じリクエスト ID も含む network.BeforeRequestSentParametersに含まれるため、 この情報は冗長である。§ 7.5.4.3 network.BaseParameters 型を参照。

requestが与えられたとき、initiator を取得する には:
  1. requestinitiator typeが "fetch" または "xmlhttprequest" である場合:

    1. stack trace現在のスタックトレースとする。

    2. stack traceのサイズが 1 以上である場合、 line numberstack trace[0]の lineNumberフィールドの値とし、column numberstack trace[0]のcolumnNumberフィールドの値とする。そうでなければ、 line numberおよびcolumn numberを 0 とする。

    そうでなければ、stack tracecolumn number、およびline numberをすべて null とする。

    TODO: Chrome は、parser により挿入されたリソースについて、現在の parser 位置を column number / line number として含める。

  2. network.Initiator生成規則に一致するマップを返す。 そのcolumnNumberフィールドはcolumn numberが null でなければ設定され、 そうでなければ省略される。lineNumberフィールドはline numberが null でなければ設定され、そうでなければ省略され、stackTraceフィールドは stack traceが null でなければ設定され、そうでなければ省略される。

7.5.4.13. network.Intercept 型

リモートエンド定義 および ローカルエンド定義

network.Intercept = text

network.Intercept 型は、ネットワークインターセプトの ID を表す。

7.5.4.14. network.Request 型

リモートエンド定義 および ローカルエンド定義

network.Request = text;

各ネットワークリクエストは、関連付けられたリクエスト IDを持つ。これは、そのリクエストを一意に識別する 文字列である。リダイレクトの結果生じるリクエストの識別子は、それを開始したリクエストのものと一致する。

7.5.4.15. network.RequestData 型

リモートエンド定義 および ローカルエンド定義

network.RequestData = {
    request: network.Request,
    url: text,
    method: text,
    headers: [*network.Header],
    cookies: [*network.Cookie],
    headersSize: js-uint,
    bodySize: js-uint / null,
    destination: text,
    initiatorType: text / null,
    timings: network.FetchTimingInfo,
}

network.RequestData 型は、進行中のネットワークリクエストを表す。

requestが与えられたとき、リクエスト データを取得するには:

  1. request idを、request のリクエスト IDとする。

  2. urlを、requestURLURL シリアライザーを実行した結果とする。

  3. methodを、requestmethodとする。

  4. body sizeを null とする。

  5. bodyを、request のbodyとする。

  6. bodyバイト列である場合、 body sizeをその列の長さに設定する。そうでなく、bodybodyである場合、 body sizeをその body の長さに設定する。

  7. headers sizeを、[HTTP11]により義務付けられるように直列化されたときの、 requestheaders listのバイト単位のサイズとする。

    注記: ヘッダー圧縮を許可するプロトコルでは、 これはネットワーク上で送信されたヘッダーの圧縮後サイズである。

  8. headersを空のリストとする。

  9. cookiesを空のリストとする。

  10. requestheaders list内の各(name, value)について:

    1. nameおよび valueヘッダーを直列化する結果をheadersに付加する。

    2. nameが "Cookie" とバイト大小無視一致する場合:

      1. requestに含まれる、ユーザーエージェントのCookie ストア内の各cookieについて:

        注記: [COOKIES]は、ストア内のどの Cookie が リクエストに含まれうるかについていくつかの基本要件を定義するが、ユーザーエージェントは 追加の制約を課してもよい。

        1. cookieが与えられたとしてCookie を直列化する結果を cookiesに付加する。

  11. destinationを、requestdestinationとする。

  12. initiator typeを、requestinitiator typeとする。

  13. timingsを、requestfetch タイミングを取得する結果とする。

  14. network.RequestData生成規則に一致するマップを返す。 そのrequestフィールドはrequest idに、urlフィールドは urlに、methodフィールドはmethodに、 headersフィールドはheadersに、cookiesフィールドは cookiesに、headersSizeフィールドはheaders sizeに、 bodySizeフィールドはbody sizeに、destination フィールドはdestinationに、initiatorTypeフィールドは initiator typeに、そしてtimingsフィールドはtimingsに設定される。

7.5.4.16. network.ResponseContent 型

リモートエンド定義 および ローカルエンド定義

network.ResponseContent = {
    size: js-uint
}

network.ResponseContent 型は、ネットワークリクエストに対するデコード済みレスポンスを表す。

responseが与えられたとき、レスポンス content 情報を取得するには:
  1. sizeフィールドがresponseresponse body infodecoded sizeに設定された、 network.ResponseContent生成規則に一致する新しいマップを返す

7.5.4.17. network.ResponseData 型

リモートエンド定義 および ローカルエンド定義

network.ResponseData = {
    url: text,
    protocol: text,
    status: js-uint,
    statusText: text,
    fromCache: bool,
    headers: [*network.Header],
    mimeType: text,
    bytesReceived: js-uint,
    headersSize: js-uint / null,
    bodySize: js-uint / null,
    content: network.ResponseContent,
    ?authChallenges: [*network.AuthChallenge],
}

network.ResponseData 型は、ネットワークリクエストに対するレスポンスを表す。

responseが与えられたとき、protocol を取得するには:

  1. protocolを空文字列とする。

  2. responsefinal connection timing infoが null でない場合、protocolresponsefinal connection timing infoALPN negotiated protocolに設定する。

  3. protocolが空文字列であるか、"unknown" に等しい場合:

    1. protocolを、responseurlschemeに設定する

    2. protocolが "http" または "https" のいずれかに等しく、かつresponseに関連付けられた HTTP Response がある場合。

      注記: [FETCH]は、 HTTP ネットワークレスポンスと response オブジェクトとの関係について明確ではない。

      1. http versionを、HTTP Response の Status line の HTTP-version [HTTP11]とする。

      2. http versionが "HTTP/" で始まる場合:

        1. versionを、http versionの 5 から http version長さまでのコード単位部分文字列とする。

        2. versionが "0.9" である場合、protocolを "http/0.9" に設定し、そうでなくversionが "1.0" である場合、 protocolを "http/1.0" に設定し、そうでなく versionが "1.1" である場合、protocolを "http/1.1" に設定する。

  4. protocolを返す。

responseが与えられたとき、レスポンス データを取得するには:
  1. urlを、responseURLURL シリアライザーを実行した結果とする。

  2. protocolを、responseが与えられたとしてprotocol を取得する結果に設定する。

  3. statusを、responsestatusとする。

  4. status textを、responsestatus messageとする。

  5. responsecache stateが "local" である場合、 from cacheを true とし、そうでなければ false とする。

  6. headersを空のリストとする。

  7. mime typeを、responseについての計算済み MIME 型essenceとする。

    注記: これは、ブラウザーが実際に使用している MIME 型であり、 たとえ[MIMESNIFF]仕様の正確なアルゴリズムに従っていなくても同様である。

  8. responseheaders list内の各(name, value)について:

    1. nameおよび valueヘッダーを直列化する結果をheadersに付加する。

  9. bytes receivedを、responseに関連付けられた HTTP レスポンスの一部として送信された総バイト数とする。

  10. headers sizeを、HTTP レスポンスのヘッダー フィールドセクションの一部として送信されたバイト数とする。

  11. body sizeを、responseresponse body infoencoded sizeとする。

  12. contentを、responseレスポンス content 情報を取得する結果とする。

  13. auth challengesを、responsechallenge を抽出する結果とする。

  14. network.ResponseData生成規則に一致するマップを返す。 そのurlフィールドはurlに、protocolフィールドは protocolに、statusフィールドはstatusに、 statusTextフィールドはstatus textに、 fromCacheフィールドはfrom cacheに、headers フィールドはheadersに、mimeTypeフィールドはmime typeに、 bytesReceivedフィールドはbytes receivedに、 headersSizeフィールドはheaders sizeに、 bodySizeフィールドはbody sizeに、content フィールドはcontentに設定され、authChallengesフィールドは auth challengesが null でなければauth challengesに設定され、そうでなければ省略される。

7.5.4.18. network.SetCookieHeader 型

Remote end definition

network.SetCookieHeader = {
    name: text,
    value: network.BytesValue,
    ? domain: text,
    ? httpOnly: bool,
    ? expiry: text,
    ? maxAge: js-int,
    ? path: text,
    ? sameSite: network.SameSite,
    ? secure: bool,
}

network.SetCookieHeader は、 Set-Cookie response header 内の data を表す。

integer である input が与えられたとき、serialize an integer するには:

注: これは input の最短表現を decimal digits の string として生成する。

  1. serialized を空文字列とする。

  2. valueinput とする。

  3. value が 0 より大きい間:

    1. xvalue を 10 で割ったものとする。

    2. most significant digitsx の integer part とする。

    3. ymost significant digits に 10 を掛けたものとする。

    4. least significant digitvalue - y とする。

    5. Assert: least significant digit は 0 から 9 までの範囲の integer (両端を含む)である。

    6. codepoint を、value が U+0030 DIGIT ZERO の value + least significant digit である code point とする。

    7. codepointserialized の先頭に付加する。

    8. valuemost significant digits に設定する。

  4. serialized を返す。

protocol cookie が与えられたときに set-cookie ヘッダーを直列化するには:
  1. name を、protocol cookie["name"] を UTF-8 符号化したものとする。

  2. value を、protocol cookie["value"] を用いて プロトコルバイトを逆直列化する結果とする。

  3. header value を、name、 `=`、および value を連結して形成される バイト シーケンスとする。

  4. protocol cookie が "expiry" を含む場合:

    1. attribute を `;Expires=` とする

    2. protocol cookie["expiry"] を UTF-8 符号化したものを attribute に付加する。

    3. attributeheader value に付加する。

  5. protocol cookie が "maxAge" を含む場合:

    1. attribute を `;Max-Age=` とする

    2. max age string を、protocol cookie["maxAge"] を整数を直列化する結果とする。

    3. max age stringUTF-8 符号化したものを attribute に付加する。

    4. attributeheader value に付加する。

  6. protocol cookie が "domain" を含む場合:

    1. attribute を `;Domain=` とする

    2. protocol cookie["domain"] を UTF-8 符号化したものを attribute に付加する。

    3. attributeheader value に付加する。

  7. protocol cookie が "path" を含む場合:

    1. attribute を `;Path=` とする

    2. protocol cookie["path"] を UTF-8 符号化したものを attribute に付加する。

    3. attributeheader value に付加する。

  8. protocol cookie が "secure" を含み、かつ protocol cookie["secure"] が true である場合:

    1. `;Secure` を header value に付加する。

  9. protocol cookie が "httpOnly" を含み、かつ protocol cookie["httpOnly"] が true である場合:

    1. `;HttpOnly` を header value に付加する。

  10. protocol cookie が "sameSite" を含む場合:

    1. attribute を `;SameSite=` とする

    2. protocol cookie["sameSite"] を UTF-8 符号化したものを attribute に付加する。

    3. attributeheader value に付加する。

  11. header value を返す。

7.5.4.19. network.UrlPattern 型

Remote end definition

network.UrlPattern = (
  network.UrlPatternPattern /
  network.UrlPatternString
)

network.UrlPatternPattern = {
    type: "pattern",
    ?protocol: text,
    ?hostname: text,
    ?port: text,
    ?pathname: text,
    ?search: text,
}


network.UrlPatternString = {
    type: "string",
    pattern: text,
}

network.UrlPattern は、network intercepts の request URL を照合するために使用される pattern を表す。

URL が network.UrlPattern に対して照合されるとき、URL は parse され、各 component は、存在する場合、pattern 内の対応する field と 等価性で比較される。pattern にない fields は常に一致する。

注: この構文は将来の拡張性を 念頭に置いて設計されている。特に、この構文は [URLPattern] 仕様で特別に扱われる文字を禁止する。これらは U+005C (\) 文字を前置することで escape できる。

patternが与えられたとき、URL パターンのエスケープを解除するには:
  1. forbidden charactersを、符号位置 «U+0028 ((), U+0029 ()), U+002A (*), U+007B ({), U+007D (})» の集合とする

  2. resultを空文字列とする。

  3. is escaped characterを false とする。

  4. pattern内の各codepointについて:

    1. is escaped characterが false である場合:

      1. forbidden characterscodepoint含む場合、エラーエラーコード invalid argumentで返す。

      2. codepointが U+005C (\) である場合:

        1. is escaped characterを true に設定する。

        2. 続行する。

    2. codepointを result に付加する。

    3. is escaped characterを false に設定する。

  5. 成功をデータresultとともに返す。

pattern が与えられたときに URL パターンを構文解析するには:
  1. has protocol を true とする。

  2. has hostname を true とする。

  3. has port を true とする。

  4. has pathname を true とする。

  5. has search を true とする。

  6. patternnetwork.UrlPatternPattern 生成規則に一致する場合:

    1. pattern url を空文字列とする。

    2. pattern が "protocol" を含む場合:

      1. pattern["protocol"] が空文字列である場合、エラーエラーコード invalid argument で返す。

      2. protocol を、pattern["protocol"] を用いて URL Pattern をエスケープ解除することを試行する結果とする。

      3. protocol 内の各 codepoint について:

        1. codepointASCII 英数字でなく、かつ «U+002B (+), U+002D (-), U+002E (.)» が codepoint含まない場合:

          1. エラーエラーコード invalid argument で返す。

      4. protocolpattern url に付加する。

    3. それ以外の場合:

      1. has protocol を false に設定する。

      2. "http" を pattern url に付加する。

    4. scheme を、pattern urlASCII 小文字化とする。

    5. ":" を pattern url に付加する。

    6. scheme特別である場合、 "//" を pattern url に付加する。

    7. pattern が "hostname" を含む場合:

      1. pattern["hostname"] が空文字列である場合、エラーエラーコード invalid argument で返す。

      2. scheme が "file" である場合、エラーエラーコード invalid argument で返す。

      3. hostname を、pattern["hostname"] を用いて URL Pattern をエスケープ解除することを試行する結果とする。

      4. inside brackets を false とする。

      5. hostname 内の各 codepoint について:

        1. «U+002F (/), U+003F (?), U+0023 (#)» が codepoint含む場合:

          1. エラーエラーコード invalid argument で返す。

        2. inside brackets が false であり、かつ codepoint が U+003A (:) である場合:

          1. エラーエラーコード invalid argument で返す。

        3. codepoint が U+005B ([) である場合、inside brackets を true に設定する。

        4. codepoint が U+005D (]) である場合、inside brackets を false に設定する。

      6. hostnamepattern url に付加する。

    8. それ以外の場合:

      1. scheme が "file" でない場合、 "placeholder" を pattern url に付加する。

      2. has hostname を false に設定する。

    9. pattern が "port" を含む場合:

      1. pattern["port"] が空文字列である場合、エラーエラーコード invalid argument で返す。

      2. port を、pattern["port"] を用いて URL Pattern をエスケープ解除することを試行する結果とする。

      3. ":" を pattern url に付加する。

      4. port 内の各 codepoint について:

        1. codepointASCII 数字でない場合:

          1. エラーエラーコード invalid argument で返す。

      5. portpattern url に付加する。

    10. それ以外の場合:

      1. has port を false に設定する。

    11. pattern が "pathname" を含む場合:

      1. pathname を、 pattern["pathname"] を用いてURL Pattern をエスケープ解除することを試行する結果とする。

      2. pathname が U+002F (/) で始まらない場合、 "/" を pattern url に付加する。

      3. pathname 内の各 codepoint について:

        1. «U+003F (?), U+0023 (#)» が codepoint含む場合:

          1. エラーエラーコード invalid argument で返す。

      4. pathnamepattern url に付加する。

    12. それ以外の場合:

      1. has pathname を false に設定する。

    13. pattern が "search" を含む場合:

      1. search を、 pattern["search"] を用いてURL pattern をエスケープ解除することを試行する結果とする。

      2. search が U+003F (?) で始まらない場合、 "?" を pattern url に付加する。

      3. search 内の各 codepoint について:

        1. codepoint が U+0023 (#) である場合:

          1. エラーエラーコード invalid argument で返す。

      4. searchpattern url に付加する。

    14. それ以外の場合:

      1. has search を false に設定する。

  7. それ以外で、patternnetwork.UrlPatternString 生成規則に一致する場合:

    1. pattern url を、 pattern["pattern"] を用いて URL pattern をエスケープ解除することを試行する結果とする。

  8. url を、pattern url構文解析する結果とする。

  9. url が失敗である場合、エラーエラーコード invalid argument で返す。

  10. parsed を、次のフィールドを持つ構造体とする:

    protocol
    has protocol が true である場合は urlスキーム、それ以外の場合は null。
    hostname
    has hostname が true である場合は urlホスト、それ以外の場合は null。
    port
    1. has port が false である場合:

      1. null。

    2. それ以外の場合:

      1. urlスキーム特別であり、かつ urlスキームデフォルトポートが null でなく、かつ urlポートが null である、または スキームデフォルトポートに等しい場合:

        1. 空文字列。

      2. それ以外で、urlポートが null でない場合:

        1. urlポートを用いて 整数を直列化する

      3. それ以外の場合:

        1. null。

    pathname
    1. has pathname が false である場合:

      1. null。

    2. それ以外の場合:

      1. urlパスが空文字列でなく、かつ でない場合は、url を用いて URL パス直列化器を実行した結果、 それ以外の場合は null。

    search
    1. has search が false である場合:

      1. null。

    2. それ以外の場合:

      1. urlクエリーが null である場合は空文字列、 それ以外の場合は urlクエリー

  11. データ parsed成功を返す。

url patternおよびurl stringが与えられたとき、URL パターンに一致する には:
  1. urlを、url string解析する結果とする。

  2. url patternの protocol が null でなく、かつurlschemeに等しくない場合、false を返す。

  3. url patternの hostname が null でなく、かつurlhostに等しくない場合、false を返す。

  4. url patternの port が null でない場合:

    1. portを null とする。

    2. urlscheme特別であり、かつurlscheme既定 ポートが null でなく、かつurlportが null であるか、scheme既定 ポートに等しい場合:

      1. portを空文字列に設定する。

    3. そうでなく、urlportが null でない場合:

      1. portを、urlport整数を直列化する結果に設定する。

    4. url patternの port がportに等しくない場合、false を返す。

  5. url patternの pathname が null でなく、かつurlURL path serializerを実行した結果に等しくない場合、false を返す。

  6. url patternの search が null でない場合:

    1. url queryを、urlqueryとする。

    2. url queryが null である場合、url queryを空文字列に設定する。

    3. url patternの search がurl queryに等しくない場合、false を返す。

  7. true を返す。

7.5.5. コマンド

7.5.5.1. network.addDataCollector コマンド

network.addDataCollectorcollector を追加する。

コマンド型
network.AddDataCollector = (
  method: "network.addDataCollector",
  params: network.AddDataCollectorParameters
)

network.AddDataCollectorParameters = {
  dataTypes: [+network.DataType],
  maxEncodedDataSize: js-uint,
  ? collectorType: network.CollectorType .default "blob",
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}
返却型
network.AddDataCollectorResult = {
  collector: network.Collector
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. collector idを、UUIDの文字列表現とする。

  2. input context idsを空の集合とする。

  3. command parameterscontextsフィールドが存在する場合、 input context idscommand parameters[contexts]で集合を作成するに設定する。

  4. data typesを、 command parameters["dataTypes"]で集合を作成するとする。

  5. max encoded item sizecommand parameters ["maxEncodedDataSize"]とする。

    注記: maxEncodedDataSize パラメーターは 最大エンコード済み項目サイズを表し、 指定された collector によって収集される各リクエストのサイズを制限するものであり、 collector 全体の収集サイズを制限するものではない。

    注記: 実装によってサポートするエンコードが 異なる場合があり、これは エンコード済みサイズがブラウザー間で異なりうることを意味する。したがって、同じデータ collector 構成であっても、一部のネットワークデータが最大エンコード済み項目サイズに収まるのは、 一部の実装のみである場合がある。

  6. collector typecommand parameters ["collectorType"]とする。

  7. input user context idsを空の集合とする。

  8. command parametersuserContextsフィールドが存在する場合、 input user context idscommand parameters[userContexts]で集合を作成するに設定する。

  9. input user context idsが空でなく、かつinput context idsが 空でない場合、エラーエラー コード invalid argumentで返す。

  10. max encoded item sizeが 0 であるか、max encoded item size最大総収集サイズより大きい場合、エラーエラー コード invalid argumentで返す。

  11. input context idsでない場合:

    1. navigablesを、input context ids試行して ID により有効な navigable を取得する 結果とする。

    2. navigables内の各navigableについて:

      1. navigableトップレベル辿可能でない場合、エラーエラーコード invalid argumentで返す。

  12. そうでなく、input user context idsでない場合:

    1. input user context idsuser context idについて:

      1. user contextを、user context idユーザーコンテキストを取得する結果とする。

      2. user contextが null である場合、エラーエラーコード そのようなユーザーコンテキストはないで返す。

  13. collectorを、 最大エンコード済み項目サイズフィールドが max encoded item sizeに、 データ型フィールドがdata typesに、 collectorフィールドがcollector idに、 collector 型フィールドがcollector typeに、 contextsフィールドがinput context idsに、 ユーザーコンテキストフィールドがinput user context idsに設定されたcollectorとする。

  14. sessionネットワーク collector[collector id]を collectorに設定する。

  15. collectorフィールドがcollector idに設定された network.AddDataCollectorResult生成規則に一致する新しいマップを返す。

7.5.5.2. network.addIntercept コマンド

network.addIntercept command は network intercept を追加する。

コマンド型
network.AddIntercept = (
  method: "network.addIntercept",
  params: network.AddInterceptParameters
)

network.AddInterceptParameters = {
  phases: [+network.InterceptPhase],
  ? contexts: [+browsingContext.BrowsingContext],
  ? urlPatterns: [*network.UrlPattern],
}

network.InterceptPhase = "beforeRequestSent" / "responseStarted" /
                         "authRequired"
返却型
network.AddInterceptResult = {
    intercept: network.Intercept
    }
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. interceptを、UUIDの文字列表現とする。

  2. url patternsを、command parametersurlPatternsフィールドが存在する場合はそれとし、そうでなければ空のリストとする。

  3. navigablesを null とする。

  4. command parameterscontextsフィールドが存在する場合:

    1. navigablesを空の集合に設定する。

    2. command parameters["contexts"]の各navigable idについて

      1. navigableを、navigable id試行してnavigable を取得する 結果とする。

      2. navigableトップレベル辿可能でない場合、エラーエラーコード invalid argumentで返す。

      3. navigablenavigablesに付加する。

    3. navigablesが空の集合である場合、エラーエラーコード invalid argumentで返す。

  5. intercept mapを、sessionインターセプトマップとする。

  6. parsed patternsを空のリストとする。

  7. url patterns内の各url patternについて:

    1. parsedを、url pattern試行して URL パターンを解析する結果とする。

    2. parsedparsed patterns付加する

  8. intercept map[intercept]を、url patterns parsed patternsphases command parameters["phases"] およびbrowsingContexts navigablesを持つ構造体に設定する。

  9. interceptフィールドがinterceptに設定された network.AddInterceptResult生成規則に一致する新しいマップを返す。

7.5.5.3. network.continueRequest コマンド

network.continueRequestコマンドは、ネットワークインターセプトによりブロックされたリクエストを 続行する。

コマンド型
network.ContinueRequest = (
  method: "network.continueRequest",
  params: network.ContinueRequestParameters
)

network.ContinueRequestParameters = {
  request: network.Request,
  ?body: network.BytesValue,
  ?cookies: [*network.CookieHeader],
  ?headers: [*network.Header],
  ?method: text,
  ?url: text,
}
戻り値型
network.ContinueRequestResult = EmptyResult
session および command parameters が与えられた リモートエンド手順は次の通りである:
  1. blocked requestssessionブロックされたリクエストマップとする。

  2. request idcommand parameters["request"] とする。

  3. blocked requestsrequest id含まない 場合、エラーエラー コード no such request で返す。

  4. (request, phase, response) を blocked requests[request id] とする。

  5. phase が "beforeRequestSent" でない場合、エラーエラーコード invalid argument で返す。

    "request already sent" エラーを検討する。

  6. command parameters が "url" を含む場合:

    1. url record を、command parameters["url"] に URL パーサーを適用した結果とし、ベース URL は null とする。

    2. url record が失敗である場合、エラーエラーコード invalid argument で返す。

      TODO: ここでも再開すべきか?

    3. requesturlurl record とする。

  7. command parameters が "method" を含む場合:

    1. methodcommand parameters["method"] とする。

    2. methodmethod token 生成規則に一致しない場合、エラーエラーコード "invalid argument" で返す。

    3. requestmethodmethod とする。

  8. command parameters が "headers" を含む場合:

    1. headers を空の ヘッダーリストとする。

    2. command parameters["headers"] 内の各 header について:

      1. deserialized header を、header を用いて ヘッダーを逆直列化する結果とする。

      2. deserialized header の名前が field-name token 生成規則に一致しない場合、エラーエラーコード "invalid argument" で返す。

      3. deserialized header の値が ヘッダー値 生成規則に一致しない場合、エラーエラーコード "invalid argument" で返す。

      4. deserialized headerheaders に付加する。

    3. requestヘッダーリストheaders に設定する。

  9. command parameters が "cookies" を含む場合:

    1. cookie header を空の バイト シーケンスとする。

    2. command parameters["cookies"] 内の各 cookie について:

      1. cookie header が空でない場合、`;` を cookie header に付加する。

      2. cookie を用いて cookie ヘッダーを直列化する結果を cookie header に付加する。

    3. found cookie header を false とする。

    4. requestヘッダーリスト内の各 header について:

      1. nameheader の名前とする。

      2. nameバイト小文字化したものが `cookie` である場合:

        1. header の値を cookie header に設定する。

        2. found cookie header を true に設定する。

        3. 中断する。

    5. found cookie header が false である場合:

      1. ヘッダー (`Cookie`, cookie header) を requestヘッダーリストに付加する。

  10. command parameters が "body" を含む場合:

    1. body を、command parameters["body"] を用いて プロトコルバイトを逆直列化する結果とする。

    2. requestbodybody に設定する。

  11. "continue request", request id, および (null, "incomplete") で再開する

  12. データ null で 成功を返す。

7.5.5.4. network.continueResponse コマンド

network.continueResponseコマンドは、ネットワークインターセプトによりブロックされた レスポンスを続行する。これは、responseStartedフェーズで呼び出すことができ、 レスポンスの status および headers を変更しつつ、ネットワークレスポンス body は引き続き提供する。

コマンド型
network.ContinueResponse = (
  method: "network.continueResponse",
  params: network.ContinueResponseParameters
)

network.ContinueResponseParameters = {
  request: network.Request,
  ?cookies: [*network.SetCookieHeader]
  ?credentials: network.AuthCredentials,
  ?headers: [*network.Header],
  ?reasonPhrase: text,
  ?statusCode: js-uint,
}
戻り値型
network.ContinueResponseResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. request idcommand parameters["request"]とする。

  2. responseを、 session、"continueResponse" およびcommand parameters試行してresponse を更新する結果とする。

  3. "continue request"、request id、および (response, "incomplete") で再開する

  4. 成功をデータ null とともに返す。

7.5.5.5. network.continueWithAuth コマンド

network.continueWithAuth command は、 authRequired phase で network intercept によって block されている response を続行する。

コマンド型
network.ContinueWithAuth = (
    method: "network.continueWithAuth",
    params: network.ContinueWithAuthParameters
    )

    network.ContinueWithAuthParameters = {
    request: network.Request,
    (network.ContinueWithAuthCredentials // network.ContinueWithAuthNoCredentials)
    }

    network.ContinueWithAuthCredentials = (
    action: "provideCredentials", 
    credentials: network.AuthCredentials
    )

    network.ContinueWithAuthNoCredentials = (
    action: "default" / "cancel"
    )
返却型
network.ContinueWithAuthResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. blocked requestsを、sessionブロックされたリクエストマップとする。

  2. request idcommand parameters["request"]とする。

  3. blocked requestsrequest id含まない 場合、 エラーエラー コード no such requestで返す。

  4. (request, phase, response)を、blocked requests[request id]とする。

  5. phaseが "authRequired" でない場合、エラーエラーコード invalid argumentで返す。

  6. command parameters "action" が "cancel" である場合、 responseの authentication credentials を "cancelled" に設定する。

  7. command parameters "action" が "provideCredentials" である場合:

    1. credentialscommand parameters["credentials"]とする。

    2. 表明:credentials["type"]は "password" である。

    3. responseの authentication credentials を (credentials["username"], credentials["password"]) に設定する

  8. "continue request"、request id、および (response, "incomplete") で再開する

  9. 成功をデータ null とともに返す。

7.5.5.6. network.disownData コマンド

network.disownDataコマンドは、指定されたcollectorについて、収集されたネットワークデータを解放する。

コマンド型
network.DisownData = (
  method: "network.disownData",
  params: network.DisownDataParameters
)

network.DisownDataParameters = {
  dataType: network.DataType,
  collector: network.Collector,
  request: network.Request,
}
戻り値型
network.DisownDataResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. data typeを、command parameters内の "dataType" フィールドの値とする。

  2. collector idを、command parameters内の "collector" フィールドの値とする。

  3. request idを、command parameters内の "request" フィールドの値とする。

  4. collectorsを、sessionネットワーク collectorとする。

  5. collectorscollector id含まない場合、 エラーエラー コード no such network collectorで返す。

  6. collected dataを、request idおよび data type収集済みデータを取得する結果とする。

  7. collected dataが null である場合、エラーエラーコード no such network dataで返す。

  8. collected dataおよびcollector idデータから collector を除去する

  9. 成功をデータ null とともに返す。

7.5.5.7. network.failRequest コマンド

network.failRequestコマンドは、ネットワークインターセプトによりブロックされた fetch を失敗させる。

コマンド型
network.FailRequest = (
  method: "network.failRequest",
  params: network.FailRequestParameters
)

network.FailRequestParameters = {
  request: network.Request,
}
戻り値型
network.FailRequestResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. blocked requestsを、sessionブロックされたリクエストマップとする。

  2. request idcommand parameters["request"]とする。

  3. blocked requestsrequest id含まない 場合、 エラーエラー コード no such requestで返す。

  4. (request, phase, response)を、 blocked requests[request id]とする。

  5. phaseが "authRequired" である場合、エラーエラーコード invalid argumentで返す。

  6. responseを新しいネットワークエラーとする。

    正確なエラー種別の設定を許可する [Issue #508]

  7. "continue request"、request id、および (response, "complete") で再開する

  8. 成功をデータ null とともに返す。

7.5.5.8. network.getData コマンド

network.getDataコマンドは、利用可能であれば ネットワークデータを取得する。

コマンド型
network.GetData = (
  method: "network.getData",
  params: network.GetDataParameters
)

network.GetDataParameters = {
  dataType: network.DataType,
  ? collector: network.Collector,
  ? disown: bool .default false,
  request: network.Request,
}
戻り値型
network.GetDataResult = {
  bytes: network.BytesValue,
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. data typecommand parameters["dataType"]とする。

  2. request idcommand parameters["request"]とする。

  3. collector idを null とする。

  4. command parametersが "collector"を含む場合:

    1. collectorsを、sessionネットワーク collectorとする。

    2. collectorscollector id含まない場合、 エラーエラーコード no such network collectorで返す。

    3. collector idcommand parameters["collector"]に設定する。

  5. disowncommand parameters["disown"]とする。

  6. disownが true であり、かつcollector idが null である場合、エラーエラーコード invalid argumentで返す。

  7. collected dataを、request idおよび data typeが与えられたとして収集済みデータを取得する結果とする。

  8. collected dataが null である場合:

    1. エラーエラーコード no such network dataで返す。

  9. collected datapendingが true である場合:

    1. "network data collected" および (request id, data type) で待機する

  10. collector idが null でなく、かつcollected datacollectorscollector id含まない場合:

    1. エラーエラーコード no such network dataで返す。

  11. bytesを、collected databytesとする。

  12. bytesが null である場合、

    1. エラーエラーコード unavailable network dataで返す。

  13. bodyを、bytesフィールドがbytesに設定された、 network.GetDataResult生成規則に一致するマップとする。

  14. disownが true である場合、collected dataおよびcollector idデータから collector を除去する

  15. 成功をデータbodyとともに返す。

7.5.5.9. network.provideResponse コマンド

network.provideResponse コマンドは、 network intercept によってブロックされた request を、完全な response を提供することにより継続する。

注: これは、request が通常の request ライフサイクルを通過し、それに伴って他のイベントを発行することを防がない。

コマンド型
network.ProvideResponse = (
  method: "network.provideResponse",
  params: network.ProvideResponseParameters
)

network.ProvideResponseParameters = {
  request: network.Request,
  ?body: network.BytesValue,
  ?cookies: [*network.SetCookieHeader],
  ?headers: [*network.Header],
  ?reasonPhrase: text,
  ?statusCode: js-uint,
}
戻り値型
network.ProvideResponseResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. request idcommand parameters["request"]とする。

  2. responseを、 session、"provideResponse"、およびcommand parameters試行してresponse を更新する結果とする。

  3. command parametersが "body"を含む場合:

    1. bodyを、command parameters["body"]でプロトコルバイトを逆直列化する結果とする。

    2. responsebodybody body としてに設定する。

  4. "continue request"、request id、および (response,"complete") で再開する

  5. 成功をデータ null とともに返す。

7.5.5.10. network.removeDataCollector コマンド

network.removeDataCollector コマンドは collector を削除する。

コマンド型
network.RemoveDataCollector = (
    method: "network.removeDataCollector",
    params: network.RemoveDataCollectorParameters
    )

    network.RemoveDataCollectorParameters = {
    collector: network.Collector
    }
戻り値型
network.RemoveDataCollectorResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. collector idを、command parameters内の "collector" フィールドの値とする。

  2. collectorsを、sessionネットワーク collectorとする。

  3. collectorscollector id含まない場合、 エラーエラー コード no such network collectorで返す。

  4. sessionネットワーク collectorからcollector id除去する

  5. 収集されたネットワークデータ内の各collected dataについて、collected dataおよびcollector idデータから collector を除去する

  6. 成功をデータ null とともに返す。

7.5.5.11. network.removeIntercept コマンド

network.removeInterceptコマンドは、ネットワークインターセプトを除去する。

コマンド型
network.RemoveIntercept = (
  method: "network.removeIntercept",
  params: network.RemoveInterceptParameters
)

network.RemoveInterceptParameters = {
  intercept: network.Intercept
}
戻り値型
network.RemoveInterceptResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. interceptを、command parameters内の "intercept" フィールドの値とする。

  2. intercept mapを、sessionインターセプトマップとする。

  3. intercept mapintercept含まない場合、 エラーエラー コード no such interceptで返す。

  4. intercept mapからintercept除去する

注記: インターセプトの除去は、このインターセプトによってすでに ブロックされたリクエストには影響しない。影響を受けるのは、将来のリクエストまたは既存リクエストの 将来のフェーズのみである。

  1. 成功をデータ null とともに返す。

7.5.5.12. network.setCacheBehavior コマンド

network.setCacheBehaviorコマンドは、 特定のリクエストについてネットワークキャッシュ挙動を構成する。

コマンド型
network.SetCacheBehavior = (
  method: "network.setCacheBehavior",
  params: network.SetCacheBehaviorParameters
)

network.SetCacheBehaviorParameters = {
  cacheBehavior: "default" / "bypass",
  ? contexts: [+browsingContext.BrowsingContext]
}
戻り値型
network.SetCacheBehaviorResult = EmptyResult
request requestが与えられたときのWebDriver BiDi キャッシュ挙動手順は次のとおりである:
  1. navigableを null とする。

  2. requestclient環境設定オブジェクトである場合:

    1. environment settingsを、requestclientとする。

    2. environment settings大域オブジェクトアクティブウィンドウであるnavigableが存在する場合、 navigable をその navigable のトップレベル辿可能に設定する。

  3. navigableが null でなく、かつnavigable キャッシュ挙動マップnavigable含む場合、navigable キャッシュ挙動 マップ[navigable]を返す。

  4. 既定のキャッシュ挙動を返す。

navigableが与えられたときのnavigable キャッシュ 挙動手順は次のとおりである:
  1. top-level navigableを、navigableトップレベル辿可能とする。

  2. navigable キャッシュ挙動マップ含む top-level navigable場合、 navigable キャッシュ挙動マップ[top-level navigable]を返す。

  3. 既定のキャッシュ挙動を返す。

sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. behaviorcommand parameters["cacheBehavior"]とする。

  2. command parametersが "contexts"を含まない場合:

    1. 既定のキャッシュ挙動behaviorに設定する。

    2. navigable キャッシュ挙動マップクリアする

    3. behavior の値で分岐する:

      "bypass"
      実装固有のリソースキャッシュを無効化するための実装定義の手順を実行する。
      "default"
      現在のリモートエンド構成で通常有効化されている 実装固有のリソースキャッシュを有効化するための実装定義の手順を実行する。
    4. 成功をデータ null とともに返す。

  3. navigablesを空の集合とする。

  4. command parameters["contexts"]の各navigable idについて:

    1. contextを、navigable id試行して navigable を 取得する 結果とする。

    2. contextトップレベルブラウジングコンテキストでない場合、エラーエラーコード invalid argumentで返す。

    3. contextnavigables付加する

  5. navigables内の各navigableについて:

    1. navigable キャッシュ挙動マップnavigable含み、かつ navigable キャッシュ挙動 マップ[navigable]がbehaviorに等しい場合、 続行する。

    2. behavior の値で分岐する:

      "bypass"
      navigableトップレベルブラウジングコンテキストである任意のブラウジング コンテキストから発生するネットワークリクエストについて、実装固有の リソースキャッシュを無効化するための実装定義の手順を実行する。
      "default"
      navigableトップレベルブラウジングコンテキストである任意のブラウジングコンテキストから発生するネットワークリクエストについて、 現在のリモートエンド構成で通常有効化されている 実装固有のリソースキャッシュを有効化するための実装定義の手順を実行する。
    3. behavior既定のキャッシュ挙動に等しい場合:

      1. navigable キャッシュ挙動マップnavigable含む場合、 navigable キャッシュ挙動 マップ[navigable]を除去する

    4. そうでなければ:

      1. navigable キャッシュ挙動 マップ[navigable]をbehaviorに設定する。

  6. 成功をデータ null とともに返す。

7.5.5.13. network.setExtraHeaders コマンド

network.setExtraHeadersコマンドは、 既存のリクエストヘッダーを拡張または上書きするヘッダーの指定を可能にする。

コマンド型
network.SetExtraHeaders = (
  method: "network.setExtraHeaders",
  params: network.SetExtraHeadersParameters
)

network.SetExtraHeadersParameters = {
  headers: [*network.Header]
  ? contexts: [+browsingContext.BrowsingContext]
  ? userContexts: [+browser.UserContext]
}
戻り値型
network.SetExtraHeadersResult = EmptyResult
requestおよびheadersが与えられたとき、ヘッダーを更新するには:
  1. request headersを、requestヘッダーリストとする。

  2. headers内の各headerについて:

    1. request headers内のheader設定する

      注記: これは常に既存の値があればそれを 上書きする。特に、既存の `Set-Cookie` ヘッダーに Cookie を付加するものではない。

sessionrequest、およびrelated navigablesが与えられたとき、リクエスト ヘッダーを更新するには:
  1. 表明:related navigablesサイズは 0 または 1 である。

    注記: これは、複数の navigable に関連付けられた worker では機能しないことを意味する。その場合、どの順序でヘッダーをオーバーライドするかは不明である。

  2. requestおよびsession追加 ヘッダー既定のヘッダーヘッダーを更新する

  3. user context headersを、session追加ヘッダーユーザーコンテキストヘッダーとする。

  4. related navigables内の各navigableについて:

    1. user contextを、navigable関連付けられた ユーザーコンテキストとする。

    2. user context headersuser context含む場合、 requestおよび user context headers[user context]でヘッダーを更新する

  5. navigable headersを、session追加ヘッダーnavigable ヘッダーとする。

  6. related navigables内の各navigableについて:

    1. top-level traversableを、navigableトップレベル辿可能とする。

    2. navigable headerstop-level traversableを含む場合、 requestおよびnavigable headers[top-level traversable]でヘッダーを更新する

session および command parameters が与えられた リモートエンド手順は次の通りである:
  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. headers を、command parameters["headers"] を用いて ヘッダーリストを作成することを試行する結果とする。

  3. command parameters が "userContexts" を含む場合:

    1. user contexts を空のリストとする。

    2. command parameters["userContexts"] 内の各 user context id について:

      1. user context を、user context id を用いて ユーザーコンテキストを取得する結果とする。

      2. user context が null である場合、エラーエラーコード no such user context で返す。

      3. user contextuser contexts付加する

    3. targetsession追加ヘッダーユーザーコンテキストヘッダーとする

    4. user contexts 内の各 user context について:

      1. target[user context] を headers に設定する。

    5. データ null で 成功を返す。

  4. command parameters が "contexts" を含む場合:

    1. navigables を、command parameters["contexts"] を用いて ID により有効なトップレベル トラバーサブルを取得することを試行する結果とする。

    2. targetsession追加ヘッダーnavigable ヘッダーとする

    3. navigables 内の各 navigable について:

      1. target[navigable] を headers に設定する。

    4. データ null で 成功を返す。

  5. session追加ヘッダーデフォルトヘッダーheaders に設定する。

  6. データ null で 成功を返す。

7.5.6. イベント

7.5.6.1. network.authRequired イベント
イベント型
network.AuthRequired = (
    method: "network.authRequired",
    params: network.AuthRequiredParameters
    )

    network.AuthRequiredParameters = {
    network.BaseParameters,
    response: network.ResponseData
    }

このイベントは、ユーザーエージェントが認可資格情報の入力を求めようとしているときに 発火される。

リモートエンドイベントトリガーは、request request およびresponse responseが与えられたときのWebDriver BiDi 認証要求 手順である:
  1. redirect countを、requestredirect countとする。

  2. 表明:before request sent マップ[request]は redirect countに等しい。

    注記: これは、すべての呼び出し側が これらの手順の前に、requestWebDriver BiDi before request sent手順が 呼び出されることを保証する必要があることを意味する。

  3. requestclientが null でない場合、related navigablesを、requestclient関連 navigable を取得する結果とする。そうでなければ、related navigables を空の 集合とする。

  4. "network.authRequired" およびrelated navigablesが与えられたときの、イベントが有効なセッションの集合 内の各sessionについて:

    1. paramsを、session、 "network.authRequired"、およびrequestネットワークイベントを処理する結果とする。

    2. response dataを、responseレスポンス データを取得する結果とする。

    3. 表明:response dataは "authChallenge"を含む

    4. paramsresponseフィールドをresponse dataに設定する。

    5. 表明:paramsnetwork.AuthRequiredParameters 生成規則に一致する。

    6. bodyを、paramsフィールドがparamsに設定された、 network.AuthRequired生成規則に一致するマップとする。

    7. sessionおよびbodyイベントを 発出する

    8. params["isBlocked"]が true である場合:

      1. blocked requestsを、sessionブロックされた リクエストマップとする。

      2. request idを、requestリクエスト IDとする。

      3. blocked requests[request id]を(request, "authRequired", response)に設定する。

      4. «"continue request"» およびrequest id待機する

      5. blocked requests[request id]を除去する

7.5.6.2. network.beforeRequestSent イベント
イベント型
network.BeforeRequestSent = (
    method: "network.beforeRequestSent",
    params: network.BeforeRequestSentParameters
    )

    network.BeforeRequestSentParameters = {
    network.BaseParameters,
    ? initiator: network.Initiator,
    }

このイベントは、リクエストが(ネットワーク経由で、または serviceworker やローカルキャッシュによって 処理される前に)送信される前に発火される。

request および user context が与えられたとき、request originates in user context かどうかを確認する手順は:
  1. settingsrequestclient とする。

  2. related navigables を、settingsget related navigables したものとする。

  3. related navigables 内の navigable について:

    1. navigableassociated user contextuser context である場合、true を返す。

  4. false を返す。

related navigablesが与えられたとき、エミュレートされたネットワーク条件を取得する手順は 次のとおりである:
  1. related navigables内の各navigableについて:

    1. top-level traversablenavigableトップレベル辿可能とする。

    2. user contexttop-level traversable関連付けられた ユーザーコンテキストとする。

    3. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされたネットワーク 条件navigable ネットワーク条件top-level traversable含む場合、 sessionエミュレートされたネットワーク 条件navigable ネットワーク条件[top-level traversable]を返す。

    4. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされたネットワーク 条件ユーザー コンテキストネットワーク条件user context含む場合、sessionエミュレートされたネットワーク 条件ユーザー コンテキストネットワーク条件[user context]を返す。

    5. アクティブ BiDi セッション内の各sessionについて:

      1. sessionエミュレートされたネットワーク 条件既定の ネットワーク条件が null でない場合、 sessionエミュレートされたネットワーク 条件既定の ネットワーク条件を返す。

  2. null を返す。

環境設定オブジェクト settingsが与えられたときの WebDriver BiDi network is offline手順は次のとおりである:
  1. navigableを、settings関連大域オブジェクト関連付けられたDocumentnode navigableとする。

  2. emulated network conditionsを、 [navigable]でエミュレートされたネットワーク条件を取得する結果とする。

  3. emulated network conditionsが null でなく、かつemulated network conditionsofflineが true である場合、true を返す。

  4. false を返す。

request requestが与えられたとき、リモートエンドイベントトリガーWebDriver BiDi before request sent手順である:
  1. ユーザーコンテキストの集合内の各user contextについて:

    1. requestおよび user contextリクエストがユーザー コンテキストから発生する手順が true を返す場合:

      1. アクティブ BiDi セッション内の各sessionについて:

        注記: user contextは、最大でも 1 つの user context to accept insecure certificates override mapにのみ存在できる。

        1. sessionuser context to accept insecure certificates override mapuser context含む場合:

          1. accept insecure certificatesを、 sessionuser context to accept insecure certificates override map[user context]とする。

          2. accept insecure certificatesが true である場合:

            1. endpoint nodeが 安全でない TLS 接続の受け入れをサポートすることを表明する。

            2. requestについてBasic Certificate Processing手順を実行するとき、 step a と、その他の実装定義の証明書検証手順をスキップする。

          3. そうでなければ、requestについてBasic Certificate Processing 手順を実行するとき、 すべての手順を、実装定義の証明書検証手順も含めて実行する。

        注記: user contextは、最大でも 1 つの user context to proxy configuration mapにのみ存在できる。

        1. sessionuser context to proxy configuration mapuser context含む場合:

          1. proxy configurationsessionuser context to proxy configuration map[user context]とする。

          2. requestproxy configurationにより定義されたプロキシ設定を使用することを保証するための、 実装定義の手順を実行する。

            注記: 設定はユーザーコンテキスト作成時に検証されるため、 この段階では有効であるものとみなされる。プロキシへのアクセス時のエラーは、 リクエスト処理時にネットワークエラーとして報告される。

  2. requestネットワークリクエスト body を収集するかもしれない

  3. before request sent マップrequestを含まない場合、before request sent マップ[request]を 新しい集合に設定する。

  4. redirect countrequestredirect countとする。

  5. redirect countbefore request sent マップ[request]に追加する。

  6. requestclientが null でない場合、related navigablesを、requestclient関連 navigable を取得する結果とする。そうでなければ、related navigablesを空の 集合とする。

  7. responseを null とする。

  8. response statusを "incomplete" とする。

  9. アクティブ BiDi セッション内の各sessionについて:

    1. sessionrequest、および related navigablesリクエストヘッダーを更新する

  10. "network.beforeRequestSent" およびrelated navigablesが与えられたときの、イベントが有効なセッションの集合 内の各sessionについて:

    1. paramsを、session、 "network.beforeRequestSent"、およびrequestネットワークイベントを処理する結果とする。

    2. initiatorを、 requestinitiator を取得する結果とする。

    3. initiatorでない場合、paramsinitiatorフィールドを initiatorに設定する。

    4. 表明:paramsnetwork.BeforeRequestSentParameters 生成規則に一致する。

    5. bodyを、paramsフィールドがparamsに設定された、 network.BeforeRequestSent生成規則に一致するマップとする。

    6. sessionおよびbodyイベントを 発出する

    7. params["isBlocked"]が true である場合:

      1. blocked requestsを、sessionブロックされた リクエストマップとする。

      2. request idを、requestリクエスト IDとする。

      3. blocked requests[request id]を(request, "beforeRequestSent", null)に設定する。

      4. (response, status)を、«"continue request"» およびrequestリクエスト ID待機する結果とする。

      5. statusが "complete" である場合、response statusstatusに設定する。

      6. blocked requests[request id]を除去する

      注記: 待機している間、リクエストの追加処理は発生しない。

  11. emulated network conditionsを、 related navigablesエミュレートされたネットワーク条件を取得する結果とする。

  12. emulated network conditionsが null でなく、かつ emulated network conditionsofflineが true である場合、(ネットワークエラー, "complete")を返す。

  13. (response, response status)を返す。

Fetch の "HTTP-network-or-cache fetch" アルゴリズムにおいて戻り値を尊重する。

7.5.6.3. network.fetchError イベント
イベント型
network.FetchError = (
  method: "network.fetchError",
  params: network.FetchErrorParameters
 )

network.FetchErrorParameters = {
  network.BaseParameters,
  errorText: text,
}

このイベントは、ネットワークリクエストがエラーで終了したときに発火される。

remote end event trigger は、request request が与えられたときの WebDriver BiDi fetch error 手順である:
  1. before request sent map[request] が requestredirect count を含まない場合、requestWebDriver BiDi before request sent 手順を実行する。

    注: これにより、呼び出し元がすべてのエラーパスで WebDriver BiDi before request sent 手順を明示的に呼び出す必要なく、network.fetchError の前に network.beforeRequestSent が常に発火され得ることが保証される。

  2. requestclient が null でない場合、related navigablesrequestclientget related navigables した結果とする。そうでなければ related navigables を空の set とする。

  3. requestMaybe abort network response body collection する。

  4. "network.fetchError" および related navigables が与えられたときの、 set of sessions for which an event is enabled 内の各 session について:

    1. params を、session、 "network.fetchError"、および requestprocess a network event した結果とする。

    2. paramserrorText フィールドを、リクエストを中止させたエラーを説明する 実装定義の文字列に設定する。

    3. Assert: paramsnetwork.FetchErrorParameters production に一致する。

    4. body を、params フィールドを params に設定した、 network.FetchError production に一致する map とする。

    5. session および bodyEmit an event する。

7.5.6.4. network.responseCompleted イベント
イベント型
network.ResponseCompleted = (
    method: "network.responseCompleted",
    params: network.ResponseCompletedParameters
    )

    network.ResponseCompletedParameters = {
    network.BaseParameters,
    response: network.ResponseData,
    }

このイベントは、完全なレスポンスボディが受信された後に発火される。

remote end event trigger は、request request および response response が与えられたときの WebDriver BiDi response completed 手順である:
  1. redirect countrequestredirect count とする。

  2. Assert: before request sent map[request] は redirect count を含む。

    注: これは、すべての呼び出し元が、これらの手順の前に WebDriver BiDi before request sent 手順が request で呼び出されることを保証する必要があることを意味する。

  3. requestclient が null でない場合、related navigablesrequestclientget related navigables した結果とする。そうでなければ related navigables を空の set とする。

  4. request および responseMaybe collect network response body する。

  5. sessions を、"network.responseCompleted" および related navigables が与えられたときの set of sessions for which an event is enabled とする。

  6. sessions 内の各 session について:

    1. params を、session、 "network.responseCompleted"、および requestprocess a network event した結果とする。

    2. Assert: params["isBlocked"] は false である。

    3. response data を、responseget the response data した結果とする。

    4. paramsresponse フィールドを response data に設定する。

    5. Assert: paramsnetwork.ResponseCompletedParameters production に一致する。

    6. body を、params フィールドを params に設定した、 network.ResponseCompleted production に一致する map とする。

    7. session および bodyEmit an event する。

7.5.6.5. network.responseStarted イベント
イベント型
network.ResponseStarted = (
    method: "network.responseStarted",
    params: network.ResponseStartedParameters
    )

    network.ResponseStartedParameters = {
    network.BaseParameters,
    response: network.ResponseData,
    }

このイベントは、レスポンスヘッダーが受信された後、ただし body が完了する前に発火される。

remote end event trigger は、request request および response response が与えられたときの WebDriver BiDi response started 手順である:
  1. redirect countrequestredirect count とする。

  2. Assert: before request sent map[request] は redirect count と等しい。

    注: これは、すべての呼び出し元が、これらの手順の前に WebDriver BiDi before request sent 手順が request で呼び出されることを保証する必要があることを意味する。

  3. requestclient が null でない場合、related navigablesrequestclientget related navigables した結果とする。そうでなければ related navigables を空の set とする。

  4. response status を "incomplete" とする。

  5. sessions を、"network.responseStarted" および related navigables が与えられたときの set of sessions for which an event is enabled とする。

  6. sessions 内の各 session について:

    1. params を、session、 "network.responseStarted"、および requestprocess a network event した結果とする。

    2. response data を、responseget the response data した結果とする。

    3. paramsresponse フィールドを response data に設定する。

    4. Assert: paramsnetwork.ResponseStartedParameters production に一致する。

    5. body を、params フィールドを params に設定した、 network.ResponseStarted production に一致する map とする。

    6. session および bodyEmit an event する。

    7. params["isBlocked"] が true の場合:

      1. blocked requestssessionblocked request map とする。

      2. request idrequestrequest id とする。

      3. blocked requests[request id] を (request, "beforeRequestSent", response) に設定する。

      4. (response, status) を、 «"continue request"» および request idawait したものとする。

      5. status が "complete" の場合、response statusstatus に設定する。

      6. blocked requests[request id] を Remove する。

  7. (response, response status) を返す。

7.6. script モジュール

script モジュールは、script レルムおよび実行に関連するコマンドとイベントを含む。

7.6.1. 定義

Remote end definition

ScriptCommand = (
  script.AddPreloadScript //
  script.CallFunction //
  script.Disown //
  script.Evaluate //
  script.GetRealms //
  script.RemovePreloadScript
)

local end definition

ScriptResult = (
  script.AddPreloadScriptResult /
  script.CallFunctionResult /
  script.DisownResult /
  script.EvaluateResult /
  script.GetRealmsResult /
  script.RemovePreloadScriptResult
)

ScriptEvent = (
  script.Message //
  script.RealmCreated //
  script.RealmDestroyed
)

7.6.2. プリロードスクリプト

プリロードスクリプトは、新しいWindowの作成時に実行されるものであり、 author 定義のスクリプトが実行される前に実行される。

TODO: これを他の種類のレルム内のスクリプトにも拡張する。

BiDi セッションプリロードスクリプトマップを持ち、 これはマップであり、 そのキーはUUIDで、その値は、文字列である function declarationという名前の項目、 リストであるargumentsという名前の項目、 リストまたは null であるcontextsという名前の項目、 文字列または null であるsandboxという名前の項目、 および集合である user contextsという名前の項目を持つ構造体である。

注記: プリロードスクリプトの実行が、構文エラーまたは 実行時例外のために失敗した場合、その実行が行われていたレルムで [ECMAScript]例外が報告され、他のプリロードスクリプトは通常どおり実行される。

environment settingsが与えられたとき、WebDriver BiDi プリロードスクリプトを実行するには:
  1. documentを、environment settings関連大域オブジェクト関連付けられたDocumentとする。

  2. navigableを、documentnavigableとする。

  3. user contextを、navigable関連付けられたユーザー コンテキストとする。

  4. user context idを、user contextユーザー コンテキスト IDとする。

  5. アクティブ BiDi セッション内の各sessionについて:

    1. sessionプリロードスクリプトマップ内の各preload scriptについて:

      1. preload scriptuser contextsサイズがゼロでない場合:

        1. preload scriptuser contextsuser context id含まない場合、 続行する

      2. preload scriptcontextsが null でない場合:

        1. navigable idを、navigableトップレベル辿可能の id とする。

        2. preload scriptcontextsnavigable id含まない場合、 続行する

      3. preload scriptsandboxが null でない場合、 realmを、preload scriptsandboxおよび navigablesandbox レルムを取得または作成する 結果とする。そうでなければ、realmenvironment settingsレルム実行コンテキストの Realm component とする。

      4. exception reporting globalを、environment settingsレルム実行コンテキストの Realm component の大域オブジェクトとする。

      5. argumentsを、preload scriptargumentsとする。

      6. deserialized argumentsを空のリストとする。

      7. arguments内の各argumentについて:

        1. channelを、sessionrealm、および argumentチャネルを作成する結果とする。

        2. channeldeserialized argumentsに付加する。

      8. base URLを、environment settingsAPI 基底 URLとする。

      9. optionsを、既定のスクリプトフェッチオプションとする。

      10. function declarationを、preload scriptfunction declarationとする。

      11. function body evaluation statusを、 function declarationenvironment settingsbase URL、およびoptions関数本体を評価する結果とする。

      12. function body evaluation statusabrupt completionである場合、 function body evaluation status.[[Value]]により与えられる例外を、 exception reporting globalについて 報告する

      13. function objectを、function body evaluation status.[[Value]]とする。

      14. IsCallable(function object)が falseである場合:

        1. errorを、 realm内の新しいTypeErrorオブジェクトとする。

        2. exception reporting globalについて error例外として報告する

      15. environment settingsスクリプトを実行する準備をする

      16. evaluation statusCall(function object, null, deserialized arguments)に設定する。

      17. environment settingsスクリプト実行後の後始末をする

      18. evaluation statusabrupt completionである場合、 evaluation status.[[Value]]により与えられる例外を、 exception reporting globalについて 報告する

7.6.3.

7.6.3.1. script.Channel 型

リモートエンド定義 およびローカルエンド定義

script.Channel = text;

script.Channel 型は、リモートエンドから ローカルエンドへカスタムメッセージを送信するために使用される、 特定のチャネルの ID を表す。

7.6.3.2. script.ChannelValue 型

リモートエンド定義

script.ChannelValue = {
  type: "channel",
  value: script.ChannelProperties,
}

script.ChannelProperties = {
  channel: script.Channel,
  ? serializationOptions: script.SerializationOptions,
  ? ownership: script.ResultOwnership,
}

script.ChannelValue型は、 リモートエンドからローカルエンドへ メッセージを送信する関数へ逆直列化できるArgumentValueを表す。

sessionrealm および protocol value が与えられたときに create a channel するには:

  1. channel propertiesprotocol value["value"] とする。

  2. steps を、引数 message が与えられたときの次の手順とする:

    1. current realmcurrent Realm Record とする。

    2. sessioncurrent realmchannel properties および messageEmit a script message する。

  3. CreateBuiltinFunction(steps, 1, "", « », realm) を返す。

7.6.3.3. script.EvaluateResult 型

リモートエンド定義 およびローカルエンド定義

script.EvaluateResult = (
    script.EvaluateResultSuccess /
    script.EvaluateResultException
    )

    script.EvaluateResultSuccess = {
    type: "success",
    result: script.RemoteValue,
    realm: script.Realm
    }

    script.EvaluateResultException = {
    type: "exception",
    exceptionDetails: script.ExceptionDetails
    realm: script.Realm
    }

script.EvaluateResult 型は、script を実行するコマンドの戻り値を示す。 script.EvaluateResultSuccess バリアントは、script が正常に完了した場合に使用され、 script.EvaluateResultException バリアントは、script が投げられた例外により 完了した場合に使用される。

7.6.3.4. script.ExceptionDetails 型

リモートエンド定義 およびローカルエンド定義

script.ExceptionDetails = {
  columnNumber: js-uint,
  exception: script.RemoteValue,
  lineNumber: js-uint,
  stackTrace: script.StackTrace,
  text: text,
}

script.ExceptionDetails型は JavaScript 例外を表す。

realm完了レコード recordownership typeおよびsessionが与えられたとき、例外の 詳細を取得するには:

  1. 表明:record.[[Type]] はthrowである。

  2. textを、recordにより表されるエラーの実装定義のテキスト説明とする。

    TODO: ここでの要件を厳密化する。人々はおそらく正規表現か同じくらい悪い何かで このデータを解析しようとするだろう。

  3. serialization optionsを、各フィールドが既定値に設定された script.SerializationOptions生成規則に一致するマップとする。

  4. exceptionを、 record.[[Value]]、serialization optionsownership type、 直列化内部マップとしての新しいマップrealmおよび sessionリモート値として 直列化する結果とする。

  5. stack traceを、recordが与えられたときの例外のスタックトレースとする。

  6. stack traceのサイズが 1 以上である場合、line numberstack trace[0]内のlineNumberフィールドの値とし、column numberstack trace[0]のcolumnNumberフィールドの値とする。そうでなければ、 line numberおよびcolumn numberを 0 とする。

  7. exception detailsを、 textフィールドがtextに、exceptionフィールドがexceptionに、 lineNumberフィールドがline numberに、 columnNumberフィールドがcolumn numberに、 stackTraceフィールドがstack traceに設定された、 script.ExceptionDetails生成規則に一致するマップとする。

  8. exception detailsを返す。

7.6.3.5. script.Handle 型

リモートエンド定義 およびローカルエンド定義

script.Handle = text;

script.Handle型は、ECMAScript ランタイムに所有されるオブジェクトへのハンドルを表す。 このハンドルは特定のRealm内でのみ有効である。

各 ECMAScript Realmには、対応するハンドルオブジェクトマップがある。これは ハンドル ID からそれに対応するオブジェクトへの強いマップである。

7.6.3.6. script.InternalId 型

リモートエンド定義 およびローカルエンド定義

script.InternalId = text;

script.InternalId型は、 直列化中に以前に直列化された script.RemoteValueの ID を表す。

7.6.3.7. script.LocalValue 型

リモートエンド定義

script.LocalValue = (
  script.RemoteReference /
  script.PrimitiveProtocolValue /
  script.ChannelValue /
  script.ArrayLocalValue /
  { script.DateLocalValue } /
  script.MapLocalValue /
  script.ObjectLocalValue /
  { script.RegExpLocalValue } /
  script.SetLocalValue
)

script.ListLocalValue = [*script.LocalValue];

script.ArrayLocalValue = {
  type: "array",
  value: script.ListLocalValue,
}

script.DateLocalValue = (
  type: "date",
  value: text
)

script.MappingLocalValue = [*[(script.LocalValue / text), script.LocalValue]];

script.MapLocalValue = {
  type: "map",
  value: script.MappingLocalValue,
}

script.ObjectLocalValue = {
  type: "object",
  value: script.MappingLocalValue,
}

script.RegExpValue = {
  pattern: text,
  ? flags: text,
}

script.RegExpLocalValue = (
  type: "regexp",
  value: script.RegExpValue,
)

script.SetLocalValue = {
  type: "set",
  value: script.ListLocalValue,
}

script.LocalValue 型は、ECMAScript へ逆直列化できる値を表す。これには、プリミティブ値および非プリミティブ値の 両方に加え、リモート参照および チャネルが含まれる。

serialized key-value listrealm およびsessionが与えられたとき、キー値リストを 逆直列化するには:

  1. deserialized key-value listを新しいリストとする。

  2. serialized key-value list内の各serialized key-valueについて:

    1. serialized key-valueサイズが 2 でない場合、 エラーエラーコード invalid argumentで返す。

    2. serialized keyserialized key-value[0]とする。

    3. serialized keystringである場合、 deserialized keyserialized keyとする。

    4. そうでなければ、deserialized keyを、serialized keyrealmおよびsession試行して ローカル値を逆直列化する結果とする。

    5. serialized valueserialized key-value[1]とする。

    6. deserialized valueを、 serialized valuerealmおよびsessionが与えられて試行して ローカル値を逆直列化する 結果とする。

    7. CreateArrayFromListdeserialized key, deserialized value»)を deserialized key-value listに付加する。

  3. 成功をデータdeserialized key-value listとともに返す。

serialized value listrealmおよび sessionが与えられたとき、値リストを 逆直列化するには:

  1. deserialized valuesを新しいリストとする。

  2. serialized value list内の各serialized valueについて:

    1. deserialized valueを、 serialized valuerealmおよびsessionが与えられて試行して ローカル値を逆直列化する 結果とする。

    2. deserialized valuedeserialized valuesに付加する。

  3. 成功をデータdeserialized valuesとともに返す。

local protocol valuerealmおよび sessionが与えられたとき、ローカル値を 逆直列化するには:

  1. local protocol valuescript.RemoteReference 生成規則に一致する場合、 与えられたlocal protocol valuerealmおよび sessionリモート参照を逆直列化する結果を返す。

  2. local protocol valuescript.PrimitiveProtocolValue生成規則に一致する場合、 local protocol valueプリミティブプロトコル値を逆直列化する 結果を返す。

  3. local protocol valuescript.ChannelValue生成規則に一致する場合、 sessionrealmおよびlocal protocol valueチャネルを 作成する結果を返す。

  4. typeを、local protocol valuetypeフィールドの値、または そのようなフィールドがない場合は undefined とする。

  5. valueを、local protocol valuevalueフィールドの値、または そのようなフィールドがない場合は undefined とする。

  6. 以下の条件とそれに関連付けられた手順のリストにおいて、 関連付けられた条件が true である最初の手順群を実行する:

    type is the string "array"
    1. deserialized value listを、valuerealmおよびsessionが与えられて試行して値リストを逆直列化する 結果とする。

    2. 成功をデータCreateArrayFromList(deserialized value list)とともに返す。

    type is the string "date"
    1. valueDate Time String Formatに一致しない場合、 エラーエラーコード invalid argumentで返す。

    2. date resultConstruct(Date, value)とする。

    3. 表明:date resultabrupt completionでない。

    4. 成功をデータdate resultとともに返す。

    type is the string "map"
    1. deserialized key-value listを、 valuerealmおよびsession試行して キー値リストを逆直列化する結果とする。

    2. iterableCreateArrayFromList(deserialized key-value list)とする

    3. 成功をデータMap(iterable)とともに返す。

    type is the string "object"
    1. deserialized key-value listを、 valuerealmおよびsession試行して キー値リストを逆直列化する結果とする。

    2. iterableCreateArrayFromList(deserialized key-value list)とする

    3. 成功をデータObject.fromEntries(iterable) とともに返す。

    type is the string "regexp"
    1. patternを、local protocol valuepatternフィールドの値とする。

    2. flagsを、local protocol valueflagsフィールドの値、または そのようなフィールドがない場合は undefined とする。

    3. regex_resultRegexp(pattern, flags)とする。これが例外を投げる場合、エラーエラーコード invalid argumentで返す。

    4. 成功をデータregex_resultとともに返す。

    type is the string "set"
    1. deserialized value listを、valuerealmおよびsessionが与えられて試行して値リストを逆直列化する 結果とする。

    2. iterableCreateArrayFromList(deserialized key-value list)とする

    3. 成功をデータSet object(iterable)とともに返す。

    それ以外
    エラーエラーコード invalid argumentで返す。
7.6.3.8. script.PreloadScript 型

リモートエンド定義 およびローカルエンド定義

script.PreloadScript = text;

script.PreloadScript型は、realm 作成時に実行されるスクリプトへのハンドルを表す。

7.6.3.9. script.Realm 型

リモートエンド定義 およびローカルエンド定義

script.Realm = text;

realmには、関連付けられたrealm IDがあり、これはその realm を 一意に識別する文字列である。これは realm が作成されるときに暗黙的に設定される。

realm のrealm IDは不透明であり、 対応する大域オブジェクトのハンドル ID からハンドルオブジェクトマップ内で導出可能であってはならず、また 関連する場合には、任意のnavigable ID からnavigableにおいて導出可能であってはならない。

注記: これは、ユーザーが異なる ID 間の 実装固有の関係に依存しないようにするためである。

realm idが与えられたとき、realm を取得するには:
  1. realm idが null である場合、成功を データ null とともに返す。

  2. realmで、IDrealm idであるものが存在しない場合、 エラーエラー コード no such frameで返す

  3. realmを、realmIDrealm idであるものとする。

  4. 成功をデータrealmとともに返す

これは誤った エラーコードを持つ

7.6.3.10. script.PrimitiveProtocolValue 型

リモートエンド定義 およびローカルエンド定義

script.PrimitiveProtocolValue = (
  script.UndefinedValue /
  script.NullValue /
  script.StringValue /
  script.NumberValue /
  script.BooleanValue /
  script.BigIntValue
)

script.UndefinedValue = {
  type: "undefined",
}

script.NullValue = {
  type: "null",
}

script.StringValue = {
  type: "string",
  value: text,
}

script.SpecialNumber = "NaN" / "-0" / "Infinity" / "-Infinity";

script.NumberValue = {
  type: "number",
  value: number / script.SpecialNumber,
}

script.BooleanValue = {
  type: "boolean",
  value: bool,
}

script.BigIntValue = {
  type: "bigint",
  value: text,
}

script.PrimitiveProtocolValueは、参照によってではなく、 値によってのみ表現できる値を表す。

valueが与えられたとき、プリミティブプロトコル値を直列化するには:

  1. remote valueを undefined とする。

  2. 以下の条件とそれに関連付けられた手順のリストにおいて、もしあれば、 関連付けられた条件が true である最初の手順群を実行する:

    Type(value) is undefined
    remote valueを、ローカルエンド定義内の script.UndefinedValue 生成規則に一致するマップとする。
    Type(value) is Null
    remote valueを、ローカルエンド定義内の script.NullValue 生成規則に一致するマップとする。
    Type(value) is String
    remote valueを、ローカルエンド定義内の script.StringValue 生成規則に一致し、value プロパティがvalueに設定されたマップとする。

    これは 孤立サロゲートを処理しない

    Type(value) is Number
    1. valueの値で分岐する:

      NaN
      serialized"NaN"とする
      -0
      serialized"-0"とする
      Infinity
      serialized"Infinity"とする
      -Infinity
      serialized"-Infinity"とする
      Otherwise:
      serializedvalueとする
    2. remote valueを、ローカルエンド定義内の script.NumberValue 生成規則に一致し、value プロパティがserializedに設定されたマップとする。

    Type(value) is Boolean
    remote valueを、ローカルエンド定義内の script.BooleanValue 生成規則に一致し、value プロパティがvalueに設定されたマップとする。
    Type(value) is BigInt
    remote valueを、ローカルエンド定義内の script.BigIntValue 生成規則に一致し、value プロパティがvalueに対してToString 演算を実行した結果に設定されたマップとする。
  3. remote valueを返す

primitive protocol valueが与えられたとき、プリミティブプロトコル値を逆直列化するには:

  1. typeを、primitive protocol valuetypeフィールドの値とする。

  2. valueを undefined とする。

  3. primitive protocol valuevalueフィールドを持つ場合:

    1. valueを、primitive protocol valuevalueフィールドの値とする。

  4. 以下の条件とそれに関連付けられた手順のリストにおいて、 関連付けられた条件が true である最初の手順群を実行する:

    type is the string "undefined"
    成功をデータundefinedとともに返す。
    type is the string "null"
    成功をデータnullとともに返す。
    type is the string "string"
    成功をデータvalueとともに返す。
    type is the string "number"
    1. Type(value) が Number である場合、成功をデータvalueとともに返す。

    2. 表明:Type(value) は String である。

    3. valueが文字列 "NaN" である場合、成功を データ NaN とともに返す。

    4. number_resultStringToNumber(value)とする。

    5. number_resultが NaN である場合、エラーエラーコード invalid argumentで返す

    6. 成功をデータnumber_resultとともに返す。

    type is the string "boolean"
    成功をデータvalueとともに返す。
    type is the string "bigint"
    1. bigint_resultStringToBigInt(value)とする。

    2. bigint_resultが undefined である場合、エラーエラーコード invalid argumentで返す

    3. 成功をデータbigint_resultとともに返す。

  5. エラーエラー コード invalid argumentで返す

7.6.3.11. script.RealmInfo 型

ローカルエンド定義

script.RealmInfo = (
  script.WindowRealmInfo /
  script.DedicatedWorkerRealmInfo /
  script.SharedWorkerRealmInfo /
  script.ServiceWorkerRealmInfo /
  script.WorkerRealmInfo /
  script.PaintWorkletRealmInfo /
  script.AudioWorkletRealmInfo /
  script.WorkletRealmInfo
)

script.BaseRealmInfo = (
  realm: script.Realm,
  origin: text
)

script.WindowRealmInfo = {
  script.BaseRealmInfo,
  type: "window",
  context: browsingContext.BrowsingContext,
  ? userContext: browser.UserContext,
  ? sandbox: text
}

script.DedicatedWorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "dedicated-worker",
  owners: [script.Realm]
}

script.SharedWorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "shared-worker"
}

script.ServiceWorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "service-worker"
}

script.WorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "worker"
}

script.PaintWorkletRealmInfo = {
  script.BaseRealmInfo,
  type: "paint-worklet"
}

script.AudioWorkletRealmInfo = {
  script.BaseRealmInfo,
  type: "audio-worklet"
}

script.WorkletRealmInfo = {
  script.BaseRealmInfo,
  type: "worklet"
}

注記: script.RealmInfo 変種とscript.RealmTypeの値の間には 1:1 の関係がある。

script.RealmInfo型は realm のプロパティを表す。

与えられたrealmで、navigable を取得するには:
  1. global objectを、realm大域オブジェクトとする。

  2. global objectを、unwrappedされたglobal objectとする。

  3. global objectWindow オブジェクトでない場合、nullを返す。

  4. documentを、global objectのラップされたWindow関連付けられたDocumentとする。

  5. documentnode navigableを返す。

与えられたglobal objectで、worker の owner を取得するには:
  1. 表明:global objectWorkerGlobalScope オブジェクトである。

  2. ownersを空のリストとする。

  3. global objectに関連付けられたowner 集合内の各ownerについて:

    1. owner environment settingsを、owner関連設定オブジェクトとする。

    2. owner realm infoを、 owner environment settingsが与えられたときのrealm info を取得する 結果とする。

    3. owner realm infoが null である場合、続行する。

    4. owner realm info["id"]をownersに付加する。

  4. ownersを返す。

environment settingsが与えられたとき、realm info を取得するには:
  1. realmを、environment settingsrealm 実行コンテキストの Realm component とする。

  2. realm idを、realmrealm IDとする。

  3. originを、environment settingsoriginが与えられたときの origin の直列化とする。

  4. global objectを、environment settingsにより指定される大域オブジェクトとする

  5. 最初に一致する条件の下の手順を実行する:

    global object is a Window object
    1. documentを、environment settings関連大域オブジェクト関連付けられたDocumentとする。

    2. navigableを、documentnode navigableとする。

    3. navigableが null である場合、null を返す。

    4. navigable idを、navigablenavigable IDとする。

    5. user context idを、navigable関連付けられたユーザーコンテキストユーザーコンテキスト IDとする

    6. realm infoを、 realmフィールドがrealm idに、origin フィールドがoriginに、contextフィールドが navigable idに、 userContextフィールドがuser context idに設定された、 script.WindowRealmInfo生成規則に一致するマップとする。

    global object is SandboxWindowProxy object
    TODO: これが sandbox を扱うための正しい定式化かは不明である。
    1. documentを、global objectのラップされたWindow関連付けられたDocumentとする。

    2. navigableを、documentnode navigableとする。

    3. navigableが null である場合、null を返す。

    4. navigable idを、navigablenavigable IDとする。

    5. user context idを、navigable関連付けられたユーザーコンテキストユーザーコンテキスト IDとする

    6. sandbox nameを、 realmが与えられたときのsandbox 名を取得する結果とする。

    7. 表明:sandbox nameは null でない。

    8. realm infoを、 realmフィールドがrealm idに、origin フィールドがoriginに、contextフィールドが navigable idに、 userContextフィールドがuser context idに、 sandboxフィールドがsandbox nameに設定された、 script.WindowRealmInfo生成規則に一致するマップとする。

    global object is a DedicatedWorkerGlobalScope object
    1. ownersを、global objectが与えられたときのworker の owner を取得する結果とする。

    2. 表明:ownersは正確に 1 つの項目を持つ。

    3. realm infoを、 realmフィールドがrealm idに、originフィールド がoriginに、ownersフィールドが ownersに設定された、 script.DedicatedWorkerRealmInfo生成規則に一致するマップとする。

    global object is a SharedWorkerGlobalScope object
    1. realm infoを、 realmフィールドがrealm idに、 originフィールド がoriginに設定された、 script.SharedWorkerRealmInfo生成規則に一致するマップとする。

    global object is a ServiceWorkerGlobalScope object
    1. realm infoを、 realmフィールドがrealm idに、 originフィールド がoriginに設定された、 script.ServiceWorkerRealmInfo生成規則に一致するマップとする。

    global object is a WorkerGlobalScope object
    1. realm infoを、 realmフィールドがrealm idに、 origin フィールドがoriginに設定された、 script.WorkerRealmInfo生成規則に一致するマップとする。

    global object is a PaintWorkletGlobalScope object
    1. realm infoを、 realmフィールドがrealm idに、 origin フィールドがoriginに設定された、 script.PaintWorkletRealmInfo生成規則に一致するマップとする。

    global object is a AudioWorkletGlobalScope object
    1. realm infoを、 realmフィールドがrealm idに、 origin フィールドがoriginに設定された、 script.AudioWorkletRealmInfo生成規則に一致するマップとする。

    global object is a WorkletGlobalScope object
    1. realm infoを、 realmフィールドがrealm idに、 origin フィールドがoriginに設定された、 script.WorkletRealmInfo生成規則に一致するマップとする。

    Otherwise:
    1. realm infoを null とする。

  6. realm infoを返す

注記: この仕様の将来の変種では、 型名を "-" で分割した後の最後の構成要素が、 WorkerGlobalScopeを実装する globals については 常に "worker" であり、 WorkletGlobalScopeを 実装する globals については "worklet" であるという不変条件を保持する。

7.6.3.12. script.RealmType 型

リモートエンド定義 およびローカルエンド定義

script.RealmType = "window" / "dedicated-worker" / "shared-worker" / "service-worker" /
                   "worker" / "paint-worklet" / "audio-worklet" / "worklet"

script.RealmType型は、Realm のさまざまな型を表す。

7.6.3.13. script.RemoteReference 型

リモートエンド定義

script.RemoteReference = (
  script.SharedReference /
  script.RemoteObjectReference
)

script.SharedReference = {
   sharedId: script.SharedId

   ? handle: script.Handle,
   Extensible
}

script.RemoteObjectReference = {
   handle: script.Handle,

   ? sharedId: script.SharedId
   Extensible
}

script.RemoteReference 型は、与えられたRealm内の ハンドルオブジェクトマップに存在する ECMAScript オブジェクトへのリモート参照を表す script.RemoteObjectReference、またはnodeへの参照を表す script.SharedReferenceのいずれかである。

"stale object reference" の場合を扱う。

注記: 提供された参照が handlesharedIdの両方を持つ場合、アルゴリズムはhandleを無視し、 sharedIdのみを尊重する。

remote referencerealmおよび sessionが与えられたとき、リモート参照を逆直列化するには:
  1. remote referencescript.RemoteReference生成規則に一致することを表明する。

  2. remote referencescript.SharedReference生成規則に一致する場合、 remote referencerealmおよびsession共有参照を逆直列化する結果を返す。

  3. remote referenceおよび realmリモートオブジェクト参照を逆直列化する結果を返す。

remote object referenceおよび realmが与えられたとき、リモートオブジェクト参照を逆直列化するには:
  1. handle idを、 remote object referencehandleフィールドの値とする。

  2. handle mapを、realmハンドルオブジェクトマップとする

  3. handle maphandle idを含まない場合、エラーエラーコード no such handleで返す。

  4. 成功をデータ handle map[handle id] とともに返す。

shared referencerealmおよび sessionが与えられたとき、共有参照を逆直列化するには:
  1. shared referencescript.SharedReference生成規則に一致することを表明する。

  2. navigableを、realmnavigable を取得する結果とする。

  3. navigablenullである場合、エラーエラーコード no such nodeで返す。

    注記: これは realm が Window global でない場合に発生する。

  4. shared idを、 shared referencesharedIdフィールドの値とする。

  5. nodeを、sessionnavigableおよびshared id試行してnode を取得する結果とする。

  6. nodenullである場合、エラーエラーコード no such nodeで返す。

  7. environment settingsを、そのrealm 実行コンテキストの Realm component が realmである環境設定オブジェクトとする。

  8. nodenode documentoriginが、environment settingsorigin同一オリジンドメインでない場合、 エラーエラー コード no such nodeで返す。

    注記: これにより、WebDriver-BiDi が、 それ以外ではスクリプトアクセスを許可しない realm 間でオブジェクトを渡すために 使用できないことが保証される。

  9. realm global objectを、realm大域オブジェクトとする。

  10. realm global objectSandboxWindowProxy オブジェクトである場合、 nodeを、realm内でnodeをラップするSandboxProxy に設定する。

  11. 成功をデータ node とともに返す。

7.6.3.14. script.RemoteValue 型

リモートエンド定義 およびローカルエンド定義

script.RemoteValue = (
  script.PrimitiveProtocolValue /
  script.SymbolRemoteValue /
  script.ArrayRemoteValue /
  script.ObjectRemoteValue /
  script.FunctionRemoteValue /
  script.RegExpRemoteValue /
  script.DateRemoteValue /
  script.MapRemoteValue /
  script.SetRemoteValue /
  script.WeakMapRemoteValue /
  script.WeakSetRemoteValue /
  script.GeneratorRemoteValue /
  script.ErrorRemoteValue /
  script.ProxyRemoteValue /
  script.PromiseRemoteValue /
  script.TypedArrayRemoteValue /
  script.ArrayBufferRemoteValue /
  script.NodeListRemoteValue /
  script.HTMLCollectionRemoteValue /
  script.NodeRemoteValue /
  script.WindowProxyRemoteValue
)

script.ListRemoteValue = [*script.RemoteValue];

script.MappingRemoteValue = [*[(script.RemoteValue / text), script.RemoteValue]];

script.SymbolRemoteValue = {
  type: "symbol",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ArrayRemoteValue = {
  type: "array",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.ObjectRemoteValue = {
  type: "object",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.MappingRemoteValue,
}

script.FunctionRemoteValue = {
  type: "function",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.RegExpRemoteValue = {
  script.RegExpLocalValue,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.DateRemoteValue = {
  script.DateLocalValue,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.MapRemoteValue = {
  type: "map",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.MappingRemoteValue,
}

script.SetRemoteValue = {
  type: "set",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue
}

script.WeakMapRemoteValue = {
  type: "weakmap",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.WeakSetRemoteValue = {
  type: "weakset",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.GeneratorRemoteValue = {
  type: "generator",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ErrorRemoteValue = {
  type: "error",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ProxyRemoteValue = {
  type: "proxy",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.PromiseRemoteValue = {
  type: "promise",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.TypedArrayRemoteValue = {
  type: "typedarray",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ArrayBufferRemoteValue = {
  type: "arraybuffer",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.NodeListRemoteValue = {
  type: "nodelist",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.HTMLCollectionRemoteValue = {
  type: "htmlcollection",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.NodeRemoteValue = {
  type: "node",
  ? sharedId: script.SharedId,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.NodeProperties,
}

script.NodeProperties = {
  nodeType: js-uint,
  childNodeCount: js-uint,
  ? attributes: {*text => text},
  ? children: [*script.NodeRemoteValue],
  ? localName: text,
  ? mode: "open" / "closed",
  ? namespaceURI: text,
  ? nodeValue: text,
  ? shadowRoot: script.NodeRemoteValue / null,
}

script.WindowProxyRemoteValue = {
  type: "window",
  value: script.WindowProxyProperties,
  ? handle: script.Handle,
  ? internalId: script.InternalId
}

script.WindowProxyProperties = {
  context: browsingContext.BrowsingContext
}

WASM 型を追加する?

WindowProxy は Node と 同様のスタイルで属性を持つべきか?

String / Number / などの wrapper object を特別に扱う?

ECMAScript runtime からアクセス可能な値は mirror object により表され、script.RemoteValue として指定される。値の型は type プロパティで指定される。JSON で表現可能な primitive value の場合、これは value プロパティに値を含む。JSON で表現できない primitive の場合、 value プロパティは値の文字列表現を 含む。

非 primitive object については、handle プロパティが存在する場合、 その object への一意な文字列 handle を含む。handle は各 serialization ごとに一意である。remote end は、対応する handle を持つ object を、 その handle で script.disown が呼び出されるか、 realm 自身が破棄されることになるまで(例: navigation によって)生存させ続ける。

一部の非 primitive 型について、value プロパティは ECMAScript object 内のデータの表現を含む。container 型では、これはさらに script.RemoteValue instance を含むことができる。 value プロパティは、重複 object、すなわちその object が現在の script.RemoteValue 内ですでに serialize されている場合、おそらく cycle の一部として、 または最大 serialization depth に到達した場合、null になり得るか、省略され得る。

同じ script.RemoteValue 内に重複 object がある場合、 値は remote value のうち 1 つに対してのみ提供される一方で、 ECMAScript object ごとに一意な internalId は、与えられた serialization におけるすべての重複 object に対して提供される。

Nodescript.RemoteValue instance により表される。これらは value プロパティに node の部分的な serialization を持つ。

mirror objects の lifecycle を再検討する。

注: mirror object は runtime 内で元の object を 生存させ続けない。object が runtime 内で破棄された場合、その後に protocol を介してそれへアクセスしようとすると error になる。

realm, ownership type および object が与えられたときに object の handle を取得するには:
  1. ownership type が "none" と等しい場合、null を返す。

  2. handle id を、object のための新しい一意な文字列 handle とする。

  3. handle maprealmhandle object map とする

  4. handle map[handle id] を object に設定する。

  5. 結果として handle id を返す。

node および session が与えられたときに node の shared id を取得する には:
  1. nodeunwrapped node とする。

  2. nodeNode を実装しない場合、 null を返す。

  3. navigablenodenode navigable とする。

  4. navigable が null の場合、null を返す。

  5. session, navigable および nodeget or create a node reference した結果を返す。

serialization internal map, remote value および object が与えられたときに 必要なら internal ids を設定する には:
  1. serialization internal mapobject を含まない場合、 serialization internal map[object] を remote value に設定する。

  2. そうでなければ、次の手順を実行する:

    1. previously serialized remote valueserialization internal map[object] とする。

    2. previously serialized remote valueinternalId フィールドを持たない場合、次の手順を実行する:

      1. internal id を、真にランダム、または疑似ランダムな数に基づく UUID の文字列表現とする。

      2. previously serialized remote valueinternalId フィールドを internal id に設定する。

    3. remote valueinternalId フィールドを、 previously serialized remote value 内の internalId フィールドに設定する。

valueserialization optionsownership typeserialization internal maprealmおよび sessionが与えられたとき、リモート値として 直列化するには:

  1. remote valueを、 valueが与えられたときのプリミティブプロトコル値を直列化する結果とする。

  2. remote valueが undefined でない場合、remote valueを返す。

  3. handle idを、realmownership type およびvalueオブジェクトのハンドルとする。

  4. ownership typeを "none" に設定する。

  5. valueserialization internal map内にある場合はknown objecttrueとし、 そうでなければfalseとする。

  6. 以下の条件とそれに関連付けられた手順のリストにおいて、 関連付けられた条件が true である最初の手順群を実行する:

    Type(value) is Symbol
    remote valueを、ローカルエンド定義内の script.SymbolRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    IsArray(value)
    remote valueを、 sessionscript.ArrayRemoteValuehandle idknown objectvalueserialization optionsownership typeserialization internal maprealm、およびsessionArray-like として直列化する結果とする。
    IsRegExp(value)
    1. patternを、Get(value, "source")のToStringとする。

    2. flagsを、Get(value, "flags")のToStringとする。

    3. serializedを、 ローカルエンド定義内の script.RegExpValue生成規則に一致し、 patternプロパティが patternに、flagsプロパティが flagsに設定されたマップとする。

    4. remote valueを、 ローカルエンド定義内の script.RegExpRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略され、 valueプロパティがserializedに設定されたマップとする。

    value has a [[DateValue]] internal slot.
    1. serializedCall(Date.prototype.toISOString, value)に設定する。

    2. 表明:serializedthrow completionでない。

    3. remote valueを、 ローカルエンド定義内の script.DateRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略され、 value がserializedに設定されたマップとする。

    value has a [[MapData]] internal slot
    1. remote valueを、 ローカルエンド定義内の script.MapRemoteValue 生成規則に一致し、 handleプロパティが、handle idが null でなければそれに設定され、 そうでなければ省略されたマップとする。

    2. serialization internal mapremote valueおよびvalue必要なら内部 ID を設定する

    3. serializedを null とする。

    4. known objectfalseであり、かつserialization options["maxObjectDepth"]が 0 でない場合、次の手順を実行する:

      1. serializedを、 CreateMapIterator(value, key+value)、serialization optionsownership typeserialization internal maprealm、およびsessionマッピングとして直列化する結果とする。

    5. serializedが null でない場合、remote valuevalueフィールドを serializedに設定する。

    value has a [[SetData]] internal slot
    1. remote valueを、 ローカルエンド定義内の script.SetRemoteValue 生成規則に一致し、 handleプロパティが、handle idが null でなければそれに設定され、 そうでなければ省略されたマップとする。

    2. serialization internal mapremote valueおよびvalue必要なら内部 ID を設定する

    3. serializedを null とする。

    4. known objectfalseであり、かつserialization options["maxObjectDepth"]が 0 でない場合、次の手順を実行する:

      1. serializedを、 CreateSetIterator(value, value)、serialization optionsownership typeserialization internal maprealm、および sessionリストとして直列化する結果とする。

    5. serializedが null でない場合、remote valuevalueフィールドを serializedに設定する。

    value has a [[WeakMapData]] internal slot
    remote valueを、ローカルエンド定義内の script.WeakMapRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value has a [[WeakSetData]] internal slot
    remote valueを、ローカルエンド定義内の script.WeakSetRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value has a [[GeneratorState]] internal slot or [[AsyncGeneratorState]] internal slot
    remote valueを、ローカルエンド定義内の script.GeneratorRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value has an [[ErrorData]] internal slot
    remote valueを、ローカルエンド定義内の script.ErrorRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value has a [[ProxyHandler]] internal slot and a [[ProxyTarget]] internal slot
    remote valueを、ローカルエンド定義内の script.ProxyRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    IsPromise(value)
    remote valueを、ローカルエンド定義内の script.PromiseRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value has a [[TypedArrayName]] internal slot
    remote valueを、ローカルエンド定義内の script.TypedArrayRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value has an [[ArrayBufferData]] internal slot
    remote valueを、ローカルエンド定義内の script.ArrayBufferRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    value is a platform object that implements NodeList
    remote valueを、 script.NodeListRemoteValuehandle idknown objectvalueserialization optionsownership typeserialization internal maprealm、およびsessionArray-like として直列化する結果とする。
    value is a platform object that implements HTMLCollection
    remote valueを、 script.HTMLCollectionRemoteValuehandle idknown objectvalueserialization optionsownership typeknown objectserialization internal maprealm、およびsessionArray-like として直列化する結果とする。
    value is a platform object that implements Node
    1. shared idを、valueおよびsessionnode の shared id を取得する結果とする。

    2. remote valueを、 ローカルエンド定義内の script.NodeRemoteValue 生成規則に一致し、sharedId プロパティが、shared idが null でなければそれに設定され、そうでなければ省略され、 handleプロパティが、handle idが null でなければそれに設定され、 そうでなければ省略されたマップとする。

    3. serialization internal mapremote valueおよびvalue必要なら内部 ID を設定する

    4. serializedを null とする。

    5. known objectfalseである場合、次の手順を実行する:

      1. serializedマップとする。

      2. serialized["nodeType"]をGet(value, "nodeType")に設定する。

      3. node valueGet(value, "nodeValue")に設定する。

      4. node valueが null でない場合、 serialized["nodeValue"]をnode valueに設定する。

      5. valueElement またはAttrを実装する場合:

        1. serialized["localName"]をGet(value, "localName")に設定する。

        2. serialized["namespaceURI"]をGet(value, "namespaceURI")に設定する

      6. child node countを、valuechildrenサイズとする。

      7. serialized["childNodeCount"]をchild node countに設定する。

      8. serialization options["maxDomDepth"]が 0 に等しい場合、またはvalueShadowRootを実装し、 かつserialization options["includeShadowTree"]が "none" である場合、 またはserialization options["includeShadowTree"] が "open" であり、かつvaluemodeが "closed" である場合、childrenを null とする。

        そうでなければ、childrenを空の リストとし、valuechildren内の各 node childについて:

        1. child serialization optionsを、 serialization options複製とする。

        2. child serialization options["maxDomDepth"]が null でない場合、child serialization options["maxDomDepth"]をchild serialization options["maxDomDepth"] - 1 に設定する。

        3. serializedを、 childchild serialization optionsownership typeserialization internal maprealm、および sessionリモート値として 直列化する結果とする。

        4. serializedchildrenに付加する。

      9. childrenが null でない場合、 serialized["children"]をchildrenに設定する。

      10. valueElementを実装する場合:

        1. attributesを新しいマップとする。

        2. value属性リスト内の各attributeについて:

          1. nameを、attribute修飾 名とする

          2. valueを、attributeとする。

          3. attributes[name]を valueに設定する

        3. serialized["attributes"]を attributesに設定する。

        4. shadow rootを、valueshadow rootとする。

        5. shadow rootが null である場合、serialized shadowを null とする。 そうでなければ、次のサブ手順を実行する:

          1. serialized shadowを、 shadow rootserialization optionsownership typeserialization internal maprealm、およびsessionリモート値として 直列化する結果とする。

        6. serialized["shadowRoot"]を serialized shadowに設定する。

      11. valueShadowRootを実装する場合、 serialized["mode"] をvaluemodeに設定する。

    6. serializedが null でない場合、remote valuevalueフィールドを serializedに設定する。

    value is a platform object that implements WindowProxy
    1. windowを、valueの [[WindowProxy]] internal slotの値とする。

    2. navigableを、windownavigableとする。

    3. navigable idを、navigablenavigable IDとする。

    4. serializedを、ローカルエンド定義内の script.WindowProxyProperties生成規則に一致し、 contextプロパティがnavigable idに設定されたマップとする。

    5. remote valueを、 ローカルエンド定義内の script.WindowProxyRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略され、 valueプロパティがserializedに設定されたマップとする。

    value is a platform object
    1. remote valueを、ローカルエンド定義内の script.ObjectRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    IsCallable(value)
    remote valueを、ローカルエンド定義内の script.FunctionRemoteValue 生成規則に一致し、handle プロパティが、handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。
    Otherwise:
    1. 表明Type(value) は Object である

    2. remote valueを、 ローカルエンド定義内の script.ObjectRemoteValue生成規則に一致し、 handleプロパティが handle idが null でなければそれに設定され、そうでなければ省略されたマップとする。

    3. serialization internal mapremote valueおよびvalue必要なら内部 ID を設定する

    4. serializedを null とする。

    5. known objectfalseであり、かつserialization options["maxObjectDepth"]が 0 でない場合、次の手順を実行する:

      1. serializedを、 EnumerableOwnPropertyNames(value, key+value)、serialization optionsownership typeserialization internal maprealm、およびsessionマッピングとして直列化する結果とする。

    6. serializedが null でない場合、remote valuevalueフィールドを serializedに設定する。

  7. remote valueを返す

children と子 node は異なるものである。childNodeCountchildNodesを参照するべきか、またはchildrenCountに改名されるべきである。

production, handle id, known object, value, serialization options, ownership type, serialization internal map, realm, および session が与えられたときに Array-like を serialize する には:
  1. remote valueproduction に一致する map とし、 handle property は handle id が null でない場合はそれに設定し、そうでなければ 省略する。

  2. serialization internal map, remote value および valueSet internal ids if needed する。

  3. known objectfalse で、かつ serialization options["maxObjectDepth"] が 0 でない場合:

    1. serialized を、 CreateArrayIterator(value, value), serialization options, ownership type, serialization internal map, realm, および sessionserialize as a list した結果とする。

    2. serialized が null でない場合、remote valuevalue フィールドを serialized に設定する。

  4. remote value を返す

iterable, serialization options, ownership type, serialization internal map, realm, および session が与えられたときに list として serialize する には:
  1. serialization options["maxObjectDepth"] が null でない場合、 assert: serialization options["maxObjectDepth"] は 0 より大きい。

  2. serialized を新しい list とする。

  3. IteratorToList(GetIterator(iterable, sync)) 内の各 child value について:

    1. child serialization optionsserialization optionsclone とする。

    2. child serialization options["maxObjectDepth"] が null でない場合、child serialization options["maxObjectDepth"] を child serialization options["maxObjectDepth"] - 1 に設定する。

    3. serialized child を、 child value, child serialization options, ownership type, serialization internal map, realm, および sessionserialize as a remote value した結果とする。

    4. serialized childserialized に append する。

  4. serialized を返す

iterable, serialization options, ownership type, serialization internal map, realm, および session が与えられたときに mapping として serialize する には:

  1. serialization options["maxObjectDepth"] が null でない場合、 assert: serialization options["maxObjectDepth"] は 0 より大きい。

  2. serialized を新しい list とする。

  3. IteratorToList(GetIterator(iterable, sync)) 内の item について:

    1. Assert: IsArray(item)

    2. propertyCreateListFromArrayLike(item) とする

    3. Assert: propertysize 2 の list である

    4. keyproperty[0] とし、valueproperty[1] とする

    5. child serialization optionsserialization optionsclone とする。

    6. child serialization options["maxObjectDepth"] が null でない場合、child serialization options["maxObjectDepth"] を child serialization options["maxObjectDepth"] - 1 に設定する。

    7. Type(key) が String である場合、serialized keychild key とし、 そうでなければ serialized key を、 child key, child serialization options, ownership type, serialization internal map, realm, および sessionserialize as a remote value した結果とする。

    8. serialized value を、 value, child serialization options, ownership type, serialization internal map, realm, および sessionserialize as a remote value した結果とする。

    9. serialized child を («serialized key, serialized value») とする。

    10. serialized childserialized に append する。

  4. serialized を返す

7.6.3.15. script.ResultOwnership 型
script.ResultOwnership = "root" / "none"

script.ResultOwnership は、serialized value ownership がどのように扱われるかを指定する。

7.6.3.16. script.SerializationOptions 型

リモートエンド定義

script.SerializationOptions = {
  ? maxDomDepth: (js-uint / null) .default 0,
  ? maxObjectDepth: (js-uint / null) .default null,
  ? includeShadowTree: ("none" / "open" / "all") .default "none",
}

script.SerializationOptionsは、ECMAScript オブジェクトをどのように 直列化するかを指定できるようにする。

7.6.3.17. script.SharedId 型

リモートエンド定義 およびローカルエンド定義

script.SharedId = text;

script.SharedId型は、任意の realm(Sandbox Realmを含む)で 使用可能な DOM Nodeへの参照を表す。

7.6.3.18. script.StackFrame 型

リモートエンド定義 およびローカルエンド定義

script.StackFrame = {
  columnNumber: js-uint,
  functionName: text,
  lineNumber: js-uint,
  url: text,
}

スタックトレース内のフレームは、StackFrame オブジェクトにより表される。これは、スクリプトの URL を表すurlプロパティ、 実行中の関数の名前を表すfunctionNameプロパティ、および 実行されたコードの行番号と列番号を表すlineNumberおよびcolumnNumber プロパティを持つ。

7.6.3.19. script.StackTrace 型

リモートエンド定義 およびローカルエンド定義

script.StackTrace = {
  callFrames: [*script.StackFrame],
}

script.StackTrace型は、スクリプト実行中のある時点における JavaScript スタックを表す。

注記: スタックフレームのリストを取得する方法、および そのリストのプロパティの詳細は十分に規定されていないため、ここでの詳細は実装定義である。

実装は、スタック フレームのリストを生成できるものと仮定される。これは、JavaScript 呼び出しスタック内の各項目に 1 つのエントリを持つリストであり、最も新しいものから始まる。 各エントリは、スクリプト script内の文または式の実行に対応する単一のスタック フレームであり、次のフィールドを含む:

script url
scriptを含むリソースの URL
function
実行中の関数の名前
line number
scriptを含むリソースの先頭を基準とした、 実行されたコードの 0 始まりの行番号。
column number
scriptを含むリソース内の行の開始位置を基準とした、 実行されたコードの 0 始まりの列番号。

スタックフレームのリストstackで、スタックトレースを 構築するには:

  1. call framesを新しいリストとする。

  2. stack内の各スタックフレーム frameについて、 最も最近実行されたフレームから始めて、次の手順を実行する:

    1. urlを、framescript urlURLが与えられたときにURL シリアライザーを実行した結果とする。

    2. frame infoを、 urlフィールドがurlに、 functionNameフィールドがframefunctionに、 lineNumberフィールドがframeline numberに、 columnNumberフィールドがframecolumn numberに設定された、 script.StackFrame生成規則に一致する新しいマップとする。

  3. frame infocall framesに付加する。

  4. stack traceを、 callFramesプロパティがcall framesに設定された、 script.StackTrace生成規則に一致する新しいマップとする。

  5. stack traceを返す。

現在のスタック トレースは、実行中の 実行コンテキストのコールスタックを表すスタック フレームのリストが与えられたときのスタックトレースを構築する結果である。

例外、または型 throwCompletion Recordである exceptionによる例外の スタックトレースは、次により与えられる:

  1. exceptionが例外として投げられた値である場合、record を、exceptionを投げるために作成されたCompletion Recordとする。そうでなければ、 recordexceptionとする。

  2. stackを、 recordが作成された時点の実行に対応するスタックフレームのリストとする。

  3. stackが与えられたときのスタックトレースを構築する結果を返す。

7.6.3.20. script.Source 型

ローカルエンド定義

script.Source = {
  realm: script.Realm,
  ? context: browsingContext.BrowsingContext,
  ? userContext: browser.UserContext
}

script.Source型は、スクリプト関連イベントが発生した script.Realmと、任意のbrowsingContext.BrowsingContextおよび関連する browser.UserContextを表す。

source realmが与えられたとき、source を取得するには:
  1. realmを、source realmrealm IDとする。

  2. environment settingsを、そのrealm 実行コンテキストの Realm component が source realmである環境設定オブジェクトとする。

  3. environment settings関連付けられたDocumentを持つ場合:

    1. documentを、environment settings の関連付けられたDocumentとする。

    2. navigableを、documentnode navigableとする。

    3. navigableが null でない場合、navigable idnavigablenavigable IDとする。

    4. user context idを、navigable関連付けられたユーザーコンテキストユーザーコンテキスト IDとする。

    そうでなければ、navigableを null とする。

  4. sourceを、 realmフィールドがrealmに設定され、contextフィールドが navigableが null でなければnavigable idに設定され、そうでなければ未設定であり、 userContextフィールドが |navigable が null でなければuser context idに設定され、そうでなければ未設定である、 script.Source生成規則に一致するマップとする。

  5. sourceを返す。

7.6.3.21. script.Target 型

リモートエンド定義

script.RealmTarget = {
  realm: script.Realm
}

script.ContextTarget = {
  context: browsingContext.BrowsingContext,
  ? sandbox: text
}

script.Target = (
  script.ContextTarget /
  script.RealmTarget
)

script.Target型は、 script.RealmまたはbrowsingContext.BrowsingContextのいずれかである値を表す。 これは、navigable 識別子が、その navigable のアクティブ文書に関連付けられた realm の代わりになる場合に有用である。

navigable idおよびsandboxが与えられたとき、navigable から realm を取得するには:
  1. navigableを、navigable id試行してnavigable を取得する 結果とする。

  2. sandboxが null または空文字列である場合:

    1. documentを、navigableアクティブ文書とする。

    2. environment settingsを、その関連大域オブジェクト関連付けられたDocumentdocumentである環境設定オブジェクトとする。

    3. realmを、environment settingsrealm 実行コンテキストの Realm component とする。

  3. そうでなければ、realmを、 sandboxおよび navigableが与えられたときの試行して sandbox realm を取得または作成する結果とする。

  4. 成功をデータrealmとともに返す

これは誤った エラーコードを持つ

targetが与えられたとき、target から realm を取得するには:
  1. targetscript.ContextTarget生成規則に一致する場合:

    1. sandboxを null とする。

    2. targetが "sandbox" を含む場合、 sandboxtarget["sandbox"]に設定する。

    3. realmを、 target["context"]およびsandboxnavigable から realm を取得する結果とする。

  2. そうでなければ:

    1. 表明:targetscript.RealmTarget 生成規則に一致する。

    2. realm idを、 targetrealmフィールドの値とする。

    3. realmを、realm idが与えられたときのrealm を取得する結果とする。

  3. 成功をデータrealmとともに返す

これは誤った エラーコードを持つ

7.6.4. コマンド

7.6.4.1. script.addPreloadScript コマンド

script.addPreloadScriptコマンドは、プリロードスクリプトを追加する。

コマンド型
script.AddPreloadScript = (
  method: "script.addPreloadScript",
  params: script.AddPreloadScriptParameters
)

script.AddPreloadScriptParameters = {
  functionDeclaration: text,
  ? arguments: [*script.ChannelValue],
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
  ? sandbox: text
}
戻り値型
script.AddPreloadScriptResult = {
  script: script.PreloadScript
}
session および command parameters が与えられた リモートエンド手順は次の通りである:
  1. command parameters が "userContexts" を含み、 かつ command parameters が "contexts" を含む場合、 エラーエラー コード invalid argument で返す。

  2. function declarationcommand parametersfunctionDeclaration フィールドとする。

  3. arguments を、存在する場合は command parametersarguments フィールドとし、それ以外の場合は空のリストとする。

  4. user contexts集合とする。

  5. navigables を null とする。

  6. command parameterscontexts フィールドが存在する場合:

    1. navigables を空の集合に設定する。

    2. command parameters["contexts"] の各 navigable id について

      1. navigable を、navigable id を用いて navigable を取得することを試行する結果とする。

      2. navigableトップレベルトラバーサブルでない場合、エラーエラーコード invalid argument で返す。

      3. navigablenavigables に付加する。

  7. それ以外で、command parametersuserContexts含む場合:

    1. user contexts を、command parameters["userContexts"] を用いて 集合を 作成する結果に設定する。

    2. user contexts の各 user context id について:

      1. user context を、user context id を用いて ユーザーコンテキストを取得する結果に設定する。

      2. user context が null である場合、エラーエラーコード no such user context で返す。

  8. sandbox を、存在する場合は command parameters 内の "sandbox" フィールドの値とし、それ以外の場合は null とする。

  9. scriptUUID の文字列表現とする。

  10. preload script mapsessionpreload script mapとする。

  11. preload script map[script] を、 function declaration function declarationarguments argumentscontexts navigablessandbox sandbox、および user contexts user contexts を持つ構造体に設定する。

  12. script フィールドが script に設定された script.AddPreloadScriptResult に一致する新しいマップを返す。

7.6.4.2. script.disown コマンド

script.disownコマンドは、与えられたハンドルの所有を放棄する。 これは、他のハンドルや強い ECMAScript 参照が存在し得るため、 ハンドルされたオブジェクトがガベージコレクトされることを保証しない。

コマンド型
script.Disown = (
  method: "script.disown",
  params: script.DisownParameters
)

script.DisownParameters = {
  handles: [*script.Handle]
  target: script.Target;
}
戻り値型
script.DisownResult = EmptyResult
command parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. realmを、command parameterstargetフィールドの値が与えられたときの試行してtarget から realm を取得する 結果とする。

  2. handlesを、command parametershandlesフィールドの値とする。

  3. handlesの各handle idについて:

    1. handle mapを、realmハンドルオブジェクトマップとする

    2. handle maphandle idを含む場合、handle idhandle mapから除去する。

  4. 成功をデータ null とともに返す。

7.6.4.3. script.callFunction コマンド

script.callFunctionコマンドは、与えられた realm 内で、 提供された関数を与えられた引数で呼び出す。

RealmInfoは realm または navigable のいずれかであり得る。

注記: functionDeclaration内のアロー関数の場合、 this引数は関数のthis束縛に影響しない。

コマンド型
script.CallFunction = (
  method: "script.callFunction",
  params: script.CallFunctionParameters
)

script.CallFunctionParameters = {
  functionDeclaration: text,
  awaitPromise: bool,
  target: script.Target,
  ? arguments: [*script.LocalValue],
  ? resultOwnership: script.ResultOwnership,
  ? serializationOptions: script.SerializationOptions,
  ? this: script.LocalValue,
  ? userActivation: bool .default false,
}
戻り値型
script.CallFunctionResult = script.EvaluateResult

TODO: script.evaluate で説明されているように、 timeout 引数を追加する。

realmserialized arguments list およびsessionが与えられたとき、引数を 逆直列化するには:

  1. deserialized arguments listを空のリストとする。

  2. serialized arguments listの各serialized argumentについて:

    1. deserialized argumentを、 serialized argumentrealmおよびsessionが与えられたときの試行して ローカル値を逆直列化する 結果とする。

    2. deserialized argumentdeserialized arguments listに付加する。

  3. 成功をデータdeserialized arguments listとともに返す。

function declarationenvironment settingsbase URL、およびoptionsが与えられたとき、関数 本体を評価するには:

注記: function declarationは 括弧で囲まれ、評価される。

  1. bypassDisabledScriptingを true とする。

  2. parenthesized function declarationを、 «"(", function declaration, ")"»を連結する結果とする

  3. function scriptを、 parenthesized function declarationenvironment settingsbase URLoptionsおよびbypassDisabledScripting古典スクリプトを作成する結果とする。

  4. environment settingsスクリプトを実行する準備をする

  5. function body evaluation statusを、 ScriptEvaluation(function scriptの record)とする。

  6. environment settingsスクリプト実行後の後始末をする

  7. function body evaluation statusを返す。

sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:

  1. realmを、command parameterstargetフィールドの値が与えられたときの試行してtarget から realm を取得する 結果とする。

  2. realm idを、realmrealm IDとする。

  3. environment settingsを、そのrealm 実行コンテキストの Realm component が realmである環境設定オブジェクトとする。

  4. command argumentsを、command parametersargumentsフィールドの値とする。

  5. deserialized argumentsを空のリストとする。

  6. command argumentsが null でない場合、deserialized argumentsを、 realmcommand argumentsおよびsessionが与えられたときの試行して 引数を逆直列化する結果に設定する。

  7. this parameterを、command parametersthisフィールドの値とする。

  8. this objectを null とする。

  9. this parameterが null でない場合、this objectを、 this parameterrealmおよびsessionが与えられたときの試行して ローカル値を逆直列化する結果に設定する。

  10. function declarationを、command parametersfunctionDeclarationフィールドの値とする。

  11. await promiseを、 command parametersawaitPromiseフィールドの値とする。

  12. serialization optionsを、存在する場合はcommand parametersserializationOptionsフィールドの値、そうでなければ 各フィールドが既定値に設定されたscript.SerializationOptions 生成規則に一致するマップとする。

  13. result ownershipを、存在する場合はcommand parametersresultOwnershipフィールドの値、 そうでなければnoneとする。

  14. base URLを、environment settingsAPI 基底 URLとする。

  15. options既定のスクリプトフェッチオプションとする。

  16. function body evaluation statusを、 function declarationenvironment settingsbase URL、およびoptions関数本体を評価する結果とする。

  17. function body evaluation status.[[Type]]がthrowである場合:

    1. exception detailsを、 realmfunction body evaluation statusresult ownershipおよびsessionが与えられたときの例外の 詳細を取得する結果とする。

    2. exceptionDetailsフィールドが exception detailsに設定された、 script.EvaluateResultException 生成規則に一致する新しいマップを返す。

  18. function objectを、function body evaluation status.[[Value]]とする。

  19. IsCallable(function object)が falseである場合:

    1. エラーエラーコード invalid argumentで返す

  20. command parameters["userActivation"]が true である場合、activation notification手順を実行する。

  21. environment settingsスクリプトを実行する準備をする

  22. evaluation statusを、 Call(function object, this object, deserialized arguments)に設定する。

  23. evaluation status.[[Type]]がnormalであり、かつawait promisetrueであり、かつIsPromise(evaluation status.[[Value]])である場合:

    1. evaluation statusAwait(evaluation status.[[Value]])に設定する。

  24. environment settingsスクリプト実行後の後始末をする

  25. evaluation status.[[Type]]がthrowである場合:

    1. exception detailsを、 realmevaluation statusresult ownershipおよび sessionが与えられたときの例外の 詳細を取得する結果とする。

    2. exceptionDetailsフィールドが exception detailsに設定された、 script.EvaluateResultException 生成規則に一致する新しいマップを返す。

  26. 表明:evaluation status.[[Type]]はnormalである。

  27. resultを、 evaluation status.[[Value]]、serialization optionsresult ownership、 直列化内部マップとしての新しいマップrealmおよび sessionリモート値として 直列化する結果とする。

  28. realmフィールドがrealm idに設定され、 かつresultフィールドがresultに設定された、 script.EvaluateResultSuccess 生成規則に一致する新しいマップを返す。

7.6.4.4. script.evaluate コマンド

script.evaluate コマンドは、与えられた realm 内で提供された script を evaluate する。便宜上、realm の代わりに navigable を提供でき、 その場合に使用される realm は browsing context の active document の realm である。

この method は、提供された script を実行した値を返す。ただし、それが promise を返し、awaitPromise が true である場合は、その promise の resolved value が 返される。

コマンド型
script.Evaluate = (
  method: "script.evaluate",
  params: script.EvaluateParameters
)

script.EvaluateParameters = {
  expression: text,
  target: script.Target,
  awaitPromise: bool,
  ? resultOwnership: script.ResultOwnership,
  ? serializationOptions: script.SerializationOptions,
  ? userActivation: bool .default false,
}
返却型
script.EvaluateResult

TODO: timeout argument を追加する。これがどのように機能すべきかは完全には明確でない。 Chrome では timeout は promise resolve step には適用されないように見えるが、 それはおそらく clients が望むものではない。

sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:

  1. realmを、command parameterstargetフィールドの値が与えられたときの試行してtarget から realm を取得する 結果とする。

  2. realm idを、realmrealm IDとする。

  3. environment settingsを、そのrealm 実行コンテキストの Realm component が realmである環境設定オブジェクトとする。

  4. sourceを、command parametersexpressionフィールドの値とする。

  5. await promiseを、 command parametersawaitPromiseフィールドの値とする。

  6. serialization optionsを、存在する場合はcommand parametersserializationOptionsフィールドの値、そうでなければ 各フィールドが既定値に設定されたscript.SerializationOptions 生成規則に一致するマップとする。

  7. result ownershipを、存在する場合はcommand parametersresultOwnershipフィールドの値、 そうでなければnoneとする。

  8. options既定のスクリプトフェッチオプションとする。

  9. base URLを、environment settingsAPI 基底 URLとする。

  10. bypassDisabledScriptingを true とする。

  11. scriptを、sourceenvironment settingsbase URLoptionsおよび bypassDisabledScripting古典スクリプトを作成する結果とする。

  12. command parameters["userActivation"]が true である場合、activation notification手順を実行する。

  13. environment settingsスクリプトを実行する準備をする

  14. evaluation statusScriptEvaluation(scriptの record)に設定する。

  15. evaluation status.[[Type]]がnormalであり、await promiseが true であり、かつIsPromise(evaluation status.[[Value]])である場合:

    1. evaluation statusAwait(evaluation status.[[Value]])に設定する。

  16. environment settingsスクリプト実行後の後始末をする

  17. evaluation status.[[Type]]がthrowである場合:

    1. exception detailsを、 realmevaluation statusresult ownershipおよび session例外の 詳細を取得する結果とする。

    2. realmフィールドがrealm idに設定され、 exceptionDetailsフィールドがexception detailsに設定された、 script.EvaluateResultException 生成規則に一致する新しいマップを返す。

  18. 表明:evaluation status.[[Type]]はnormalである。

  19. resultを、 evaluation status.[[Value]]、serialization optionsresult ownership、 直列化内部マップとしての新しいマップrealmおよび sessionリモート値として 直列化する結果とする。

  20. realmフィールドがrealm idに設定され、 かつresultフィールドがresultに設定された、 script.EvaluateResultSuccess 生成規則に一致する新しいマップを返す。

7.6.4.5. script.getRealms コマンド

script.getRealmsコマンドは、 すべての realm のリストを返す。任意で、特定の型のrealm、またはnavigableアクティブ文書に関連付けられた realm に絞り込める。

コマンド型
script.GetRealms = (
  method: "script.getRealms",
  params: script.GetRealmsParameters
)

script.GetRealmsParameters = {
  ? context: browsingContext.BrowsingContext,
  ? type: script.RealmType,
}
戻り値型
script.GetRealmsResult = {
  realms: [*script.RealmInfo]
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. environment settingsを、リストとする。これは、 実行準備完了フラグが設定されている、すべての環境設定オブジェクトのリストである。

  2. command parameterscontextを含む場合:

    1. navigableを、 command parameters["context"]で試行して navigable を取得する 結果とする。

    2. documentを、navigableアクティブ文書とする。

    3. navigable environment settingsリストとする。

    4. environment settingsの各settingsについて:

      1. 次の条件のいずれかが満たされる場合:

        settingsnavigable environment settingsに付加する。

    5. environment settingsnavigable environment settingsに設定する。

  3. realmsをリストとする。

  4. environment settingsの各settingsについて:

    1. realm infoを、settingsが与えられたときのrealm info を取得する 結果とする。

    2. command parameterstypeを含み、かつrealm info["type"]がcommand parameters["type"]と等しくない場合、続行する

    3. realm infoが null でない場合、realm inforealmsに付加する。

  5. bodyを、realmsフィールドがrealmsに設定された、 script.GetRealmsResult生成規則に一致するマップ とする。

  6. 成功をデータbodyとともに返す。

これを拡張して、 ネストされた worker などのために realm の親も許可するか? またはすべての祖先 worker を取得するか?

単なる リテラル一致よりも高度なフィルターシステムが必要かもしれない。

7.6.4.6. script.removePreloadScript コマンド

script.removePreloadScriptコマンドは、 プリロードスクリプトを除去する。

コマンド型
script.RemovePreloadScript = (
  method: "script.removePreloadScript",
  params: script.RemovePreloadScriptParameters
)

script.RemovePreloadScriptParameters = {
  script: script.PreloadScript
}
戻り値型
script.RemovePreloadScriptResult = EmptyResult
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. scriptを、command parameters内の"script"フィールドの値とする。

  2. preload script mapを、sessionプリロードスクリプトマップとする。

  3. preload script mapscript含まない 場合、 エラーエラー コード no such scriptで返す。

  4. scriptpreload script mapから除去する

  5. null を返す

7.6.5. イベント

7.6.5.1. script.message イベント
イベント型
script.Message = (
  method: "script.message",
  params: script.MessageParameters
 )

script.MessageParameters = {
  channel: script.Channel,
  data: script.RemoteValue,
  source: script.Source,
}
リモートエンドイベントトリガーは、sessionrealmchannel propertiesおよびmessageが与えられたときの、script message を発火する手順である:
  1. environment settingsを、そのrealm 実行コンテキストの Realm component が realmである環境設定オブジェクトとする。

  2. related navigablesを、environment settingsが与えられたときの関連 navigable を取得する結果とする。

  3. session、"script.message" およびrelated navigablesが与えられてイベントが 有効である場合:

    1. channel propertiesが "serializationOptions"を含む場合、serialization optionschannel propertiesserializationOptionsフィールドの値とする。 そうでなければ、serialization optionsを、各フィールドが既定値に設定された script.SerializationOptions生成規則に一致するマップとする。

    2. channel propertiesが "ownership" を含む場合、ownership typechannel properties["ownership"]とする。 そうでなければ、 ownership typeを "none" とする。

    3. dataを、messageserialization optionsownership type、 直列化内部マップとしての新しい マップおよびrealmが与えられたときのリモート値として直列化する結果とする。

    4. sourceを、realmsource を取得する結果とする。

    5. paramsを、 channelフィールドがchannel properties["channel"]に、 dataフィールドがdataに、source フィールドがsourceに設定された、 script.MessageParameters生成規則に一致するマップとする。

    6. bodyを、paramsフィールドがparamsに設定された script.Message生成規則に一致するマップとする。

    7. sessionおよびbodyイベントを 発火する

7.6.5.2. script.realmCreated イベント
イベント型
script.RealmCreated = (
 method: "script.realmCreated",
 params: script.RealmInfo
)
リモートエンドイベントトリガーは次である:

window 環境設定オブジェクトを設定するworker 環境設定オブジェクトを設定する、またはworklet 環境設定オブジェクトを設定する アルゴリズムのいずれかが呼び出されたとき、settings object を返す直前に:

  1. environment settingsを、新しく作成された環境設定オブジェクトとする。

  2. realm infoを、environment settingsが与えられたときのrealm info を取得する結果とする。

  3. realm infoが null である場合、返す。

  4. related navigablesを、environment settingsが与えられたときの関連 navigable を取得する結果とする。

  5. bodyを、paramsフィールドがrealm infoに設定された、 script.RealmCreated 生成規則に一致するマップ とする。

  6. "script.realmCreated"およびrelated navigablesが与えられたときの、 イベントが有効であるセッションの集合 内の各sessionについて:

    1. sessionおよびbodyイベントを 発火する

リモートエンド購読手順は、購読優先度 2 で、sessionnavigables およびinclude globalが与えられたとき、次のとおりである:

  1. environment settingsを、実行準備完了フラグが設定されている、 すべての環境設定オブジェクトのリストとする。

  2. environment settingsの各settingsについて:

    1. related navigablesを新しい集合とする。

    2. settings関連大域オブジェクト関連付けられたDocumentDocumentである場合:

      1. navigableを、settings関連大域オブジェクト関連付けられた Documentnode navigableとする。

      2. navigableが null である場合、続行する。

      3. top-level traversibleを、navigableトップレベル辿可能とする。

      4. top-level traversiblenavigables内にない場合、続行する。

      5. top-level traversiblerelated navigablesに付加する。

      そうでなければ、include globalが false である場合、続行する。

    3. realm infoを、settingsが与えられたときのrealm info を取得する 結果とする。

    4. realm infoが null である場合、続行する。

    5. bodyを、paramsフィールドがrealm infoに設定された script.RealmCreated 生成規則に一致するマップとする。

    6. session、 "script.realmCreated"およびrelated navigablesが与えられてイベントが 有効である場合:

      1. sessionおよびbodyイベントを 発火する

ここでの順序は より厳密に定義されるべきか?

7.6.5.3. script.realmDestroyed イベント
イベント型
script.RealmDestroyed = (
  method: "script.realmDestroyed",
  params: script.RealmDestroyedParameters
)

script.RealmDestroyedParameters = {
  realm: script.Realm
}

リモートエンドイベントトリガーは次である:
documentで、次のunloading document cleanup stepsを定義する:
  1. related navigablesを空の集合とする。

  2. documentnavigablerelated navigablesに付加する。

  3. documentworklet global scopes内の各worklet global scopeについて:

    1. realmを、worklet global scope関連 Realmとする。

    2. realm idを、realmrealm IDとする。

    3. paramsを、 realmフィールドがrealm idに設定された、 script.RealmDestroyedParameters 生成規則に一致するマップとする。

    4. bodyを、paramsフィールドがparamsに設定された script.RealmDestroyed 生成規則に一致するマップとする。

    5. "script.realmDestroyed"およびrelated navigablesが与えられたときの、 イベントが有効であるセッションの集合 内の各sessionについて:

      1. sessionおよびbodyイベントを 発火する

  4. environment settingsを、その関連大域オブジェクト関連付けられたDocumentdocumentである環境設定オブジェクトとする。

  5. realmを、environment settingsrealm 実行コンテキストの Realm component とする。

  6. realm idを、realmrealm IDとする。

  7. paramsを、 realmフィールドがrealm idに設定された、 script.RealmDestroyedParameters生成規則に一致するマップ とする。

  8. bodyを、paramsフィールドがparamsに設定された script.RealmDestroyed 生成規則に一致するマップ とする。

  9. "script.realmDestroyed"およびrelated navigablesが与えられたときの、 イベントが有効であるセッションの集合 内の各sessionについて:

    1. sessionおよびbodyイベントを 発火する

worker イベントループevent loopが破棄されるたびに、 worker がライフサイクルの終端に達したためであれ、worker を終了するアルゴリズムにより時期尚早に破棄されたためであれ:

  1. environment settingsを、event loop担当イベントループである環境設定オブジェクトとする。

  2. related navigablesを、environment settingsが与えられたときの関連 navigable を取得する結果とする。

  3. realmを、environment settings環境設定オブジェクトの Realmとする。

  4. realm idを、realmrealm IDとする。

  5. paramsを、realmフィールドがrealm idに設定された、 script.RealmDestroyedParameters 生成規則に一致するマップとする。

  6. bodyを、paramsフィールドがparamsに設定された、 script.RealmDestroyed 生成規則に一致するマップとする。

7.7. storage モジュール

storageモジュールは、ストレージに関連する機能および イベントを含む。

ストレージパーティションは、 ユーザーエージェントがCookieやローカルストレージなどの永続データを 編成できる名前空間である。

ストレージパーティション キーは、マップであり、ストレージパーティションを一意に識別する。

7.7.1. 定義

リモートエンド定義

StorageCommand = (
  storage.DeleteCookies //
  storage.GetCookies //
  storage.SetCookie
)

ローカルエンド定義

StorageResult = (
  storage.DeleteCookiesResult /
  storage.GetCookiesResult /
  storage.SetCookieResult
)

7.7.2.

7.7.2.1. storage.PartitionKey 型

ローカルエンド定義

storage.PartitionKey = {
  ? userContext: text,
  ? sourceOrigin: text,
  Extensible,
}

storage.PartitionKey型は、ストレージパーティションキーを表す。

次の標準ストレージパーティションキー属性の表は、 よく知られた意味を持つ属性を列挙し、リモートエンドが サポートすることを選択できる。実装は追加の拡張ストレージパーティションキー属性を定義してもよい。

属性 定義
"userContext" ユーザーコンテキスト ID
"sourceOrigin" ストレージパーティションにアクセスできるリソースのorigin の直列化

リモートエンドは任意の数の拡張ストレージパーティションキー 属性をサポートしてもよい。他の実装との衝突を避けるため、これらの 属性は、ベンダーおよびユーザーエージェントの一意な識別子で始まり、 U+003A (:) が続かなければならない。

リモートエンドは、0 個以上のエントリを含むストレージパーティション キー属性の既定値マップを持つ。 各キーは、ストレージパーティション キーが標準ストレージパーティションに対応する場合は標準ストレージパーティションキー 属性の表のメンバーでなければならず、そうでない場合は 拡張ストレージパーティションキー属性 でなければならない。また値は、ユーザーが明示的な値を提供しないときに使用される そのパーティションキーの既定値を表す。正確なエントリは実装定義であり、 実装が採用するストレージパーティショニングにより決定される。

リモートエンドは、0 個以上のエントリを含む必須パーティションキー 属性リストを持つ。各キーは、 ストレージパーティション キーが標準ストレージパーティションに対応する場合は標準ストレージパーティションキー 属性の表のメンバーでなければならず、そうでない場合は 拡張ストレージパーティションキー属性 でなければならない。正確なエントリは実装定義であり、実装が採用するストレージ パーティショニングにより決定される。このリストは、既定値が利用できないパーティション キーのみを含む。したがって、このリストはストレージパーティション キー属性の既定値のキーといかなるエントリも共有してはならない。

filterが与えられたとき、filter を 逆直列化するには:
  1. deserialized filterを空のマップとする。

  2. filter内の各namevalueについて:

    1. deserialized nameを、Cookie 変換の表内の JSON キー nameに対応するフィールド名とする。

    2. nameが "value" である場合、deserialized valuevalueプロトコルバイトを逆直列化する結果に設定し、 そうでなければdeserialized valuevalueとする。

    3. deserialized filter[deserialized name]をdeserialized value設定する

  3. deserialized filterを返す。

partition spec が与えられたときに ストレージ パーティション仕様を展開するには:
  1. partition spec が null である場合:

    1. partition spec を空のマップに設定する。

  2. それ以外で、partition spec["type"] が "context" である場合:

    1. navigable を、partition spec["context"] が与えられた navigable を取得することを試行する結果とする。

    2. partition key を、navigable関連付けられたストレージパーティションキーとする。

    3. データ partition key成功を返す。

  3. partition key を空のマップとする。

  4. ストレージ パーティションキー属性のデフォルト値内の各 namedefault value について:

    1. value を、partition spec[name] が存在する場合はそれとし、それ以外の場合は default value とする。

    2. partition key[name] を value設定する

  5. リモートエンドの必須パーティションキー属性内の各 name について:

    1. partition spec[name] が存在する場合:

      1. partition key][name] を partition spec[name] に設定する

    2. それ以外の場合:

      1. エラーエラーコード underspecified storage partition で返す。

  6. データ partition key成功を返す。

storage partition keyが与えられたとき、Cookie ストアを取得するには:
  1. storage partition keyが既存のストレージパーティションを一意に識別する場合:

    1. storeを、そのストレージパーティションCookie ストアとする。

    2. 成功をデータstoreとともに返す。

  2. エラーエラー コード no such storage partitionで返す。

stored cookieおよびfilterが与えられたとき、Cookie と照合するには:
  1. filter内の各namevalueについて:

    1. stored cookie[name]がvalueと等しくない場合:

      1. false を返す。

  2. true を返す。

cookie storeおよびfilterが与えられたとき、照合する Cookie を取得するには:
  1. cookiesを新しいリストとする。

  2. deserialized filterを、filterfilter を逆直列化する結果に設定する。

  3. cookie store内の各stored cookieについて:

    1. stored cookieおよびdeserialized filterCookie と照合する結果が true である場合:

      1. stored cookiecookiesに付加する。

  4. cookiesを返す。

7.7.3. コマンド

7.7.3.1. storage.getCookies コマンド

storage.getCookiesコマンドは、提供された一連のパラメーターと一致する 0 個以上のCookieを 取得する。

コマンド型
storage.GetCookies = (
  method: "storage.getCookies",
  params: storage.GetCookiesParameters
)


storage.CookieFilter = {
  ? name: text,
  ? value: network.BytesValue,
  ? domain: text,
  ? path: text,
  ? size: js-uint,
  ? httpOnly: bool,
  ? secure: bool,
  ? sameSite: network.SameSite,
  ? expiry: js-uint,
  Extensible,
}

storage.BrowsingContextPartitionDescriptor = {
  type: "context",
  context: browsingContext.BrowsingContext
}

storage.StorageKeyPartitionDescriptor = {
  type: "storageKey",
  ? userContext: text,
  ? sourceOrigin: text,
  Extensible,
}

storage.PartitionDescriptor = (
  storage.BrowsingContextPartitionDescriptor /
  storage.StorageKeyPartitionDescriptor
)

storage.GetCookiesParameters = {
  ? filter: storage.CookieFilter,
  ? partition: storage.PartitionDescriptor,
}
戻り値型
storage.GetCookiesResult = {
  cookies: [*network.Cookie],
  partitionKey: storage.PartitionKey,
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. filterを、存在する場合はcommand parametersfilterフィールドの値、 そうでなければ空のマップとする。

  2. partition specを、存在する場合は command parameterspartitionフィールドの値、 そうでなければ null とする。

  3. partition keyを、 partition spec試行してストレージパーティション仕様を展開する結果とする。

  4. storeを、 partition key試行してCookie ストアを取得する結果とする。

  5. cookiesを、storeおよび filter照合する Cookie を取得する結果とする。

  6. serialized cookiesを新しいリストとする。

  7. cookies内の各cookieについて:

    1. serialized cookieを、 cookieが与えられたときのCookie を直列化する結果とする。

    2. serialized cookieserialized cookiesに付加する。

  8. bodyを、cookiesフィールドがserialized cookiesに、 partitionKey フィールドがpartition keyに設定された、 storage.GetCookiesResult生成規則に一致するマップとする。

  9. 成功をデータbodyとともに返す。

7.7.3.2. storage.setCookie コマンド

storage.setCookieコマンドは、Cookie ストア内に新しいCookieを作成し、 [COOKIES]に従って一致する そのストア内の任意の Cookie を置き換える。

コマンド型
storage.SetCookie = (
  method: "storage.setCookie",
  params: storage.SetCookieParameters,
)


storage.PartialCookie = {
  name: text,
  value: network.BytesValue,
  domain: text,
  ? path: text,
  ? httpOnly: bool,
  ? secure: bool,
  ? sameSite: network.SameSite,
  ? expiry: js-uint,
  Extensible,
}

storage.SetCookieParameters = {
  cookie: storage.PartialCookie,
  ? partition: storage.PartitionDescriptor,
}
戻り値型
storage.SetCookieResult = {
  partitionKey: storage.PartitionKey
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. cookie specを、command parameterscookieフィールドの値とする。

  2. partition specを、存在する場合は command parameterspartitionフィールドの値、 そうでなければ null とする。

  3. partition keyを、 partition spec試行してストレージパーティション仕様を展開する結果とする。

  4. storeを、 partition key試行してCookie ストアを取得する結果とする。

  5. deserialized valueを、 cookie spec["value"]でプロトコルバイトを逆直列化する結果とする。

  6. store内に、Cookie 名 cookie spec["name"]、 Cookie 値 deserialized valueCookie ドメイン cookie spec["domain"]、および Cookie 変換の表に列挙された次の Cookie 概念の属性値リストを使用して、Cookie を作成する

    Cookie パス

    存在する場合はcookie spec["path"]、そうでなければ "/"。

    Cookie secure only

    存在する場合はcookie spec["secure"]、そうでなければ false。

    Cookie HTTP only

    存在する場合はcookie spec["httpOnly"]、そうでなければ false。

    Cookie 有効期限時刻

    存在する場合はcookie spec["expiry"]、そうでなければ これがセッション Cookie であることを示すため未設定のままにする。

    注記: Cookie の expiry 値は、 Cookie Lifetime Limitsに従って、 リモートエンドにより制限されることがある。

    Cookie same site

    存在する場合はcookie spec["sameSite"]、そうでなければ same site ポリシーが定義されていないことを示すため未設定のままにする。

    この手順が Cookie を Cookie ストアに挿入せずに中止された場合、 エラーエラー コード unable to set cookieで返す。

  7. bodyを、partitionKeyフィールドがpartition keyに設定された storage.SetCookieResult生成規則に一致するマップとする。

  8. 成功をデータbodyとともに返す。

7.7.3.3. storage.deleteCookies コマンド

storage.deleteCookiesコマンドは、提供された一連の パラメーターと一致する 0 個以上のCookieを除去する。

コマンド型
storage.DeleteCookies = (
  method: "storage.deleteCookies",
  params: storage.DeleteCookiesParameters,
)

storage.DeleteCookiesParameters = {
  ? filter: storage.CookieFilter,
  ? partition: storage.PartitionDescriptor,
}
戻り値型
storage.DeleteCookiesResult = {
  partitionKey: storage.PartitionKey
}
sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. filterを、存在する場合はcommand parametersfilterフィールドの値、 そうでなければ空のマップとする。

  2. partition specを、存在する場合は command parameterspartitionフィールドの値、 そうでなければ null とする。

  3. partition keyを、 partition spec試行してストレージパーティション仕様を展開する結果とする。

  4. storeを、 partition key試行してCookie ストアを取得する結果とする。

  5. cookiesを、storeおよび filter照合する Cookie を取得する結果とする。

  6. cookies内の各cookieについて:

    1. cookiestoreから除去する。

  7. bodyを、partitionKeyフィールドがpartition keyに設定された storage.DeleteCookiesResult生成規則に一致するマップとする。

  8. 成功をデータbodyとともに返す。

7.8. log モジュール

logモジュールは、ログ記録に関連する機能およびイベントを含む。

BiDi セッションは、ログイベントバッファを持つ。これは、 navigable IDから、そのコンテキストでまだ 発火されていないログイベントのリストへのマップである。ユーザーエージェントは、このバッファに最大サイズを課してもよい。ただし、 イベント A と B が同じコンテキスト内で発生し、A が B より前に発生し、かつ両方がバッファに追加された場合、 B のエントリは A のエントリより先に除去されてはならないという条件に従う。

sessionnavigablesおよびeventが与えられたとき、ログイベントを バッファするには:

  1. bufferを、sessionログイベントバッファとする。

  2. navigable idsを新しいリストとする。

  3. navigablesの各navigableについて:

    1. navigablenavigable IDnavigable idsに付加する。

  4. navigable ids内の各navigable idについて:

    1. other navigablesを空のリストとする

    2. navigable ids内の各other idについて:

    3. other idnavigable idと等しくない場合、other idother navigablesに付加する。

    4. buffernavigable idを含まない場合、 buffer[navigable id]を新しいリストとする。

    5. (event, other navigables)を buffer[navigable id]に付加する。

注記: 各イベントが 1 回だけ発火されるようにするため、 ここで他の navigable を保存する。実際には、これは複数の navigable と関連付けられ得る worker にのみ関係する。

これを browsing context またはトップレベル辿可能のどちらに キー付けするべきか? 違いは、イベントがフレーム内で発生し、その後ローカルエンドがトップレベル navigable のログイベントを購読する前に そのフレームがナビゲートされた場合に何が起こるかにある。

7.8.1. 定義

ローカルエンド定義

LogEvent = (
  log.EntryAdded
)

7.8.2.

7.8.2.1. log.LogEntry

ローカルエンド定義

log.Level = "debug" / "info" / "warn" / "error"

log.Entry = (
  log.GenericLogEntry /
  log.ConsoleLogEntry /
  log.JavascriptLogEntry
)

log.BaseLogEntry = (
  level: log.Level,
  source: script.Source,
  text: text / null,
  timestamp: js-uint,
  ? stackTrace: script.StackTrace,
)

log.GenericLogEntry = {
  log.BaseLogEntry,
  type: text,
}

log.ConsoleLogEntry = {
  log.BaseLogEntry,
  type: "console",
  method: text,
  args: [*script.RemoteValue],
}

log.JavascriptLogEntry = {
  log.BaseLogEntry,
  type: "javascript",
}

各ログイベントはlog.Entryオブジェクトにより表される。これは、 追加されたログエントリの型を表すtypeプロパティ、重大度を表す levelプロパティ、ログエントリの発生源を表すsource プロパティ、ログメッセージ文字列そのものを持つtextプロパティ、および ログエントリが生成された時刻に対応するtimestampプロパティを持つ。 log.Entryの特定の変種は、異なる発生源からのログを表すために使用され、 エントリ型に固有の追加フィールドを提供する。

7.8.3. イベント

7.8.3.1. log.entryAdded イベント
イベント型
log.EntryAdded = (
 method: "log.entryAdded",
 params: log.Entry,
)

リモートエンドイベントトリガーは次である:

methodargsおよび optionsで、次のconsole 手順を定義する:

  1. アクティブ BiDi セッション内の各sessionについて:

    1. methodが "error" または "assert" である場合、 levelを "error" とする。methodが "debug" または "trace" である場合、levelを "debug" とする。methodが "warn" である場合、 levelを "warn" とする。そうでなければ、levelを "info" とする。

    2. timestampを、現在の日付と時刻を UTC で表す時刻値とする。

    3. textを空文字列とする。

    4. Type(args[0])が String であり、かつargs[0]が書式指定子を含む場合、 formatted argsFormatter(args)とする。そうでなければ、 formatted argsargsとする。

      注記: formatter 演算は console 仕様で十分に定義されておらず、 書式化は異なる実装間で一貫しないことがある。

    5. formatted args内の各argについて:

      1. argargs内の最初のエントリでない場合、U+0020 SPACE をtextに付加する。

      2. argプリミティブ ECMAScript 値である場合、ToString(arg)を textに付加する。そうでなければ、実装定義の文字列を textに付加する。

    6. realmを、現在の Realm Recordrealm IDとする。

    7. serialized argsを新しいリストとする。

    8. serialization optionsを、各フィールドが既定値に設定された script.SerializationOptions生成規則に一致するマップとする。

    9. argsの各argについて:

      1. serialized argを、値としての argserialization options、所有型としてのnone、 直列化内部マップとしての新しいマップrealmおよび sessionリモート値として直列化する結果とする。

      2. serialized argserialized argsに追加する。

    10. sourceを、現在の Realm Recordが与えられたときのsource を取得する結果とする。

    11. stack現在のスタックトレースとする。

    12. entryを、levelフィールドがlevelに、 textフィールドがtextに、timestampフィールドが timestampに、stackTraceフィールドがstackに、 methodフィールドがmethodに、 sourceフィールドがsourceに、 argsフィールドがserialized argsに設定された、 log.ConsoleLogEntry生成規則に一致するマップとする。

    13. bodyを、paramsフィールドがentryに設定された log.EntryAdded 生成規則に一致するマップとする。

    14. settings現在の設定オブジェクトとする

    15. related navigablesを、settingsが与えられたときの関連 navigable を取得する結果とする。

    16. session、"log.entryAdded"および related navigablesイベントが 有効である場合、sessionおよび bodyイベントを発火する

      そうでなければ、sessionrelated browsing contextsおよびbodyログイベントをバッファする

scriptline numbercolumn numbermessageおよび handledを引数として、次のエラー報告手順を定義する:

  1. handledが true である場合、返す。

  2. settingsを、script設定オブジェクトとする。

  3. timestampを、現在の日付と時刻を UTC で表す時刻値とする。

  4. stackを、報告されているエラーに対応する例外で例外のスタックトレースとする。

  5. sourceを、現在の Realm Recordが与えられたときのsource を取得する結果とする。

  6. entryを、levelが "error" に、textmessageに、sourcesourceに、timestamptimestampに、stackTraceフィールドがstackに設定された、 log.JavascriptLogEntry生成規則に一致するマップ とする。

  7. bodyを、paramsフィールドがentryに設定された log.EntryAdded生成規則に一致するマップとする。

  8. related navigablesを、settingsが与えられたときの関連 navigable を取得する結果とする。

  9. アクティブ BiDi セッション内の各sessionについて:

    1. session、"log.entryAdded"および related navigablesイベントが 有効である場合、sessionおよび bodyイベントを発火する

      そうでなければ、sessionrelated browsing contextsおよびbodyログイベントをバッファする

ログ記録を必要とするものは さらに多数ある。CDP には LogEntryAdded 型として xml、 javascript、network、storage、appcache、rendering、security、deprecation、 worker、violation、intervention、recommendation、other がある。これらは、 異なるメソッドで表される JS 例外および Console API 型に加えて存在する。

実装定義のログ型を許可する

リモートエンド購読手順は、購読優先度 10 で、sessionnavigablesおよび include globalが与えられたとき、次のとおりである:

  1. sessionログイベントバッファ内の 各navigable ideventsについて:

    1. maybe contextを、 navigable idが与えられたときにnavigable を取得する結果とする。

    2. maybe contextエラーである場合、 navigable idログイベントバッファから除去し、続行する。

    3. navigablemaybe contextのデータとする

    4. top level navigableを、navigableトップレベル辿可能とする。

    5. include globalが true であり、かつtop level navigablenavigables内にない場合、 またはinclude globalが false であり、かつtop level navigablenavigables内にある場合:

      1. events内の各(event, other navigables)について:

        1. sessionおよびeventイベントを発火する

        2. other navigables内の各other context idについて:

          1. ログイベントバッファother context idを含む場合、eventログイベント バッファ[other context id]から除去する。

7.9. input モジュール

inputモジュールは、 シミュレートされたユーザー入力のための機能を含む。

7.9.1. 定義

リモートエンド定義

InputCommand = (
  input.PerformActions //
  input.ReleaseActions //
  input.SetFiles
)
InputResult = (
  input.PerformActionsResult /
  input.ReleaseActionsResult /
  input.SetFilesResult
)

ローカルエンド定義

InputEvent = (
  input.FileDialogOpened
)

7.9.2.

7.9.2.1. input.ElementOrigin

input.ElementOrigin型は、座標原点として使用されるElementを表す。

input.ElementOrigin = {
  type: "element",
  element: script.SharedReference
}
objectが与えられたときのis input.ElementOrigin手順は次のとおりである:
  1. objectinput.ElementOrigin 生成規則に一致するマップである場合、 true を返す。

  2. false を返す。

sessionが与えられたとき、input.ElementOriginから Element を取得する手順には:
  1. originおよびnavigableが与えられたときの、次の手順を返す:

    1. 表明:origininput.ElementOriginに一致する。

    2. documentを、navigableアクティブ文書とする。

    3. referenceorigin["element"]とする

    4. environment settingsを、その関連大域オブジェクト関連付けられたDocumentdocumentである環境設定オブジェクトとする。

    5. realmを、environment settingsrealm 実行コンテキストの Realm component とする。

    6. elementを、referencerealmおよびsession試行して リモート参照を逆直列化する 結果とする。

    7. elementElementを実装していない場合、 エラーエラーコード no such elementで返す。

    8. 成功をデータelementとともに返す。

7.9.3. コマンド

7.9.3.1. input.performActions コマンド

input.performActions コマンドは、 指定された user input actions の sequence を実行する。

注: このコマンドの動作の詳細な説明については、 actions section of [WEBDRIVER] を参照すること。

コマンド型
input.PerformActions = (
  method: "input.performActions",
  params: input.PerformActionsParameters
)

input.PerformActionsParameters = {
  context: browsingContext.BrowsingContext,
  actions: [*input.SourceActions]
}

input.SourceActions = (
  input.NoneSourceActions /
  input.KeySourceActions /
  input.PointerSourceActions /
  input.WheelSourceActions
)

input.NoneSourceActions = {
  type: "none",
  id: text,
  actions: [*input.NoneSourceAction]
}

input.NoneSourceAction = input.PauseAction

input.KeySourceActions = {
  type: "key",
  id: text,
  actions: [*input.KeySourceAction]
}

input.KeySourceAction = (
  input.PauseAction /
  input.KeyDownAction /
  input.KeyUpAction
)

input.PointerSourceActions = {
  type: "pointer",
  id: text,
  ? parameters: input.PointerParameters,
  actions: [*input.PointerSourceAction]
}

input.PointerType = "mouse" / "pen" / "touch"

input.PointerParameters = {
  ? pointerType: input.PointerType .default "mouse"
}

input.PointerSourceAction = (
  input.PauseAction /
  input.PointerDownAction /
  input.PointerUpAction /
  input.PointerMoveAction
)

input.WheelSourceActions = {
  type: "wheel",
  id: text,
  actions: [*input.WheelSourceAction]
}

input.WheelSourceAction = (
  input.PauseAction /
  input.WheelScrollAction
)

input.PauseAction = {
  type: "pause",
  ? duration: js-uint
}

input.KeyDownAction = {
  type: "keyDown",
  value: text
}

input.KeyUpAction = {
  type: "keyUp",
  value: text
}

input.PointerUpAction = {
  type: "pointerUp",
  button: js-uint,
}

input.PointerDownAction = {
  type: "pointerDown",
  button: js-uint,
  input.PointerCommonProperties
}

input.PointerMoveAction = {
  type: "pointerMove",
  x: float,
  y: float,
  ? duration: js-uint,
  ? origin: input.Origin,
  input.PointerCommonProperties
}

input.WheelScrollAction = {
  type: "scroll",
  x: js-int,
  y: js-int,
  deltaX: js-int,
  deltaY: js-int,
  ? duration: js-uint,
  ? origin: input.Origin .default "viewport",
}

input.PointerCommonProperties = (
  ? width: js-uint,
  ? height: js-uint,
  ? pressure: (0.0..1.0),
  ? tangentialPressure: (-1.0..1.0),
  ? twist: (0..359),
  ; 0 .. Math.PI / 2
  ? altitudeAngle: (0.0..1.5707963267948966),
  ; 0 .. 2 * Math.PI
  ? azimuthAngle: (0.0..6.283185307179586),
)

input.Origin = "viewport" / "pointer" / input.ElementOrigin
返却型
input.PerformActionsResult = EmptyResult

sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:

  1. navigable idを、command parameterscontextフィールドの値とする。

  2. navigableを、navigable id試行してnavigable を取得する 結果とする。

  3. input stateを、sessionおよびnavigableトップレベル辿可能入力状態を取得する結果とする。

  4. actions optionsを、is element origin手順がis input.ElementOriginに設定され、かつ get element origin手順が sessionが与えられたときのinput.ElementOrigin から Element を取得する 手順の結果に設定された、新しいactions optionsとする。

  5. actions by tickを、input statecommand parametersおよびactions optionsアクションシーケンスを抽出することを試行した結果とする。

  6. input stateactions by ticknavigableおよびactions options試行してアクションをディスパッチする

  7. 成功をデータ null とともに返す。

7.9.3.2. input.releaseActions コマンド

input.releaseActionsコマンドは、現在のセッションに関連付けられた入力 状態をリセットする。

コマンド型
input.ReleaseActions = (
  method: "input.releaseActions",
  params: input.ReleaseActionsParameters
)

input.ReleaseActionsParameters = {
  context: browsingContext.BrowsingContext,
}
戻り値型
input.ReleaseActionsResult = EmptyResult

sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:

  1. navigable idを、command parameterscontextフィールドの値とする。

  2. navigableを、navigable id試行してnavigable を取得する 結果とする。

  3. top-level traversableを、navigableトップレベル辿可能とする。

  4. input stateを、sessionおよび top-level traversable入力状態を取得する結果とする。

  5. actions optionsを、is element origin手順がis input.ElementOriginに設定され、かつ get element origin手順が、 sessionが与えられたときのinput.ElementOrigin から Element を取得する 手順に設定された、新しいactions optionsとする。

  6. undo actionsを、input stateinput cancel listを逆順にしたものとする。

  7. undo actions、0、navigableおよび actions options試行してtick アクションをディスパッチする

  8. sessionおよび top-level traversable入力状態をリセットする

  9. 成功をデータ null とともに返す。

7.9.3.3. input.setFiles コマンド

input.setFilesコマンドは、与えられた file型のinput要素のfilesプロパティを ファイルパスの集合に設定する。

コマンド型
input.SetFiles = (
  method: "input.setFiles",
  params: input.SetFilesParameters
)

input.SetFilesParameters = {
  context: browsingContext.BrowsingContext,
  element: script.SharedReference,
  files: [*text]
}
戻り値型
input.SetFilesResult = EmptyResult

sessionおよびcommand parametersが与えられたときのリモートエンド手順は次のとおりである:

  1. navigable idを、command parameters["context"]フィールドの値とする。

  2. navigableを、 navigable id試行してnavigable を取得する結果とする。

  3. documentを、navigableアクティブ文書とする。

  4. environment settingsを、その 関連大域オブジェクト関連付けられたDocumentdocumentである環境設定オブジェクトとする。

  5. realmを、environment settingsrealm 実行コンテキストの Realm component とする。

  6. elementを、command parameters["element"]、 realmおよび session試行してリモート参照を逆直列化する結果とする。

  7. elementElementを実装していない場合、 エラーエラー コード no such elementで返す。

  8. elementHTMLInputElementを実装していない場合、 elementtypeファイルアップロード状態でない場合、またはelement無効である場合、 エラーエラー コード unable to set file inputで返す。

  9. filesサイズが 1 より大きく、かつ elementmultiple 属性が設定されていない場合、エラーエラーコード unable to set file inputで返す。

  10. filesを、command parameters["files"] フィールドの値とする。

  11. selected filesを、element選択されたファイルとする。

  12. filesselected files共通部分サイズselected filesサイズと等しく、かつ filesサイズとも等しい場合、elementが与えられたとき、 ユーザー操作タスクソース上に要素タスクをキューに入れbubbles属性を true に初期化して、 elementcancelという名前のイベントを発火する。

    注記: ブラウザーにおけるキャンセルは通常、 ファイル選択の変更により判定される。言い換えれば、変更がない場合、"cancel" イベントが送信される。

  13. そうでなければ、filesをユーザーの選択として、elementファイル選択を更新する

  14. 何らかの理由で、リモートエンドがelement選択されたファイルfilesで与えられたパスのファイルに設定できない場合、 エラーエラーコード unsupported operationで返す。

    注記: 例えば、リモートエンドは、 ファイルシステム上に現在存在しないファイルを選択されたファイルに設定できないことがある。

  15. 成功をデータ null とともに返す。

7.9.4. イベント

7.9.4.1. input.fileDialogOpened イベント
イベント型
input.FileDialogOpened = (
   method: "input.fileDialogOpened",
   params: input.FileDialogInfo
)

input.FileDialogInfo = {
   context: browsingContext.BrowsingContext,
   ? userContext: browser.UserContext,
   ? element: script.SharedReference,
   multiple: bool,
}

WebDriver BiDi ファイルピッカーオプションは、multipleという名前の項目を持つ構造体であり、 これは真偽値である。

リモートエンドイベントトリガーは、 要素 elementおよび任意でWebDriver BiDi ファイルピッカーオプション file picker options(既定値:null)が与えられたときの WebDriver BiDi ファイルダイアログが開かれた手順である:

注記: 他のユーザープロンプトハンドラーとは異なり、既定の 挙動はファイルダイアログを開くことを許可する。

  1. navigableを、elementnode documentnavigableとする。

  2. navigable idを、navigablenavigable IDとする。

  3. user context idを、navigable関連付けられたユーザー コンテキストユーザー コンテキスト IDとする。

  4. multiplefalseとする。

  5. elementが null でなく、かつelementmultiple 属性が設定されている場合、 multipletrueに設定する。

  6. file picker optionsが null でなく、かつfile picker optionsmultipleが true である場合、 multipletrueに設定する。

  7. related navigablesを、navigableを含む集合とする。

  8. "input.fileDialogOpened"およびrelated navigablesが与えられたときの イベントが有効であるセッションの集合内の 各sessionについて:

    1. paramsを、contextフィールドがnavigable idに、 userContextフィールドがuser context idに、かつ multipleフィールドがmultipleに設定された input.FileDialogInfo生成規則に一致するマップとする。

    2. elementが null でない場合:

      1. shared idを、elementおよびsessionnode の shared id を取得する結果とする。

      2. params["element"]をshared idに設定する。

    3. bodyを、paramsフィールドがparamsに設定された input.fileDialogOpened 生成規則に一致するマップとする。

    4. sessionおよびbodyイベントを 発火する

  9. dismissedを false とする。

  10. アクティブ BiDi セッション内の各sessionについて:

    1. user prompt handlerを、sessionユーザープロンプトハンドラーとする。

    2. user prompt handlerが null でない場合:

    3. user prompt handlerマップであることを表明する。

    4. user prompt handlerが "file" を含む場合:

      1. user prompt handler["file"]が "ignore" と等しくない場合、dismissedを true に設定する。

    5. そうでなく、user prompt handlerが "default" を含み、かつ user prompt handler["default"]が "ignore" と等しくない場合、dismissedを true に設定する。

  11. dismissedを返す。

7.10. webExtension モジュール

webExtension モジュールは、web extensions の管理およびそれらとの interaction のための機能を含む。

7.10.1. 定義

リモートエンド定義

WebExtensionCommand = (
  webExtension.Install //
  webExtension.Uninstall
)

ローカルエンド定義

WebExtensionResult = (
  webExtension.InstallResult /
  webExtension.UninstallResult
)

7.10.2.

7.10.2.1. webExtension.Extension 型
webExtension.Extension = text

webExtension.Extension型は、リモートエンド内の Web 拡張機能 ID を表す。

7.10.3. コマンド

7.10.3.1. webExtension.install コマンド

webExtension.installコマンドは、リモートエンド内に Web 拡張機能をインストールする。

コマンド型
webExtension.Install = (
   method: "webExtension.install",
   params: webExtension.InstallParameters
)

webExtension.InstallParameters = {
   extensionData: webExtension.ExtensionData,
}

webExtension.ExtensionData = (
   webExtension.ExtensionArchivePath /
   webExtension.ExtensionBase64Encoded /
   webExtension.ExtensionPath
)

webExtension.ExtensionPath = {
   type: "path",
   path: text,
}

webExtension.ExtensionArchivePath = {
   type: "archivePath",
   path: text,
}

webExtension.ExtensionBase64Encoded = {
   type: "base64",
   value: text,
}
戻り値型
webExtension.InstallResult = {
  extension: webExtension.Extension
}
bytesが与えられたとき、zip アーカイブを展開するには:
  1. zip 圧縮アルゴリズムを使用してbytesをデコードする、実装定義の手順を実行する。TODO: zip デコードのより良い参照を見つける。

  2. 前の手順が失敗した場合(例えば、bytesが有効な zip 圧縮データを表していなかったため)、エラーをエラーコード invalid web extensionで返す。そうでなければ、entryを、展開されたファイルシステムエントリを含むディレクトリエントリとする。

  3. entryを返す。

extension data specが与えられたとき、Web 拡張機能データ仕様を展開するには:
  1. typeextension data spec["type"]とする。

  2. typeを使用した Web 拡張機能のインストールがサポートされていない場合、エラーエラー コード unsupported operationで返す。

  3. 以下の条件とそれに関連付けられた手順のリストにおいて、 関連付けられた条件が true である最初の手順群を実行する:

    type is the string "path"
    1. pathextension data spec["path"]とする。

    2. locatorを、パスpathと、ファイルシステムのルートに対応するルートを持つディレクトリロケーターとする。

    3. entryを、locatorが与えられたときにエントリを特定する結果とする。

    type is the string "archivePath"
    1. archive pathextension data spec["path"]とする。

    2. locatorを、パスarchive pathと、ファイルシステムのルートに対応するルートを持つファイルロケーターとする。

    3. archive entryを、 locatorが与えられたときにエントリを特定する結果とする。

    4. archive entryが null である場合、null を返す。

    5. bytesを、archive entryバイナリデータとする。

    6. entryを、bytesが与えられたときに試行してzip アーカイブを展開する結果とする。

    type is the string "base64"
    1. bytesを、 extension data spec["value"]のforgiving-base64 decode結果とする。

    2. bytesが failure である場合、null を返す。

    3. entryを、bytesが与えられたときに試行してzip アーカイブを展開する結果とする。

  4. entryを返す。

command parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. Web 拡張機能のインストールがサポートされていない場合、エラーをエラー コード unsupported operationで返す。

  2. extension data speccommand parameters["extensionData"]とする。

  3. extension directory entryを、 extension data spec試行してWeb 拡張機能データ仕様を展開する結果とする。

  4. extension directory entryが null である場合、エラーエラーコード invalid web extensionで返す。

  5. extension directory entryから Web 拡張機能をインストールする実装定義の手順を実行する。これが失敗した場合、エラーエラーコード invalid web extensionで返す。そうでなければ、extension idを、新しくインストールされた Web 拡張機能の一意な識別子とする。

  6. resultを、 extensionフィールドがextension idに設定された webExtension.InstallResult生成規則に一致するマップとする。

  7. 成功をデータresultとともに返す。

注記: ブラウザーは既定で Web 拡張機能を一時的にのみ インストールする場合があるため、 次回終了時に自動的にアンインストールされることがある。

7.10.3.2. webExtension.uninstall コマンド

webExtension.uninstallコマンドは、 リモートエンドの Web 拡張機能をアンインストールする。

コマンド型
webExtension.Uninstall = (
   method: "webExtension.uninstall",
   params: webExtension.UninstallParameters
)

webExtension.UninstallParameters = {
   extension: webExtension.Extension,
}
戻り値型
webExtension.UninstallResult = EmptyResult
command parametersが与えられたときのリモートエンド手順は次のとおりである:
  1. extensioncommand parameters["extension"]とする。

  2. リモートエンドextensionと等しい ID を持つ Web 拡張機能を持たない場合、 エラーエラーコード no such web extensionで返す。

  3. Web 拡張機能をリモートエンドから除去する、任意の実装定義の手順を実行する。これが失敗した場合、エラーエラーコード unknown errorで返す。

  4. 成功をデータ null とともに返す。

8. 他の仕様へのパッチ

この仕様は、必要な integration points を提供するため、外部仕様へのいくつかの変更を必要とする。 これらの patches は standards process の一部として他の仕様へ commit されるものと想定される。

8.1. HTML

report an error algorithm は、末尾に追加の step を加えて変更される:

  1. 外部仕様で定義された任意の error reporting steps を、script, line, col, message, および error が handled であれば true、そうでなければ false とともに呼び出す。

8.2. Console

他の仕様は console steps を定義できる。

  1. Printer operation が arguments name, printerArgs および options(argument が提供されない場合は undefined) とともに呼び出される時点で、外部仕様で定義された任意の console steps を arguments name, printerArgs, および options とともに呼び出す。

8.3. CSS

8.3.1. device pixel ratio の決定

determine the device pixel ratio algorithm の先頭に、 次の steps を挿入する:

  1. device pixel ratio overrideswindownavigablecontains する場合、device pixel ratio overrides[windownavigable] を返す。

9. 付録

この節は非規範的である。

9.1. 外部仕様

注: この list は網羅的ではなく、最新でない可能性がある。

次の外部仕様は、追加の WebDriver BiDi modules を定義する:

  1. Digital Credentials API

  2. Permissions

  3. nav-speculation

  4. User-Agent Client Hints

  5. Web Bluetooth

索引

この仕様で定義される用語

参照により定義される用語

参考文献

規範的参考文献

[ACCNAME-1.1]
Joanmarie Diggs; Bryan Garaventa; Michael Cooper. アクセシブルな 名前および説明の計算 1.1. URL: https://w3c.github.io/accname/
[CONSOLE]
Dominic Farolino; Robert Kowalski; Terin Stock. Console 標準. Living Standard. URL: https://console.spec.whatwg.org/
[COOKIES]
A. Barth. HTTP状態管理メカニズム. 2011年4月. Proposed Standard. URL: https://httpwg.org/specs/rfc6265.html
[CORE-AAM-1.1]
Joanmarie Diggs; et al. コアアクセシビリティAPIマッピング 1.1. URL: https://w3c.github.io/core-aam/
[CSS-COLOR-ADJUST-1]
Elika Etemad; et al. CSS色調整 モジュール レベル1. URL: https://drafts.csswg.org/css-color-adjust-1/
[CSS-OVERFLOW-3]
Elika Etemad; Florian Rivoal. CSSオーバーフローモジュール レベル3. URL: https://drafts.csswg.org/css-overflow-3/
[CSS-PAINT-API-1]
Ian Kilpatrick; Dean Jackson. CSS描画 API レベル1. URL: https://drafts.css-houdini.org/css-paint-api-1/
[CSS2]
Bert Bos; et al. カスケーディング・スタイル・シート レベル2 改訂1 (CSS 2.1) 仕様. URL: https://drafts.csswg.org/css2/
[CSSOM-VIEW-1]
Simon Fraser; Emilio Cobos Álvarez. CSSOM View モジュール. URL: https://drafts.csswg.org/cssom-view/
[DOM]
Anne van Kesteren. DOM標準. Living Standard. URL: https://dom.spec.whatwg.org/
[ECMA-402]
ECMAScript国際化API仕様. URL: https://tc39.es/ecma402/
[ECMAScript]
ECMAScript言語仕様. URL: https://tc39.es/ecma262/multipage/
[ENCODING]
Anne van Kesteren. Encoding標準. Living Standard. URL: https://encoding.spec.whatwg.org/
[FETCH]
Anne van Kesteren. Fetch標準. Living Standard. URL: https://fetch.spec.whatwg.org/
[FS]
Austin Sullivan. File System標準. Living Standard. URL: https://fs.spec.whatwg.org/
[FULLSCREEN]
Philip Jägenstedt. Fullscreen API標準. Living Standard. URL: https://fullscreen.spec.whatwg.org/
[GEOLOCATION]
Marcos Caceres; Reilly Grant. Geolocation. URL: https://w3c.github.io/geolocation/
[GEOMETRY-1]
Sebastian Zartner; Yehonatan Daniv. Geometry Interfaces モジュール レベル1. URL: https://drafts.csswg.org/geometry/
[HR-TIME-3]
Yoav Weiss. 高精度時間. URL: https://w3c.github.io/hr-time/
[HTML]
Anne van Kesteren; et al. HTML標準. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra 標準. Living Standard. URL: https://infra.spec.whatwg.org/
[MIMESNIFF]
Gordon P. Hemsley. MIME Sniffing標準. Living Standard. URL: https://mimesniff.spec.whatwg.org/
[RESOURCE-TIMING]
Yoav Weiss; Noam Rosenthal. Resource Timing. URL: https://w3c.github.io/resource-timing/
[RFC4648]
S. Josefsson. Base16、Base32、およびBase64データ エンコーディング. 2006年10月. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc4648/
[RFC5280]
D. Cooper; et al. Internet X.509公開鍵 基盤証明書および証明書失効リスト(CRL)プロファイル. 2008年5月. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc5280/
[RFC6455]
I. Fette; A. Melnikov. WebSocket プロトコル. 2011年12月. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc6455/
[RFC8610]
H. Birkholz; C. Vigano; C. Bormann. Concise Data Definition Language(CDDL):Concise Binary Object Representation (CBOR)およびJSONデータ構造を表現するための記法規約. 2019年6月. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc8610/
[RFC9110]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP Semantics. 2022年6月. Internet Standard. URL: https://httpwg.org/specs/rfc9110.html
[RFC9562]
K. Davis; B. Peabody; P. Leach. Universally Unique IDentifiers(UUID). 2024年5月. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc9562/
[SCREEN-CAPTURE]
Jan-Ivar Bruaroey; Elad Alon. 画面 キャプチャ. URL: https://w3c.github.io/mediacapture-screen-share/
[SCREEN-ORIENTATION]
Marcos Caceres. 画面の向き. URL: https://w3c.github.io/screen-orientation/
[SELECTORS-4]
Elika Etemad; Tab Atkins Jr.. セレクター レベル 4. URL: https://drafts.csswg.org/selectors/
[SERVICE-WORKERS]
Monica CHINTALA; Yoshisato Yanagisawa. Service Workers Nightly. URL: https://w3c.github.io/ServiceWorker/
[SVG2]
Amelia Bellamy-Royds; et al. Scalable Vector Graphics(SVG)2. URL: https://w3c.github.io/svgwg/svg2-draft/
[UNICODE]
Unicode標準. URL: https://www.unicode.org/versions/latest/
[URL]
Anne van Kesteren. URL標準. Living Standard. URL: https://url.spec.whatwg.org/
[WEBAUDIO-1.0]
Paul Adenot; Hongchan Choi. Web Audio API. URL: https://webaudio.github.io/web-audio-api/
[WEBDRIVER]
Simon Stewart; David Burns. WebDriver. URL: https://w3c.github.io/webdriver/
[WEBIDL]
Edgar Chen; Timothy Gu. Web IDL標準. Living Standard. URL: https://webidl.spec.whatwg.org/
[WEBSOCKETS]
Adam Rice. WebSockets標準. Living Standard. URL: https://websockets.spec.whatwg.org/
[WEBTRANSPORT]
Nidhi Jaju; Victor Vasiliev; Jan-Ivar Bruaroey. WebTransport. URL: https://w3c.github.io/webtransport/

非規範的参考文献

[CSS-VALUES-3]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. URL: https://drafts.csswg.org/css-values-3/
[HTTP11]
R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP/1.1. 2022 年 6 月. Internet Standard. URL: https://httpwg.org/specs/rfc9112.html
[JSON-RPC]
JSON-RPC Working Group. JSON-RPC 2.0 Specification. 2013 年 1 月 4 日. URL: https://www.jsonrpc.org/specification
[RFC6265BIS]
Cookies: HTTP State Management Mechanism. Editor's Draft. URL: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis
[TOUCH-EVENTS]
Doug Schepers; et al. Touch Events. URL: https://w3c.github.io/touch-events/
[URLPattern]
Ben Kelly; Jeremy Roman; 宍戸俊哉 (Shunya Shishido). URL Pattern Standard. Living Standard. URL: https://urlpattern.spec.whatwg.org/

CDDL 索引

Remote end definition

Command = {
  id: js-uint,
  CommandData,
  Extensible,
}

CommandData = (
  BrowserCommand //
  BrowsingContextCommand //
  EmulationCommand //
  InputCommand //
  NetworkCommand //
  ScriptCommand //
  SessionCommand //
  StorageCommand //
  WebExtensionCommand
)

EmptyParams = {
   Extensible
}

Extensible = (*text => any)

js-int = -9007199254740991..9007199254740991
js-uint = 0..9007199254740991

SessionCommand = (
  session.End //
  session.New //
  session.Status //
  session.Subscribe //
  session.Unsubscribe
)

session.CapabilitiesRequest = {
  ? alwaysMatch: session.CapabilityRequest,
  ? firstMatch: [*session.CapabilityRequest]
}

session.CapabilityRequest = {
  ? acceptInsecureCerts: bool,
  ? browserName: text,
  ? browserVersion: text,
  ? platformName: text,
  ? proxy: session.ProxyConfiguration,
  ? unhandledPromptBehavior: session.UserPromptHandler,
  Extensible
}

session.ProxyConfiguration = {
   session.AutodetectProxyConfiguration //
   session.DirectProxyConfiguration //
   session.ManualProxyConfiguration //
   session.PacProxyConfiguration //
   session.SystemProxyConfiguration
}

session.AutodetectProxyConfiguration = (
   proxyType: "autodetect",
   Extensible
)

session.DirectProxyConfiguration = (
   proxyType: "direct",
   Extensible
)

session.ManualProxyConfiguration = (
   proxyType: "manual",
   ? httpProxy: text,
   ? sslProxy: text,
   ? session.SocksProxyConfiguration,
   ? noProxy: [*text],
   Extensible
)

session.SocksProxyConfiguration = (
   socksProxy: text,
   socksVersion: 0..255,
)

session.PacProxyConfiguration = (
   proxyType: "pac",
   proxyAutoconfigUrl: text,
   Extensible
)

session.SystemProxyConfiguration = (
   proxyType: "system",
   Extensible
)


session.UserPromptHandler = {
  ? alert: session.UserPromptHandlerType,
  ? beforeUnload: session.UserPromptHandlerType,
  ? confirm: session.UserPromptHandlerType,
  ? default: session.UserPromptHandlerType,
  ? file: session.UserPromptHandlerType,
  ? prompt: session.UserPromptHandlerType,
}

session.UserPromptHandlerType = "accept" / "dismiss" / "ignore";

session.Subscription = text

session.SubscribeParameters = {
  events: [+text],
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

session.UnsubscribeByIDRequest = {
  subscriptions: [+session.Subscription],
}

session.UnsubscribeByAttributesRequest = {
  events: [+text],
}

session.Status = (
  method: "session.status",
  params: EmptyParams,
)

session.New = (
  method: "session.new",
  params: session.NewParameters
)

session.NewParameters = {
  capabilities: session.CapabilitiesRequest
}

session.End = (
  method: "session.end",
  params: EmptyParams
)


session.Subscribe = (
  method: "session.subscribe",
  params: session.SubscribeParameters
)

session.Unsubscribe = (
  method: "session.unsubscribe",
  params: session.UnsubscribeParameters,
)

session.UnsubscribeParameters = session.UnsubscribeByAttributesRequest / session.UnsubscribeByIDRequest

BrowserCommand = (
  browser.Close //
  browser.CreateUserContext //
  browser.GetClientWindows //
  browser.GetUserContexts //
  browser.RemoveUserContext //
  browser.SetClientWindowState //
  browser.SetDownloadBehavior
)

browser.ClientWindow = text;

browser.ClientWindowInfo = {
  active: bool,
  clientWindow: browser.ClientWindow,
  height: js-uint,
  state: "fullscreen" / "maximized" / "minimized" / "normal",
  width: js-uint,
  x: js-int,
  y: js-int,
}

browser.UserContext = text;

browser.UserContextInfo = {
  userContext: browser.UserContext
}

browser.Close = (
  method: "browser.close",
  params: EmptyParams,
)

browser.CreateUserContext = (
  method: "browser.createUserContext",
  params: browser.CreateUserContextParameters,
)

browser.CreateUserContextParameters = {
  ? acceptInsecureCerts: bool,
  ? proxy: session.ProxyConfiguration,
  ? unhandledPromptBehavior: session.UserPromptHandler
}

browser.GetClientWindows = (
  method: "browser.getClientWindows",
  params: EmptyParams,
)

browser.GetUserContexts = (
  method: "browser.getUserContexts",
  params: EmptyParams,
)

browser.RemoveUserContext = (
  method: "browser.removeUserContext",
  params: browser.RemoveUserContextParameters
)

browser.RemoveUserContextParameters = {
  userContext: browser.UserContext
}

browser.SetClientWindowState = (
  method: "browser.setClientWindowState",
  params: browser.SetClientWindowStateParameters
)

browser.SetClientWindowStateParameters = {
  clientWindow: browser.ClientWindow,
  (browser.ClientWindowNamedState // browser.ClientWindowRectState)
}

browser.ClientWindowNamedState = (
  state: "fullscreen" / "maximized" / "minimized"
)

browser.ClientWindowRectState = (
  state: "normal",
  ? width: js-uint,
  ? height: js-uint,
  ? x: js-int,
  ? y: js-int,
)

browser.SetDownloadBehavior = (
  method: "browser.setDownloadBehavior",
  params: browser.SetDownloadBehaviorParameters
)

browser.SetDownloadBehaviorParameters = {
  downloadBehavior: browser.DownloadBehavior / null,
  ? userContexts: [+browser.UserContext]
}

browser.DownloadBehavior = {
  (
    browser.DownloadBehaviorAllowed //
    browser.DownloadBehaviorDenied
  )
}

browser.DownloadBehaviorAllowed = (
  type: "allowed",
  destinationFolder: text
)

browser.DownloadBehaviorDenied = (
  type: "denied"
)

BrowsingContextCommand = (
  browsingContext.Activate //
  browsingContext.CaptureScreenshot //
  browsingContext.Close //
  browsingContext.Create //
  browsingContext.GetTree //
  browsingContext.HandleUserPrompt //
  browsingContext.LocateNodes //
  browsingContext.Navigate //
  browsingContext.Print //
  browsingContext.Reload //
  browsingContext.SetBypassCSP //
  browsingContext.SetViewport //
  browsingContext.StartScreencast //
  browsingContext.StopScreencast //
  browsingContext.TraverseHistory
)

browsingContext.BrowsingContext = text;

browsingContext.Locator = (
   browsingContext.AccessibilityLocator /
   browsingContext.CssLocator /
   browsingContext.ContextLocator /
   browsingContext.InnerTextLocator /
   browsingContext.XPathLocator
)

browsingContext.AccessibilityLocator = {
   type: "accessibility",
   value: {
    ? name: text,
    ? role: text,
   }
}

browsingContext.CssLocator = {
   type: "css",
   value: text
}

browsingContext.ContextLocator = {
  type: "context",
  value: {
    context: browsingContext.BrowsingContext,
  }
}

browsingContext.InnerTextLocator = {
   type: "innerText",
   value: text,
   ? ignoreCase: bool
   ? matchType: "full" / "partial",
   ? maxDepth: js-uint,
}

browsingContext.XPathLocator = {
   type: "xpath",
   value: text
}

browsingContext.Navigation = text;

browsingContext.Download = text;

browsingContext.ReadinessState = "none" / "interactive" / "complete"

browsingContext.UserPromptType = "alert" / "beforeunload" / "confirm" / "prompt";

browsingContext.Activate = (
  method: "browsingContext.activate",
  params: browsingContext.ActivateParameters
)

browsingContext.ActivateParameters = {
  context: browsingContext.BrowsingContext
}

browsingContext.CaptureScreenshot = (
  method: "browsingContext.captureScreenshot",
  params: browsingContext.CaptureScreenshotParameters
)

browsingContext.CaptureScreenshotParameters = {
  context: browsingContext.BrowsingContext,
  ? origin: ("viewport" / "document") .default "viewport",
  ? format: browsingContext.ImageFormat,
  ? clip: browsingContext.ClipRectangle,
}

browsingContext.ImageFormat = {
   type: text,
   ? quality: 0.0..1.0,
}

browsingContext.ClipRectangle = (
  browsingContext.BoxClipRectangle /
  browsingContext.ElementClipRectangle
)

browsingContext.ElementClipRectangle = {
  type: "element",
  element: script.SharedReference
}

browsingContext.BoxClipRectangle = {
   type: "box",
   x: float,
   y: float,
   width: float,
   height: float
}

browsingContext.Close = (
  method: "browsingContext.close",
  params: browsingContext.CloseParameters
)

browsingContext.CloseParameters = {
  context: browsingContext.BrowsingContext,
  ? promptUnload: bool .default false
}

browsingContext.Create = (
  method: "browsingContext.create",
  params: browsingContext.CreateParameters
)

browsingContext.CreateType = "tab" / "window"

browsingContext.CreateParameters = {
  type: browsingContext.CreateType,
  ? referenceContext: browsingContext.BrowsingContext,
  ? background: bool .default false,
  ? userContext: browser.UserContext
}

browsingContext.GetTree = (
  method: "browsingContext.getTree",
  params: browsingContext.GetTreeParameters
)

browsingContext.GetTreeParameters = {
  ? maxDepth: js-uint,
  ? root: browsingContext.BrowsingContext,
}

browsingContext.HandleUserPrompt = (
  method: "browsingContext.handleUserPrompt",
  params: browsingContext.HandleUserPromptParameters
)

browsingContext.HandleUserPromptParameters = {
  context: browsingContext.BrowsingContext,
  ? accept: bool,
  ? userText: text,
}

browsingContext.LocateNodes = (
  method: "browsingContext.locateNodes",
  params: browsingContext.LocateNodesParameters
)

browsingContext.LocateNodesParameters = {
   context: browsingContext.BrowsingContext,
   locator: browsingContext.Locator,
   ? maxNodeCount: (js-uint .ge 1),
   ? serializationOptions: script.SerializationOptions,
   ? startNodes: [ + script.SharedReference ]
}

browsingContext.Navigate = (
  method: "browsingContext.navigate",
  params: browsingContext.NavigateParameters
)

browsingContext.NavigateParameters = {
  context: browsingContext.BrowsingContext,
  url: text,
  ? wait: browsingContext.ReadinessState,
}

browsingContext.Print = (
  method: "browsingContext.print",
  params: browsingContext.PrintParameters
)

browsingContext.PrintParameters = {
  context: browsingContext.BrowsingContext,
  ? background: bool .default false,
  ? margin: browsingContext.PrintMarginParameters,
  ? orientation: ("portrait" / "landscape") .default "portrait",
  ? page: browsingContext.PrintPageParameters,
  ? pageRanges: [*(js-uint / text)],
  ? scale: (0.1..2.0) .default 1.0,
  ? shrinkToFit: bool .default true,
}

browsingContext.PrintMarginParameters = {
  ? bottom: (float .ge 0.0) .default 1.0,
  ? left: (float .ge 0.0) .default 1.0,
  ? right: (float .ge 0.0) .default 1.0,
  ? top: (float .ge 0.0) .default 1.0,
}

; Minimum size is 1pt x 1pt. Conversion follows from
; https://www.w3.org/TR/css3-values/#absolute-lengths
browsingContext.PrintPageParameters = {
  ? height: (float .ge 0.0352) .default 27.94,
  ? width: (float .ge 0.0352) .default 21.59,
}

browsingContext.Reload = (
  method: "browsingContext.reload",
  params: browsingContext.ReloadParameters
)

browsingContext.ReloadParameters = {
  context: browsingContext.BrowsingContext,
  ? ignoreCache: bool,
  ? wait: browsingContext.ReadinessState,
}

browsingContext.SetBypassCSP = (
  method: "browsingContext.setBypassCSP",
  params: browsingContext.SetBypassCSPParameters
)

browsingContext.SetBypassCSPParameters = {
  bypass: true / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

browsingContext.SetViewport = (
  method: "browsingContext.setViewport",
  params: browsingContext.SetViewportParameters
)

browsingContext.SetViewportParameters = {
  ? context: browsingContext.BrowsingContext,
  ? viewport: browsingContext.Viewport / null,
  ? devicePixelRatio: (float .gt 0.0) / null,
  ? userContexts: [+browser.UserContext],
}

browsingContext.Viewport = {
  width: js-uint,
  height: js-uint,
}

browsingContext.StartScreencast = (
  method: "browsingContext.startScreencast",
  params: browsingContext.StartScreencastParameters
)

browsingContext.StartScreencastParameters = {
  context: browsingContext.BrowsingContext,
  ? mimeType: text,
  ? video: browsingContext.MediaTrackConstraints,
  ? audio: bool .default false,
}

browsingContext.MediaTrackConstraints = {
   ? width: js-uint,
   ? height: js-uint,
   ? frameRate: js-uint,
}


browsingContext.Screencast = text

browsingContext.StopScreencast = (
  method: "browsingContext.stopScreencast",
  params: browsingContext.StopScreencastParameters
)

browsingContext.StopScreencastParameters = {
  screencast: browsingContext.Screencast
}

browsingContext.TraverseHistory = (
  method: "browsingContext.traverseHistory",
  params: browsingContext.TraverseHistoryParameters
)

browsingContext.TraverseHistoryParameters = {
  context: browsingContext.BrowsingContext,
  delta: js-int,
}

EmulationCommand = (
  emulation.SetForcedColorsModeThemeOverride //
  emulation.SetGeolocationOverride //
  emulation.SetLocaleOverride //
  emulation.SetNetworkConditions //
  emulation.SetScreenOrientationOverride //
  emulation.SetScreenSettingsOverride //
  emulation.SetScriptingEnabled //
  emulation.SetScrollbarTypeOverride //
  emulation.SetTimezoneOverride //
  emulation.SetTouchOverride //
  emulation.SetUserAgentOverride
)


emulation.SetForcedColorsModeThemeOverride = (
  method: "emulation.setForcedColorsModeThemeOverride",
  params: emulation.SetForcedColorsModeThemeOverrideParameters
)

emulation.SetForcedColorsModeThemeOverrideParameters = {
  theme: emulation.ForcedColorsModeTheme / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.ForcedColorsModeTheme = "light" / "dark"

emulation.SetGeolocationOverride = (
  method: "emulation.setGeolocationOverride",
  params: emulation.SetGeolocationOverrideParameters
)

emulation.SetGeolocationOverrideParameters = {
  (
    (coordinates: emulation.GeolocationCoordinates / null) //
    (error: emulation.GeolocationPositionError)
  ),
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.GeolocationCoordinates = {
   latitude: -90.0..90.0,
   longitude: -180.0..180.0,
   ? accuracy: (float .ge 0.0) .default 1.0,
   ? altitude: float / null .default null,
   ? altitudeAccuracy: (float .ge 0.0) / null .default null,
   ? heading: (0.0...360.0) / null .default null,
   ? speed: (float .ge 0.0) / null .default null,
}

emulation.GeolocationPositionError = {
   type: "positionUnavailable"
}

emulation.SetLocaleOverride = (
  method: "emulation.setLocaleOverride",
  params: emulation.SetLocaleOverrideParameters
)

emulation.SetLocaleOverrideParameters = {
  locale: text / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetNetworkConditions = (
  method: "emulation.setNetworkConditions",
  params: emulation.SetNetworkConditionsParameters
)

emulation.SetNetworkConditionsParameters = {
  networkConditions: emulation.NetworkConditions / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.NetworkConditions = emulation.NetworkConditionsOffline

emulation.NetworkConditionsOffline = {
  type: "offline"
}

emulation.SetScreenSettingsOverride = (
  method: "emulation.setScreenSettingsOverride",
  params: emulation.SetScreenSettingsOverrideParameters
)

emulation.ScreenArea = {
  width: js-uint,
  height: js-uint
}

emulation.SetScreenSettingsOverrideParameters = {
  screenArea: emulation.ScreenArea / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetScreenOrientationOverride = (
  method: "emulation.setScreenOrientationOverride",
  params: emulation.SetScreenOrientationOverrideParameters
)

emulation.ScreenOrientationNatural = "portrait" / "landscape"
emulation.ScreenOrientationType = "portrait-primary" / "portrait-secondary" / "landscape-primary" / "landscape-secondary"

emulation.ScreenOrientation = {
  natural: emulation.ScreenOrientationNatural,
  type: emulation.ScreenOrientationType
}

emulation.SetScreenOrientationOverrideParameters = {
  screenOrientation: emulation.ScreenOrientation / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetUserAgentOverride = (
  method: "emulation.setUserAgentOverride",
  params: emulation.SetUserAgentOverrideParameters
)

emulation.SetUserAgentOverrideParameters = {
  userAgent: text / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetScriptingEnabled = (
  method: "emulation.setScriptingEnabled",
  params: emulation.SetScriptingEnabledParameters
)

emulation.SetScriptingEnabledParameters = {
  enabled: false / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetScrollbarTypeOverride = (
  method: "emulation.setScrollbarTypeOverride",
  params: emulation.SetScrollbarTypeOverrideParameters
)

emulation.SetScrollbarTypeOverrideParameters = {
  scrollbarType: "classic" / "overlay" / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetTimezoneOverride = (
  method: "emulation.setTimezoneOverride",
  params: emulation.SetTimezoneOverrideParameters
)

emulation.SetTimezoneOverrideParameters = {
  timezone: text / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

emulation.SetTouchOverride = (
  method: "emulation.setTouchOverride",
  params: emulation.SetTouchOverrideParameters
)

emulation.SetTouchOverrideParameters = {
  maxTouchPoints: (js-uint .ge 1) / null,
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

NetworkCommand = (
  network.AddDataCollector //
  network.AddIntercept //
  network.ContinueRequest //
  network.ContinueResponse //
  network.ContinueWithAuth //
  network.DisownData //
  network.FailRequest //
  network.GetData //
  network.ProvideResponse //
  network.RemoveDataCollector //
  network.RemoveIntercept //
  network.SetCacheBehavior //
  network.SetExtraHeaders
)


network.AuthCredentials = {
  type: "password",
  username: text,
  password: text,
}

network.BytesValue = network.StringValue / network.Base64Value;

network.StringValue = {
  type: "string",
  value: text,
}

network.Base64Value = {
  type: "base64",
  value: text,
}

network.Collector = text

network.CollectorType = "blob"

network.SameSite = "strict" / "lax" / "none" / "default"


network.Cookie = {
    name: text,
    value: network.BytesValue,
    domain: text,
    path: text,
    size: js-uint,
    httpOnly: bool,
    secure: bool,
    sameSite: network.SameSite,
    ? expiry: js-uint,
    Extensible,
}

network.CookieHeader = {
    name: text,
    value: network.BytesValue,
}

network.DataType = "request" / "response"

network.Header = {
  name: text,
  value: network.BytesValue,
}

network.Intercept = text

network.Request = text;

network.SetCookieHeader = {
    name: text,
    value: network.BytesValue,
    ? domain: text,
    ? httpOnly: bool,
    ? expiry: text,
    ? maxAge: js-int,
    ? path: text,
    ? sameSite: network.SameSite,
    ? secure: bool,
}

network.UrlPattern = (
  network.UrlPatternPattern /
  network.UrlPatternString
)

network.UrlPatternPattern = {
    type: "pattern",
    ?protocol: text,
    ?hostname: text,
    ?port: text,
    ?pathname: text,
    ?search: text,
}


network.UrlPatternString = {
    type: "string",
    pattern: text,
}


network.AddDataCollector = (
  method: "network.addDataCollector",
  params: network.AddDataCollectorParameters
)

network.AddDataCollectorParameters = {
  dataTypes: [+network.DataType],
  maxEncodedDataSize: js-uint,
  ? collectorType: network.CollectorType .default "blob",
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
}

network.AddIntercept = (
  method: "network.addIntercept",
  params: network.AddInterceptParameters
)

network.AddInterceptParameters = {
  phases: [+network.InterceptPhase],
  ? contexts: [+browsingContext.BrowsingContext],
  ? urlPatterns: [*network.UrlPattern],
}

network.InterceptPhase = "beforeRequestSent" / "responseStarted" /
                         "authRequired"

network.ContinueRequest = (
  method: "network.continueRequest",
  params: network.ContinueRequestParameters
)

network.ContinueRequestParameters = {
  request: network.Request,
  ?body: network.BytesValue,
  ?cookies: [*network.CookieHeader],
  ?headers: [*network.Header],
  ?method: text,
  ?url: text,
}

network.ContinueResponse = (
  method: "network.continueResponse",
  params: network.ContinueResponseParameters
)

network.ContinueResponseParameters = {
  request: network.Request,
  ?cookies: [*network.SetCookieHeader]
  ?credentials: network.AuthCredentials,
  ?headers: [*network.Header],
  ?reasonPhrase: text,
  ?statusCode: js-uint,
}

network.ContinueWithAuth = (
  method: "network.continueWithAuth",
  params: network.ContinueWithAuthParameters
)

network.ContinueWithAuthParameters = {
  request: network.Request,
  (network.ContinueWithAuthCredentials // network.ContinueWithAuthNoCredentials)
}

network.ContinueWithAuthCredentials = (
  action: "provideCredentials", 
  credentials: network.AuthCredentials
)

network.ContinueWithAuthNoCredentials = (
  action: "default" / "cancel"
)

network.DisownData = (
  method: "network.disownData",
  params: network.DisownDataParameters
)

network.DisownDataParameters = {
  dataType: network.DataType,
  collector: network.Collector,
  request: network.Request,
}

network.FailRequest = (
  method: "network.failRequest",
  params: network.FailRequestParameters
)

network.FailRequestParameters = {
  request: network.Request,
}

network.GetData = (
  method: "network.getData",
  params: network.GetDataParameters
)

network.GetDataParameters = {
  dataType: network.DataType,
  ? collector: network.Collector,
  ? disown: bool .default false,
  request: network.Request,
}

network.ProvideResponse = (
  method: "network.provideResponse",
  params: network.ProvideResponseParameters
)

network.ProvideResponseParameters = {
  request: network.Request,
  ?body: network.BytesValue,
  ?cookies: [*network.SetCookieHeader],
  ?headers: [*network.Header],
  ?reasonPhrase: text,
  ?statusCode: js-uint,
}

network.RemoveDataCollector = (
  method: "network.removeDataCollector",
  params: network.RemoveDataCollectorParameters
)

network.RemoveDataCollectorParameters = {
  collector: network.Collector
}

network.RemoveIntercept = (
  method: "network.removeIntercept",
  params: network.RemoveInterceptParameters
)

network.RemoveInterceptParameters = {
  intercept: network.Intercept
}

network.SetCacheBehavior = (
  method: "network.setCacheBehavior",
  params: network.SetCacheBehaviorParameters
)

network.SetCacheBehaviorParameters = {
  cacheBehavior: "default" / "bypass",
  ? contexts: [+browsingContext.BrowsingContext]
}

network.SetExtraHeaders = (
  method: "network.setExtraHeaders",
  params: network.SetExtraHeadersParameters
)

network.SetExtraHeadersParameters = {
  headers: [*network.Header]
  ? contexts: [+browsingContext.BrowsingContext]
  ? userContexts: [+browser.UserContext]
}

ScriptCommand = (
  script.AddPreloadScript //
  script.CallFunction //
  script.Disown //
  script.Evaluate //
  script.GetRealms //
  script.RemovePreloadScript
)

script.Channel = text;

script.ChannelValue = {
  type: "channel",
  value: script.ChannelProperties,
}

script.ChannelProperties = {
  channel: script.Channel,
  ? serializationOptions: script.SerializationOptions,
  ? ownership: script.ResultOwnership,
}

script.EvaluateResult = (
  script.EvaluateResultSuccess /
  script.EvaluateResultException
)

script.EvaluateResultSuccess = {
  type: "success",
  result: script.RemoteValue,
  realm: script.Realm
}

script.EvaluateResultException = {
  type: "exception",
  exceptionDetails: script.ExceptionDetails
  realm: script.Realm
}

script.ExceptionDetails = {
  columnNumber: js-uint,
  exception: script.RemoteValue,
  lineNumber: js-uint,
  stackTrace: script.StackTrace,
  text: text,
}

script.Handle = text;

script.InternalId = text;

script.LocalValue = (
  script.RemoteReference /
  script.PrimitiveProtocolValue /
  script.ChannelValue /
  script.ArrayLocalValue /
  { script.DateLocalValue } /
  script.MapLocalValue /
  script.ObjectLocalValue /
  { script.RegExpLocalValue } /
  script.SetLocalValue
)

script.ListLocalValue = [*script.LocalValue];

script.ArrayLocalValue = {
  type: "array",
  value: script.ListLocalValue,
}

script.DateLocalValue = (
  type: "date",
  value: text
)

script.MappingLocalValue = [*[(script.LocalValue / text), script.LocalValue]];

script.MapLocalValue = {
  type: "map",
  value: script.MappingLocalValue,
}

script.ObjectLocalValue = {
  type: "object",
  value: script.MappingLocalValue,
}

script.RegExpValue = {
  pattern: text,
  ? flags: text,
}

script.RegExpLocalValue = (
  type: "regexp",
  value: script.RegExpValue,
)

script.SetLocalValue = {
  type: "set",
  value: script.ListLocalValue,
}

script.PreloadScript = text;

script.Realm = text;

script.PrimitiveProtocolValue = (
  script.UndefinedValue /
  script.NullValue /
  script.StringValue /
  script.NumberValue /
  script.BooleanValue /
  script.BigIntValue
)

script.UndefinedValue = {
  type: "undefined",
}

script.NullValue = {
  type: "null",
}

script.StringValue = {
  type: "string",
  value: text,
}

script.SpecialNumber = "NaN" / "-0" / "Infinity" / "-Infinity";

script.NumberValue = {
  type: "number",
  value: number / script.SpecialNumber,
}

script.BooleanValue = {
  type: "boolean",
  value: bool,
}

script.BigIntValue = {
  type: "bigint",
  value: text,
}

script.RealmType = "window" / "dedicated-worker" / "shared-worker" / "service-worker" /
                   "worker" / "paint-worklet" / "audio-worklet" / "worklet"

script.RemoteReference = (
  script.SharedReference /
  script.RemoteObjectReference
)

script.SharedReference = {
   sharedId: script.SharedId

   ? handle: script.Handle,
   Extensible
}

script.RemoteObjectReference = {
   handle: script.Handle,

   ? sharedId: script.SharedId
   Extensible
}

script.RemoteValue = (
  script.PrimitiveProtocolValue /
  script.SymbolRemoteValue /
  script.ArrayRemoteValue /
  script.ObjectRemoteValue /
  script.FunctionRemoteValue /
  script.RegExpRemoteValue /
  script.DateRemoteValue /
  script.MapRemoteValue /
  script.SetRemoteValue /
  script.WeakMapRemoteValue /
  script.WeakSetRemoteValue /
  script.GeneratorRemoteValue /
  script.ErrorRemoteValue /
  script.ProxyRemoteValue /
  script.PromiseRemoteValue /
  script.TypedArrayRemoteValue /
  script.ArrayBufferRemoteValue /
  script.NodeListRemoteValue /
  script.HTMLCollectionRemoteValue /
  script.NodeRemoteValue /
  script.WindowProxyRemoteValue
)

script.ListRemoteValue = [*script.RemoteValue];

script.MappingRemoteValue = [*[(script.RemoteValue / text), script.RemoteValue]];

script.SymbolRemoteValue = {
  type: "symbol",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ArrayRemoteValue = {
  type: "array",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.ObjectRemoteValue = {
  type: "object",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.MappingRemoteValue,
}

script.FunctionRemoteValue = {
  type: "function",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.RegExpRemoteValue = {
  script.RegExpLocalValue,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.DateRemoteValue = {
  script.DateLocalValue,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.MapRemoteValue = {
  type: "map",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.MappingRemoteValue,
}

script.SetRemoteValue = {
  type: "set",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue
}

script.WeakMapRemoteValue = {
  type: "weakmap",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.WeakSetRemoteValue = {
  type: "weakset",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.GeneratorRemoteValue = {
  type: "generator",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ErrorRemoteValue = {
  type: "error",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ProxyRemoteValue = {
  type: "proxy",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.PromiseRemoteValue = {
  type: "promise",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.TypedArrayRemoteValue = {
  type: "typedarray",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ArrayBufferRemoteValue = {
  type: "arraybuffer",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.NodeListRemoteValue = {
  type: "nodelist",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.HTMLCollectionRemoteValue = {
  type: "htmlcollection",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.NodeRemoteValue = {
  type: "node",
  ? sharedId: script.SharedId,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.NodeProperties,
}

script.NodeProperties = {
  nodeType: js-uint,
  childNodeCount: js-uint,
  ? attributes: {*text => text},
  ? children: [*script.NodeRemoteValue],
  ? localName: text,
  ? mode: "open" / "closed",
  ? namespaceURI: text,
  ? nodeValue: text,
  ? shadowRoot: script.NodeRemoteValue / null,
}

script.WindowProxyRemoteValue = {
  type: "window",
  value: script.WindowProxyProperties,
  ? handle: script.Handle,
  ? internalId: script.InternalId
}

script.WindowProxyProperties = {
  context: browsingContext.BrowsingContext
}

script.ResultOwnership = "root" / "none"

script.SerializationOptions = {
  ? maxDomDepth: (js-uint / null) .default 0,
  ? maxObjectDepth: (js-uint / null) .default null,
  ? includeShadowTree: ("none" / "open" / "all") .default "none",
}

script.SharedId = text;

script.StackFrame = {
  columnNumber: js-uint,
  functionName: text,
  lineNumber: js-uint,
  url: text,
}

script.StackTrace = {
  callFrames: [*script.StackFrame],
}

script.RealmTarget = {
  realm: script.Realm
}

script.ContextTarget = {
  context: browsingContext.BrowsingContext,
  ? sandbox: text
}

script.Target = (
  script.ContextTarget /
  script.RealmTarget
)

script.AddPreloadScript = (
  method: "script.addPreloadScript",
  params: script.AddPreloadScriptParameters
)

script.AddPreloadScriptParameters = {
  functionDeclaration: text,
  ? arguments: [*script.ChannelValue],
  ? contexts: [+browsingContext.BrowsingContext],
  ? userContexts: [+browser.UserContext],
  ? sandbox: text
}

script.Disown = (
  method: "script.disown",
  params: script.DisownParameters
)

script.DisownParameters = {
  handles: [*script.Handle]
  target: script.Target;
}

script.CallFunction = (
  method: "script.callFunction",
  params: script.CallFunctionParameters
)

script.CallFunctionParameters = {
  functionDeclaration: text,
  awaitPromise: bool,
  target: script.Target,
  ? arguments: [*script.LocalValue],
  ? resultOwnership: script.ResultOwnership,
  ? serializationOptions: script.SerializationOptions,
  ? this: script.LocalValue,
  ? userActivation: bool .default false,
}

script.Evaluate = (
  method: "script.evaluate",
  params: script.EvaluateParameters
)

script.EvaluateParameters = {
  expression: text,
  target: script.Target,
  awaitPromise: bool,
  ? resultOwnership: script.ResultOwnership,
  ? serializationOptions: script.SerializationOptions,
  ? userActivation: bool .default false,
}

script.GetRealms = (
  method: "script.getRealms",
  params: script.GetRealmsParameters
)

script.GetRealmsParameters = {
  ? context: browsingContext.BrowsingContext,
  ? type: script.RealmType,
}

script.RemovePreloadScript = (
  method: "script.removePreloadScript",
  params: script.RemovePreloadScriptParameters
)

script.RemovePreloadScriptParameters = {
  script: script.PreloadScript
}

StorageCommand = (
  storage.DeleteCookies //
  storage.GetCookies //
  storage.SetCookie
)

storage.PartitionKey = {
  ? userContext: text,
  ? sourceOrigin: text,
  Extensible,
}

storage.GetCookies = (
  method: "storage.getCookies",
  params: storage.GetCookiesParameters
)


storage.CookieFilter = {
  ? name: text,
  ? value: network.BytesValue,
  ? domain: text,
  ? path: text,
  ? size: js-uint,
  ? httpOnly: bool,
  ? secure: bool,
  ? sameSite: network.SameSite,
  ? expiry: js-uint,
  Extensible,
}

storage.BrowsingContextPartitionDescriptor = {
  type: "context",
  context: browsingContext.BrowsingContext
}

storage.StorageKeyPartitionDescriptor = {
  type: "storageKey",
  ? userContext: text,
  ? sourceOrigin: text,
  Extensible,
}

storage.PartitionDescriptor = (
  storage.BrowsingContextPartitionDescriptor /
  storage.StorageKeyPartitionDescriptor
)

storage.GetCookiesParameters = {
  ? filter: storage.CookieFilter,
  ? partition: storage.PartitionDescriptor,
}

storage.SetCookie = (
  method: "storage.setCookie",
  params: storage.SetCookieParameters,
)


storage.PartialCookie = {
  name: text,
  value: network.BytesValue,
  domain: text,
  ? path: text,
  ? httpOnly: bool,
  ? secure: bool,
  ? sameSite: network.SameSite,
  ? expiry: js-uint,
  Extensible,
}

storage.SetCookieParameters = {
  cookie: storage.PartialCookie,
  ? partition: storage.PartitionDescriptor,
}

storage.DeleteCookies = (
  method: "storage.deleteCookies",
  params: storage.DeleteCookiesParameters,
)

storage.DeleteCookiesParameters = {
  ? filter: storage.CookieFilter,
  ? partition: storage.PartitionDescriptor,
}

InputCommand = (
  input.PerformActions //
  input.ReleaseActions //
  input.SetFiles
)

input.ElementOrigin = {
  type: "element",
  element: script.SharedReference
}

input.PerformActions = (
  method: "input.performActions",
  params: input.PerformActionsParameters
)

input.PerformActionsParameters = {
  context: browsingContext.BrowsingContext,
  actions: [*input.SourceActions]
}

input.SourceActions = (
  input.NoneSourceActions /
  input.KeySourceActions /
  input.PointerSourceActions /
  input.WheelSourceActions
)

input.NoneSourceActions = {
  type: "none",
  id: text,
  actions: [*input.NoneSourceAction]
}

input.NoneSourceAction = input.PauseAction

input.KeySourceActions = {
  type: "key",
  id: text,
  actions: [*input.KeySourceAction]
}

input.KeySourceAction = (
  input.PauseAction /
  input.KeyDownAction /
  input.KeyUpAction
)

input.PointerSourceActions = {
  type: "pointer",
  id: text,
  ? parameters: input.PointerParameters,
  actions: [*input.PointerSourceAction]
}

input.PointerType = "mouse" / "pen" / "touch"

input.PointerParameters = {
  ? pointerType: input.PointerType .default "mouse"
}

input.PointerSourceAction = (
  input.PauseAction /
  input.PointerDownAction /
  input.PointerUpAction /
  input.PointerMoveAction
)

input.WheelSourceActions = {
  type: "wheel",
  id: text,
  actions: [*input.WheelSourceAction]
}

input.WheelSourceAction = (
  input.PauseAction /
  input.WheelScrollAction
)

input.PauseAction = {
  type: "pause",
  ? duration: js-uint
}

input.KeyDownAction = {
  type: "keyDown",
  value: text
}

input.KeyUpAction = {
  type: "keyUp",
  value: text
}

input.PointerUpAction = {
  type: "pointerUp",
  button: js-uint,
}

input.PointerDownAction = {
  type: "pointerDown",
  button: js-uint,
  input.PointerCommonProperties
}

input.PointerMoveAction = {
  type: "pointerMove",
  x: float,
  y: float,
  ? duration: js-uint,
  ? origin: input.Origin,
  input.PointerCommonProperties
}

input.WheelScrollAction = {
  type: "scroll",
  x: js-int,
  y: js-int,
  deltaX: js-int,
  deltaY: js-int,
  ? duration: js-uint,
  ? origin: input.Origin .default "viewport",
}

input.PointerCommonProperties = (
  ? width: js-uint,
  ? height: js-uint,
  ? pressure: (0.0..1.0),
  ? tangentialPressure: (-1.0..1.0),
  ? twist: (0..359),
  ; 0 .. Math.PI / 2
  ? altitudeAngle: (0.0..1.5707963267948966),
  ; 0 .. 2 * Math.PI
  ? azimuthAngle: (0.0..6.283185307179586),
)

input.Origin = "viewport" / "pointer" / input.ElementOrigin

input.ReleaseActions = (
  method: "input.releaseActions",
  params: input.ReleaseActionsParameters
)

input.ReleaseActionsParameters = {
  context: browsingContext.BrowsingContext,
}

input.SetFiles = (
  method: "input.setFiles",
  params: input.SetFilesParameters
)

input.SetFilesParameters = {
  context: browsingContext.BrowsingContext,
  element: script.SharedReference,
  files: [*text]
}

WebExtensionCommand = (
  webExtension.Install //
  webExtension.Uninstall
)

webExtension.Extension = text

webExtension.Install = (
   method: "webExtension.install",
   params: webExtension.InstallParameters
)

webExtension.InstallParameters = {
   extensionData: webExtension.ExtensionData,
}

webExtension.ExtensionData = (
   webExtension.ExtensionArchivePath /
   webExtension.ExtensionBase64Encoded /
   webExtension.ExtensionPath
)

webExtension.ExtensionPath = {
   type: "path",
   path: text,
}

webExtension.ExtensionArchivePath = {
   type: "archivePath",
   path: text,
}

webExtension.ExtensionBase64Encoded = {
   type: "base64",
   value: text,
}

webExtension.Uninstall = (
   method: "webExtension.uninstall",
   params: webExtension.UninstallParameters
)

webExtension.UninstallParameters = {
   extension: webExtension.Extension,
}

Local end definition

Message = (
  CommandResponse /
  ErrorResponse /
  Event
)

CommandResponse = {
  type: "success",
  id: js-uint,
  result: ResultData,
  Extensible
}

ErrorResponse = {
  type: "error",
  id: js-uint / null,
  error: ErrorCode,
  message: text,
  ? stacktrace: text,
  Extensible
}

ResultData = (
  BrowserResult /
  BrowsingContextResult /
  EmulationResult /
  InputResult /
  NetworkResult /
  ScriptResult /
  SessionResult /
  StorageResult /
  WebExtensionResult
)

EmptyResult = {
  Extensible
}

Event = {
  type: "event",
  EventData,
  Extensible
}

EventData = (
  BrowsingContextEvent //
  InputEvent //
  LogEvent //
  NetworkEvent //
  ScriptEvent
)

Extensible = (*text => any)

js-int = -9007199254740991..9007199254740991
js-uint = 0..9007199254740991

ErrorCode = "invalid argument" /
            "invalid selector" /
            "invalid session id" /
            "invalid web extension" /
            "move target out of bounds" /
            "no such alert" /
            "no such network collector" /
            "no such element" /
            "no such frame" /
            "no such handle" /
            "no such history entry" /
            "no such intercept" /
            "no such network data" /
            "no such node" /
            "no such request" /
            "no such screencast" /
            "no such script" /
            "no such storage partition" /
            "no such user context" /
            "no such web extension" /
            "session not created" /
            "unable to capture screen" /
            "unable to close browser" /
            "unable to set cookie" /
            "unable to set file input" /
            "unavailable network data" /
            "underspecified storage partition" /
            "unknown command" /
            "unknown error" /
            "unsupported operation"

SessionResult = (
  session.EndResult /
  session.NewResult /
  session.StatusResult /
  session.SubscribeResult /
  session.UnsubscribeResult
)

session.CapabilitiesRequest = {
  ? alwaysMatch: session.CapabilityRequest,
  ? firstMatch: [*session.CapabilityRequest]
}

session.CapabilityRequest = {
  ? acceptInsecureCerts: bool,
  ? browserName: text,
  ? browserVersion: text,
  ? platformName: text,
  ? proxy: session.ProxyConfiguration,
  ? unhandledPromptBehavior: session.UserPromptHandler,
  Extensible
}

session.ProxyConfiguration = {
   session.AutodetectProxyConfiguration //
   session.DirectProxyConfiguration //
   session.ManualProxyConfiguration //
   session.PacProxyConfiguration //
   session.SystemProxyConfiguration
}

session.AutodetectProxyConfiguration = (
   proxyType: "autodetect",
   Extensible
)

session.DirectProxyConfiguration = (
   proxyType: "direct",
   Extensible
)

session.ManualProxyConfiguration = (
   proxyType: "manual",
   ? httpProxy: text,
   ? sslProxy: text,
   ? session.SocksProxyConfiguration,
   ? noProxy: [*text],
   Extensible
)

session.SocksProxyConfiguration = (
   socksProxy: text,
   socksVersion: 0..255,
)

session.PacProxyConfiguration = (
   proxyType: "pac",
   proxyAutoconfigUrl: text,
   Extensible
)

session.SystemProxyConfiguration = (
   proxyType: "system",
   Extensible
)


session.UserPromptHandler = {
  ? alert: session.UserPromptHandlerType,
  ? beforeUnload: session.UserPromptHandlerType,
  ? confirm: session.UserPromptHandlerType,
  ? default: session.UserPromptHandlerType,
  ? file: session.UserPromptHandlerType,
  ? prompt: session.UserPromptHandlerType,
}

session.UserPromptHandlerType = "accept" / "dismiss" / "ignore";

session.Subscription = text

session.StatusResult = {
  ready: bool,
  message: text,
}

session.NewResult = {
  sessionId: text,
  capabilities: {
    acceptInsecureCerts: bool,
    browserName: text,
    browserVersion: text,
    platformName: text,
    setWindowRect: bool,
    userAgent: text,
    ? proxy: session.ProxyConfiguration,
    ? unhandledPromptBehavior: session.UserPromptHandler,
    ? webSocketUrl: text,
    Extensible
  }
}

session.EndResult = EmptyResult

session.SubscribeResult = {
  subscription: session.Subscription,
}

session.UnsubscribeResult = EmptyResult

BrowserResult = (
  browser.CloseResult /
  browser.CreateUserContextResult /
  browser.GetClientWindowsResult /
  browser.GetUserContextsResult /
  browser.RemoveUserContextResult /
  browser.SetClientWindowStateResult /
  browser.SetDownloadBehaviorResult
)

browser.ClientWindow = text;

browser.ClientWindowInfo = {
  active: bool,
  clientWindow: browser.ClientWindow,
  height: js-uint,
  state: "fullscreen" / "maximized" / "minimized" / "normal",
  width: js-uint,
  x: js-int,
  y: js-int,
}

browser.UserContext = text;

browser.UserContextInfo = {
  userContext: browser.UserContext
}

browser.CloseResult = EmptyResult

browser.CreateUserContextResult = browser.UserContextInfo

browser.GetClientWindowsResult = {
  clientWindows: [ * browser.ClientWindowInfo]
}

browser.GetUserContextsResult = {
  userContexts: [ + browser.UserContextInfo]
}

browser.RemoveUserContextResult = EmptyResult

browser.SetClientWindowStateResult = browser.ClientWindowInfo

browser.SetDownloadBehaviorResult = EmptyResult

BrowsingContextResult = (
  browsingContext.ActivateResult /
  browsingContext.CaptureScreenshotResult /
  browsingContext.CloseResult /
  browsingContext.CreateResult /
  browsingContext.GetTreeResult /
  browsingContext.HandleUserPromptResult /
  browsingContext.LocateNodesResult /
  browsingContext.NavigateResult /
  browsingContext.PrintResult /
  browsingContext.ReloadResult /
  browsingContext.SetBypassCSPResult /
  browsingContext.SetViewportResult /
  browsingContext.StartScreencastResult /
  browsingContext.StopScreencastResult /
  browsingContext.TraverseHistoryResult
)

BrowsingContextEvent = (
  browsingContext.ContextCreated //
  browsingContext.ContextDestroyed //
  browsingContext.DomContentLoaded //
  browsingContext.DownloadEnd //
  browsingContext.DownloadWillBegin //
  browsingContext.FragmentNavigated //
  browsingContext.HistoryUpdated //
  browsingContext.Load //
  browsingContext.NavigationAborted //
  browsingContext.NavigationCommitted //
  browsingContext.NavigationFailed //
  browsingContext.NavigationStarted //
  browsingContext.UserPromptClosed //
  browsingContext.UserPromptOpened
)

browsingContext.BrowsingContext = text;

browsingContext.InfoList = [*browsingContext.Info]

browsingContext.Info = {
  children: browsingContext.InfoList / null,
  clientWindow: browser.ClientWindow,
  context: browsingContext.BrowsingContext,
  originalOpener: browsingContext.BrowsingContext / null,
  url: text,
  userContext: browser.UserContext,
  ? parent: browsingContext.BrowsingContext / null,
}

browsingContext.Locator = (
   browsingContext.AccessibilityLocator /
   browsingContext.CssLocator /
   browsingContext.ContextLocator /
   browsingContext.InnerTextLocator /
   browsingContext.XPathLocator
)

browsingContext.AccessibilityLocator = {
   type: "accessibility",
   value: {
    ? name: text,
    ? role: text,
   }
}

browsingContext.CssLocator = {
   type: "css",
   value: text
}

browsingContext.ContextLocator = {
  type: "context",
  value: {
    context: browsingContext.BrowsingContext,
  }
}

browsingContext.InnerTextLocator = {
   type: "innerText",
   value: text,
   ? ignoreCase: bool
   ? matchType: "full" / "partial",
   ? maxDepth: js-uint,
}

browsingContext.XPathLocator = {
   type: "xpath",
   value: text
}

browsingContext.Navigation = text;

browsingContext.Download = text;

browsingContext.BaseNavigationInfo = (
  context: browsingContext.BrowsingContext,
  navigation: browsingContext.Navigation / null,
  timestamp: js-uint,
  url: text,
  ? userContext: browser.UserContext,
)

browsingContext.NavigationInfo = {
  browsingContext.BaseNavigationInfo
}

browsingContext.UserPromptType = "alert" / "beforeunload" / "confirm" / "prompt";

browsingContext.ActivateResult = EmptyResult

browsingContext.CaptureScreenshotResult = {
  data: text
}

browsingContext.CloseResult = EmptyResult

browsingContext.CreateResult = {
  context: browsingContext.BrowsingContext,
  ? userContext: browser.UserContext
}

browsingContext.GetTreeResult = {
  contexts: browsingContext.InfoList
}

browsingContext.HandleUserPromptResult = EmptyResult

browsingContext.LocateNodesResult = {
    nodes: [ * script.NodeRemoteValue ]
}

browsingContext.NavigateResult = {
  navigation: browsingContext.Navigation / null,
  url: text,
}

browsingContext.PrintResult = {
  data: text
}

browsingContext.ReloadResult = browsingContext.NavigateResult

browsingContext.SetBypassCSPResult = EmptyResult

browsingContext.SetViewportResult = EmptyResult

browsingContext.StartScreencastResult = {
   screencast: browsingContext.Screencast,
   path: text
}


browsingContext.Screencast = text

browsingContext.StopScreencastResult = {
   path: text,
   ? error: text
}

browsingContext.TraverseHistoryResult = EmptyResult

browsingContext.ContextCreated = (
 method: "browsingContext.contextCreated",
 params: browsingContext.Info
)

browsingContext.ContextDestroyed = (
 method: "browsingContext.contextDestroyed",
 params: browsingContext.Info
)

browsingContext.NavigationStarted = (
 method: "browsingContext.navigationStarted",
 params: browsingContext.NavigationInfo
)

browsingContext.FragmentNavigated = (
 method: "browsingContext.fragmentNavigated",
 params: browsingContext.NavigationInfo
)

browsingContext.HistoryUpdated = (
  method: "browsingContext.historyUpdated",
  params: browsingContext.HistoryUpdatedParameters
)

browsingContext.HistoryUpdatedParameters = {
  context: browsingContext.BrowsingContext,
  timestamp: js-uint,
  url: text,
  ? userContext: browser.UserContext
}

browsingContext.DomContentLoaded = (
 method: "browsingContext.domContentLoaded",
 params: browsingContext.NavigationInfo
)

browsingContext.Load = (
 method: "browsingContext.load",
 params: browsingContext.NavigationInfo
)

browsingContext.DownloadWillBegin = (
 method: "browsingContext.downloadWillBegin",
 params: browsingContext.DownloadWillBeginParams
)

browsingContext.DownloadWillBeginParams = {
  download: browsingContext.Download,
  suggestedFilename: text,
  browsingContext.BaseNavigationInfo
}

browsingContext.DownloadEnd = (
  method: "browsingContext.downloadEnd",
  params: browsingContext.DownloadEndParams
)

browsingContext.DownloadEndParams = {
  (
    browsingContext.DownloadCanceledParams //
    browsingContext.DownloadCompleteParams
  )
}

browsingContext.DownloadCanceledParams = (
  status: "canceled",
  download: browsingContext.Download,
  browsingContext.BaseNavigationInfo
)

browsingContext.DownloadCompleteParams = (
  status: "complete",
  download: browsingContext.Download,
  filepath: text / null,
  browsingContext.BaseNavigationInfo
)

browsingContext.NavigationAborted = (
 method: "browsingContext.navigationAborted",
 params: browsingContext.NavigationInfo
)

browsingContext.NavigationCommitted = (
 method: "browsingContext.navigationCommitted",
 params: browsingContext.NavigationInfo
)

browsingContext.NavigationFailed = (
 method: "browsingContext.navigationFailed",
 params: browsingContext.NavigationInfo
)

browsingContext.UserPromptClosed = (
  method: "browsingContext.userPromptClosed",
  params: browsingContext.UserPromptClosedParameters
)

browsingContext.UserPromptClosedParameters = {
  context: browsingContext.BrowsingContext,
  accepted: bool,
  type: browsingContext.UserPromptType,
  ? userContext: browser.UserContext,
  ? userText: text
}

browsingContext.UserPromptOpened = (
  method: "browsingContext.userPromptOpened",
  params: browsingContext.UserPromptOpenedParameters
)

browsingContext.UserPromptOpenedParameters = {
  context: browsingContext.BrowsingContext,
  handler: session.UserPromptHandlerType,
  message: text,
  type: browsingContext.UserPromptType,
  ? userContext: browser.UserContext,
  ? defaultValue: text
}

EmulationResult = (
  emulation.SetForcedColorsModeThemeOverrideResult /
  emulation.SetGeolocationOverrideResult /
  emulation.SetLocaleOverrideResult /
  emulation.SetScreenOrientationOverrideResult /
  emulation.SetScriptingEnabledResult /
  emulation.SetScrollbarTypeOverrideResult /
  emulation.SetTimezoneOverrideResult /
  emulation.SetTouchOverrideResult /
  emulation.SetUserAgentOverrideResult
)

emulation.SetForcedColorsModeThemeOverrideResult = EmptyResult

emulation.SetGeolocationOverrideResult = EmptyResult

emulation.SetLocaleOverrideResult = EmptyResult

emulation.SetNetworkConditionsResult = EmptyResult

emulation.SetScreenSettingsOverrideResult = EmptyResult

emulation.SetScreenOrientationOverrideResult = EmptyResult

emulation.SetUserAgentOverrideResult = EmptyResult

emulation.SetScriptingEnabledResult = EmptyResult

emulation.SetScrollbarTypeOverrideResult = EmptyResult

emulation.SetTimezoneOverrideResult = EmptyResult

emulation.SetTouchOverrideResult = EmptyResult

NetworkResult = (
  network.AddDataCollectorResult /
  network.AddInterceptResult /
  network.ContinueRequestResult /
  network.ContinueResponseResult /
  network.ContinueWithAuthResult /
  network.DisownDataResult /
  network.FailRequestResult /
  network.GetDataResult /
  network.ProvideResponseResult /
  network.RemoveDataCollectorResult /
  network.RemoveInterceptResult /
  network.SetCacheBehaviorResult /
  network.SetExtraHeadersResult
)

NetworkEvent = (
    network.AuthRequired //
    network.BeforeRequestSent //
    network.FetchError //
    network.ResponseCompleted //
    network.ResponseStarted
)


network.AuthChallenge = {
  scheme: text,
  realm: text,
}

network.BaseParameters = (
    context: browsingContext.BrowsingContext / null,
    isBlocked: bool,
    navigation: browsingContext.Navigation / null,
    redirectCount: js-uint,
    request: network.RequestData,
    timestamp: js-uint,
    ? userContext: browser.UserContext / null,
    ? intercepts: [+network.Intercept]
)

network.BytesValue = network.StringValue / network.Base64Value;

network.StringValue = {
  type: "string",
  value: text,
}

network.Base64Value = {
  type: "base64",
  value: text,
}

network.Collector = text

network.CollectorType = "blob"

network.SameSite = "strict" / "lax" / "none" / "default"


network.Cookie = {
    name: text,
    value: network.BytesValue,
    domain: text,
    path: text,
    size: js-uint,
    httpOnly: bool,
    secure: bool,
    sameSite: network.SameSite,
    ? expiry: js-uint,
    Extensible,
}

network.DataType = "request" / "response"

network.FetchTimingInfo = {
    timeOrigin: float,
    requestTime: float,
    redirectStart: float,
    redirectEnd: float,
    fetchStart: float,
    dnsStart: float,
    dnsEnd: float,
    connectStart: float,
    connectEnd: float,
    tlsStart: float,

    requestStart: float,
    responseStart: float,

    responseEnd: float,
}

network.Header = {
  name: text,
  value: network.BytesValue,
}

network.Initiator = {
    ? columnNumber: js-uint,
    ? lineNumber: js-uint,
    ? request: network.Request,
    ? stackTrace: script.StackTrace,
    ? type: "parser" / "script" / "preflight" / "other"
}

network.Intercept = text

network.Request = text;

network.RequestData = {
    request: network.Request,
    url: text,
    method: text,
    headers: [*network.Header],
    cookies: [*network.Cookie],
    headersSize: js-uint,
    bodySize: js-uint / null,
    destination: text,
    initiatorType: text / null,
    timings: network.FetchTimingInfo,
}

network.ResponseContent = {
    size: js-uint
}

network.ResponseData = {
    url: text,
    protocol: text,
    status: js-uint,
    statusText: text,
    fromCache: bool,
    headers: [*network.Header],
    mimeType: text,
    bytesReceived: js-uint,
    headersSize: js-uint / null,
    bodySize: js-uint / null,
    content: network.ResponseContent,
    ?authChallenges: [*network.AuthChallenge],
}

network.AddDataCollectorResult = {
  collector: network.Collector
}

network.AddInterceptResult = {
  intercept: network.Intercept
}

network.ContinueRequestResult = EmptyResult

network.ContinueResponseResult = EmptyResult

network.ContinueWithAuthResult = EmptyResult

network.DisownDataResult = EmptyResult

network.FailRequestResult = EmptyResult

network.GetDataResult = {
  bytes: network.BytesValue,
}

network.ProvideResponseResult = EmptyResult

network.RemoveDataCollectorResult = EmptyResult

network.RemoveInterceptResult = EmptyResult

network.SetCacheBehaviorResult = EmptyResult

network.SetExtraHeadersResult = EmptyResult

network.AuthRequired = (
  method: "network.authRequired",
  params: network.AuthRequiredParameters
)

network.AuthRequiredParameters = {
  network.BaseParameters,
  response: network.ResponseData
}

network.BeforeRequestSent = (
  method: "network.beforeRequestSent",
  params: network.BeforeRequestSentParameters
 )

network.BeforeRequestSentParameters = {
  network.BaseParameters,
  ? initiator: network.Initiator,
}

network.FetchError = (
  method: "network.fetchError",
  params: network.FetchErrorParameters
 )

network.FetchErrorParameters = {
  network.BaseParameters,
  errorText: text,
}

network.ResponseCompleted = (
  method: "network.responseCompleted",
  params: network.ResponseCompletedParameters
 )

network.ResponseCompletedParameters = {
  network.BaseParameters,
  response: network.ResponseData,
}

network.ResponseStarted = (
  method: "network.responseStarted",
  params: network.ResponseStartedParameters
 )

network.ResponseStartedParameters = {
  network.BaseParameters,
  response: network.ResponseData,
}

ScriptResult = (
  script.AddPreloadScriptResult /
  script.CallFunctionResult /
  script.DisownResult /
  script.EvaluateResult /
  script.GetRealmsResult /
  script.RemovePreloadScriptResult
)

ScriptEvent = (
  script.Message //
  script.RealmCreated //
  script.RealmDestroyed
)

script.Channel = text;

script.ChannelValue = {
  type: "channel",
  value: script.ChannelProperties,
}

script.ChannelProperties = {
  channel: script.Channel,
  ? serializationOptions: script.SerializationOptions,
  ? ownership: script.ResultOwnership,
}

script.EvaluateResult = (
  script.EvaluateResultSuccess /
  script.EvaluateResultException
)

script.EvaluateResultSuccess = {
  type: "success",
  result: script.RemoteValue,
  realm: script.Realm
}

script.EvaluateResultException = {
  type: "exception",
  exceptionDetails: script.ExceptionDetails
  realm: script.Realm
}

script.ExceptionDetails = {
  columnNumber: js-uint,
  exception: script.RemoteValue,
  lineNumber: js-uint,
  stackTrace: script.StackTrace,
  text: text,
}

script.Handle = text;

script.InternalId = text;

script.LocalValue = (
  script.RemoteReference /
  script.PrimitiveProtocolValue /
  script.ChannelValue /
  script.ArrayLocalValue /
  { script.DateLocalValue } /
  script.MapLocalValue /
  script.ObjectLocalValue /
  { script.RegExpLocalValue } /
  script.SetLocalValue
)

script.ListLocalValue = [*script.LocalValue];

script.ArrayLocalValue = {
  type: "array",
  value: script.ListLocalValue,
}

script.DateLocalValue = (
  type: "date",
  value: text
)

script.MappingLocalValue = [*[(script.LocalValue / text), script.LocalValue]];

script.MapLocalValue = {
  type: "map",
  value: script.MappingLocalValue,
}

script.ObjectLocalValue = {
  type: "object",
  value: script.MappingLocalValue,
}

script.RegExpValue = {
  pattern: text,
  ? flags: text,
}

script.RegExpLocalValue = (
  type: "regexp",
  value: script.RegExpValue,
)

script.SetLocalValue = {
  type: "set",
  value: script.ListLocalValue,
}

script.PreloadScript = text;

script.Realm = text;

script.PrimitiveProtocolValue = (
  script.UndefinedValue /
  script.NullValue /
  script.StringValue /
  script.NumberValue /
  script.BooleanValue /
  script.BigIntValue
)

script.UndefinedValue = {
  type: "undefined",
}

script.NullValue = {
  type: "null",
}

script.StringValue = {
  type: "string",
  value: text,
}

script.SpecialNumber = "NaN" / "-0" / "Infinity" / "-Infinity";

script.NumberValue = {
  type: "number",
  value: number / script.SpecialNumber,
}

script.BooleanValue = {
  type: "boolean",
  value: bool,
}

script.BigIntValue = {
  type: "bigint",
  value: text,
}

script.RealmInfo = (
  script.WindowRealmInfo /
  script.DedicatedWorkerRealmInfo /
  script.SharedWorkerRealmInfo /
  script.ServiceWorkerRealmInfo /
  script.WorkerRealmInfo /
  script.PaintWorkletRealmInfo /
  script.AudioWorkletRealmInfo /
  script.WorkletRealmInfo
)

script.BaseRealmInfo = (
  realm: script.Realm,
  origin: text
)

script.WindowRealmInfo = {
  script.BaseRealmInfo,
  type: "window",
  context: browsingContext.BrowsingContext,
  ? userContext: browser.UserContext,
  ? sandbox: text
}

script.DedicatedWorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "dedicated-worker",
  owners: [script.Realm]
}

script.SharedWorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "shared-worker"
}

script.ServiceWorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "service-worker"
}

script.WorkerRealmInfo = {
  script.BaseRealmInfo,
  type: "worker"
}

script.PaintWorkletRealmInfo = {
  script.BaseRealmInfo,
  type: "paint-worklet"
}

script.AudioWorkletRealmInfo = {
  script.BaseRealmInfo,
  type: "audio-worklet"
}

script.WorkletRealmInfo = {
  script.BaseRealmInfo,
  type: "worklet"
}

script.RealmType = "window" / "dedicated-worker" / "shared-worker" / "service-worker" /
                   "worker" / "paint-worklet" / "audio-worklet" / "worklet"

script.RemoteReference = (
  script.SharedReference /
  script.RemoteObjectReference
)

script.SharedReference = {
   sharedId: script.SharedId

   ? handle: script.Handle,
   Extensible
}

script.RemoteObjectReference = {
   handle: script.Handle,

   ? sharedId: script.SharedId
   Extensible
}

script.RemoteValue = (
  script.PrimitiveProtocolValue /
  script.SymbolRemoteValue /
  script.ArrayRemoteValue /
  script.ObjectRemoteValue /
  script.FunctionRemoteValue /
  script.RegExpRemoteValue /
  script.DateRemoteValue /
  script.MapRemoteValue /
  script.SetRemoteValue /
  script.WeakMapRemoteValue /
  script.WeakSetRemoteValue /
  script.GeneratorRemoteValue /
  script.ErrorRemoteValue /
  script.ProxyRemoteValue /
  script.PromiseRemoteValue /
  script.TypedArrayRemoteValue /
  script.ArrayBufferRemoteValue /
  script.NodeListRemoteValue /
  script.HTMLCollectionRemoteValue /
  script.NodeRemoteValue /
  script.WindowProxyRemoteValue
)

script.ListRemoteValue = [*script.RemoteValue];

script.MappingRemoteValue = [*[(script.RemoteValue / text), script.RemoteValue]];

script.SymbolRemoteValue = {
  type: "symbol",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ArrayRemoteValue = {
  type: "array",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.ObjectRemoteValue = {
  type: "object",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.MappingRemoteValue,
}

script.FunctionRemoteValue = {
  type: "function",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.RegExpRemoteValue = {
  script.RegExpLocalValue,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.DateRemoteValue = {
  script.DateLocalValue,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.MapRemoteValue = {
  type: "map",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.MappingRemoteValue,
}

script.SetRemoteValue = {
  type: "set",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue
}

script.WeakMapRemoteValue = {
  type: "weakmap",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.WeakSetRemoteValue = {
  type: "weakset",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.GeneratorRemoteValue = {
  type: "generator",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ErrorRemoteValue = {
  type: "error",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ProxyRemoteValue = {
  type: "proxy",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.PromiseRemoteValue = {
  type: "promise",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.TypedArrayRemoteValue = {
  type: "typedarray",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.ArrayBufferRemoteValue = {
  type: "arraybuffer",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
}

script.NodeListRemoteValue = {
  type: "nodelist",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.HTMLCollectionRemoteValue = {
  type: "htmlcollection",
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.ListRemoteValue,
}

script.NodeRemoteValue = {
  type: "node",
  ? sharedId: script.SharedId,
  ? handle: script.Handle,
  ? internalId: script.InternalId,
  ? value: script.NodeProperties,
}

script.NodeProperties = {
  nodeType: js-uint,
  childNodeCount: js-uint,
  ? attributes: {*text => text},
  ? children: [*script.NodeRemoteValue],
  ? localName: text,
  ? mode: "open" / "closed",
  ? namespaceURI: text,
  ? nodeValue: text,
  ? shadowRoot: script.NodeRemoteValue / null,
}

script.WindowProxyRemoteValue = {
  type: "window",
  value: script.WindowProxyProperties,
  ? handle: script.Handle,
  ? internalId: script.InternalId
}

script.WindowProxyProperties = {
  context: browsingContext.BrowsingContext
}

script.ResultOwnership = "root" / "none"

script.SerializationOptions = {
  ? maxDomDepth: (js-uint / null) .default 0,
  ? maxObjectDepth: (js-uint / null) .default null,
  ? includeShadowTree: ("none" / "open" / "all") .default "none",
}

script.SharedId = text;

script.StackFrame = {
  columnNumber: js-uint,
  functionName: text,
  lineNumber: js-uint,
  url: text,
}

script.StackTrace = {
  callFrames: [*script.StackFrame],
}

script.Source = {
  realm: script.Realm,
  ? context: browsingContext.BrowsingContext,
  ? userContext: browser.UserContext
}

script.AddPreloadScriptResult = {
  script: script.PreloadScript
}

script.DisownResult = EmptyResult

script.CallFunctionResult = script.EvaluateResult

script.GetRealmsResult = {
  realms: [*script.RealmInfo]
}

script.RemovePreloadScriptResult = EmptyResult

script.Message = (
  method: "script.message",
  params: script.MessageParameters
 )

script.MessageParameters = {
  channel: script.Channel,
  data: script.RemoteValue,
  source: script.Source,
}

script.RealmCreated = (
 method: "script.realmCreated",
 params: script.RealmInfo
)

script.RealmDestroyed = (
  method: "script.realmDestroyed",
  params: script.RealmDestroyedParameters
)

script.RealmDestroyedParameters = {
  realm: script.Realm
}


StorageResult = (
  storage.DeleteCookiesResult /
  storage.GetCookiesResult /
  storage.SetCookieResult
)

storage.PartitionKey = {
  ? userContext: text,
  ? sourceOrigin: text,
  Extensible,
}

storage.GetCookiesResult = {
  cookies: [*network.Cookie],
  partitionKey: storage.PartitionKey,
}

storage.SetCookieResult = {
  partitionKey: storage.PartitionKey
}

storage.DeleteCookiesResult = {
  partitionKey: storage.PartitionKey
}

LogEvent = (
  log.EntryAdded
)

log.Level = "debug" / "info" / "warn" / "error"

log.Entry = (
  log.GenericLogEntry /
  log.ConsoleLogEntry /
  log.JavascriptLogEntry
)

log.BaseLogEntry = (
  level: log.Level,
  source: script.Source,
  text: text / null,
  timestamp: js-uint,
  ? stackTrace: script.StackTrace,
)

log.GenericLogEntry = {
  log.BaseLogEntry,
  type: text,
}

log.ConsoleLogEntry = {
  log.BaseLogEntry,
  type: "console",
  method: text,
  args: [*script.RemoteValue],
}

log.JavascriptLogEntry = {
  log.BaseLogEntry,
  type: "javascript",
}

log.EntryAdded = (
 method: "log.entryAdded",
 params: log.Entry,
)

InputResult = (
  input.PerformActionsResult /
  input.ReleaseActionsResult /
  input.SetFilesResult
)

InputEvent = (
  input.FileDialogOpened
)

input.PerformActionsResult = EmptyResult

input.ReleaseActionsResult = EmptyResult

input.SetFilesResult = EmptyResult

input.FileDialogOpened = (
   method: "input.fileDialogOpened",
   params: input.FileDialogInfo
)

input.FileDialogInfo = {
   context: browsingContext.BrowsingContext,
   ? userContext: browser.UserContext,
   ? element: script.SharedReference,
   multiple: bool,
}

WebExtensionResult = (
  webExtension.InstallResult /
  webExtension.UninstallResult
)

webExtension.Extension = text

webExtension.InstallResult = {
  extension: webExtension.Extension
}

webExtension.UninstallResult = EmptyResult

課題索引

この「event を待つ」ことを行うための、もっと良い mechanism がきっとあるはずだ。
これが event loop 上の他の tasks より前に実行されることを保証するために、 microtasks のようなものを持つべきか?
これは appendix にするべきか?
1 つの session に対して 2 つ以上の connection をサポートするか?
UTF-8 errors にどの status code が使用されるかを定義しているものはないように見える。
UA が望む場合に listener を閉じられるようにするため、session ending に hook in する必要がある。
sandbox realm の作成を定義する。これは window を wrap する SandboxWindowProxy を返すことになる。
SandboxProxy がどのように動作するかを詳細に定義する
これがどのように動作するかを定義する。
user context の concept または storage との interaction を形式的に定義する最良の方法であるかは不明。
null でない opener を持つ top-level traversables は、その opener と同じ associated user context を持つと 指定するべきか? これが既存の実装で強制されているものか確認する必要がある。
これはかなり不正確な言い方だが、connections の shutdown を開始する前に command への response を送信する、という intent が明確であることを期待する。
これは realms でも動作するように generalize する必要がある。
これは realms でも動作するように generalise する必要がある。
ignore cache flag がどのように動作するかを正確に指定する。これは、 resource の最初の load だけが cache を bypass するのか (すなわち、最初に cache を clear して通常どおり進めるのと同様なのか)、 それとも HTML parser によって直接 load されない resources (例えば scripts や stylesheets により開始される loads)も cache を bypass するのかを 考慮する必要がある。
ここで error により、何が失敗したのか、なぜ失敗したのかについて十分な情報を surface しているか? どの error code が望ましいか? local ends が実際に何が問題だったかを 把握するために implementation-defined strings を parse するような問題が起きるか?
これは update rendering algorithm に、より明示的な形で integrate されるべきである。
最後の top-level traversable を閉じるときの behavior について open discussion がある。 browser を閉じる、session を閉じる、またはこれを implementation に委ねることが考えられる。 [w3c/webdriver-bidi Issue #170]
これは update rendering algorithm に より明示的な形で integrate されるべきである。
記述されている algorithm には race condition がある。なぜなら、 target session history entry を navigate しようとする時点で、 それが存在しない可能性があるためである。history の navigate を待つことをサポートしたら、 これをより robust に処理できる。
`browsingContext.pageShow event を expose したいか? その場合、 bfcache restore のときだけでなく、`pageshow` が emit されることになるたびに これを call する必要があり、data に persisted status も追加する必要がある。
active documents を持つ browsing contexts に対してのみこの event を fire すべきかは不明である。 navigation は、contexts が inaccessible になるが bfcache のためにまだ discard されない、 ということも起こし得る。
この algorithm を screen orientation specification に移動する。
これは navigable に関連しない data の収集を防ぐ。 collector configuration に照らして確認するためには、依然として navigable を retrieve する必要があるが、 ここでは null も受け入れられる可能性がある。
これには auth を cancel する方法がない。
realm 以外の parameters も含めるべきか?
Fetch と同様、これは multiple headers、parsing issues などを扱う正しい方法か不明である。
context に加えて、request を開始した document node の `sharedId` を含めることを検討する。
"request already sent" error を検討する。
error の正確な種類を設定できるようにする [Issue #508]
Fetch の "HTTP-network-or-cache fetch" algorithm で return value を尊重する。
これは error code が間違っている
これは lone surrogates を処理しない
"stale object reference" case を処理する。
WASM types を追加するか?
WindowProxy は Node と同様の style で attributes を取得するべきか?
String / Number / etc. wrapper objects を特別に扱うか?
mirror objects の lifecycle を再検討する。
children と child nodes は異なるものである。childNodeCountchildNodes を reference するべきか、または childrenCount に rename するべきである。
これは error code が間違っている
これは error code が間違っている
TODO: script.evaluate で説明されているように timeout argument を追加する。
nested workers の場合など、realm parents も許可するようにこれを拡張するか? またはすべての ancestor workers を取得する。
literal match だけでなく、より sophisticated な filter system を持つことを望むかもしれない。
ここでの order はより明確に定義されるべきか?
これを browsing context または top-level traversable のどちらに基づいて key するか? 違いは、ある event が frame 内で発生し、その後 local end が top level navigable の log events に subscribe する前に、その frame が navigate された場合に何が起きるかにある。
さらに多くのものが logging を必要とする。CDP には LogEntryAdded types として xml, javascript, network, storage, appcache, rendering, security, deprecation, worker, violation, intervention, recommendation, other がある。これらは、 異なる methods により表される js exception および console API types に加えて存在する。
implementation-defined log types を許可する