From d433ae556e3c69f4a5928ecb05610aaebd04a256 Mon Sep 17 00:00:00 2001 From: James Graham Date: Fri, 29 Sep 2023 14:12:18 +0100 Subject: [PATCH 1/2] Make context/navigable id per session. Also make it clear that context ids actually relate to navigables, not browsing contexts. This part is a temporary workaround while the rest of the spec continues to pass in browsing contexts rather than navigables. --- index.bs | 498 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 294 insertions(+), 204 deletions(-) diff --git a/index.bs b/index.bs index b5588c13..eb9ae019 100644 --- a/index.bs +++ b/index.bs @@ -1321,7 +1321,7 @@ events are disabled, the return value is always empty. 1. For each |context id| in |browsing contexts|: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |context id|. 1. Let |top-level context| be the [=top-level browsing context=] for |context|. @@ -1804,7 +1804,15 @@ The [=remote end steps=] with |session| and command parameters ## The browsingContext Module ## {#module-browsingContext} The browsingContext module contains commands and -events relating to browsing contexts. +events relating to [=navigables=]. + +Note: For historic reasons this module is called browsingContext +rather than navigable, and the protocol uses the term +context to refer to navigables, particuarly as a field in command +and response parameters. + +Issue: Update the spec to use [=navigable=] consistently and remove +uses of [=/browsing context=]. The progress of navigation is communicated using an immutable WebDriver navigation status struct, which has the following items: @@ -1880,23 +1888,54 @@ BrowsingContextEvent = ( browsingContext.BrowsingContext = text; -Each [=/browsing context=] has an associated browsing context -id, which is a string uniquely identifying that browsing context. This is -implicitly set when the context is created. For browsing contexts with an -associated WebDriver [=window handle=] the [=/browsing context id=] must be the -same as the [=window handle=]. +A [=/navigable=] is associated with a context id, which is a +string uniquely identifying that browsing context within a specific [=bidi +session=]. + +A [=BiDi session=] has a context id map which is a weak map between +[=navigables=] and their corresponding [=context id=]. When the session is +created this map is empty.
-To get a browsing context given |context id|: +To get context id given |session| and |context|: + +1. Let |navigable| be |context|'s [=active document=]'s [=node document=]'s + [=node navigable=]. + +1. If |navigable| is null, return [=error=] with [=error code=] [=no such + frame=]. + + TODO: Once we change the callers to use navigables throughout the condition + will become unreachable. + +1. Let |context id map| be |session|'s [=context id map=]. + +1. If |context id map| doesn't [=map/contain=] |navigable|: + + 1. If |navigable| is a [=navigable/top-level traversable=] and |session| is a + [=HTTP session=], let |context id| be the [=window handle=] for + |navigable|. Othereise, let |context id| be a new, unique, string. + + 1. [=map/Set=] |context id map|[|navigable|] to |context id|. + +1. Return [=success=] with data |context id map|[|navigable|]. + +
+ +
+To get a browsing context given |session| and |context id|: 1. If |context id| is null, return [=success=] with data null. -1. If there is no browsing context with [=browsing context id=] |context id| return - [=error=] with [=error code=] [=no such frame=] +1. Let |context id map| be |session|'s [=context id map=]. + +1. For each |navigable| → |id| of |context id map|: + + 1. If |id| equals |context id|: -1. Let |context| be the browsing context with id |context id|. + 1. Return [=success=] with data |navigable|'s [=active browsing context=]. -1. Return [=success=] with data |context| +1. Return [=error=] with [=error code=] [=no such frame=]
@@ -1956,10 +1995,15 @@ TODO: make this return a list in document order
-To get the browsing context info given |context|, +To get the browsing context info given |session|, |context|, |max depth| and |is root|: -1. Let |context id| be the [=browsing context id=] for |context|. +1. Let |context id result| be [=get context id=] with |session| and |context|. + +1. Assert: |context id| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + +1. Set |context id| to |context id result|'s data. 1. Let |parent browsing context| be [=get the parent browsing context=] given |context|. @@ -1988,7 +2032,7 @@ To get the browsing context info given |context|, 1. For each |context| of |child contexts|: 1. Let |info| be the result of [=get the browsing context info=] given - |context|, |child depth|, and false. + |session|, |context|, |child depth|, and false. 1. Append |info| to |child infos| @@ -2117,9 +2161,15 @@ browsingContext.NavigationInfo = { The browsingContext.NavigationInfo type provides details of an ongoing navigation.
-To get the navigation info, given |context| and |navigation status|: +To get the navigation info, given |session|, |context| and |navigation status|: + +1. Let |context id result| be [=get context id=] with |session| and + |context|. -1. Let |context id| be the [=browsing context id=] for |context|. +1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + +1. Set |context id| to |context id result|'s data. 1. Let |navigation id| be |navigation status|'s id. @@ -2174,13 +2224,13 @@ The browsingContext.activate command activates an
-The [=remote end steps=] with |command parameters| are: - -1. Let |context id| be the value of the |command parameters|["context"] field. +The [=remote end steps=] with |session| and |command parameters| are: -1. Let |context| be the result of [=trying=] to [=get a browsing context=] with |context id|. +1. Let |context| be the result of [=trying=] to [=get a browsing context=] with + |session| and |command parameters|["context"]. -1. If |context| is not a [=top-level browsing context=], return [=error=] with [=error code=] [=invalid argument=]. +1. If |context| is not a [=top-level browsing context=], return [=error=] with + [=error code=] [=invalid argument=]. 1. Return [=activate a context=] with |context|. @@ -2367,12 +2417,10 @@ To render viewport to a canvas given |viewport| and |rect|:
-The [=remote end steps=] with session and |command parameters| are: - -1. Let |context id| be |command parameters|["context"]. +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"].. 1. If the implementation is unable to capture a screenshot of |context| for any reason then return [=error=] with [=error code=] [=unsupported operation=]. @@ -2477,13 +2525,10 @@ The browsingContext.close command closes a
-The [=remote end steps=] with |command parameters| are: - - 1. Let |context id| be the value of the context field of - |command parameters|. +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. Assert: |context| is not null. @@ -2535,7 +2580,7 @@ The browsingContext.create command creates a new
-The [=remote end steps=] with |command parameters| are: +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |type| be the value of the type field of |command parameters|. @@ -2544,7 +2589,7 @@ The [=remote end steps=] with |command parameters| are: field of |command parameters|, if present, or null otherwise. 1. If |reference context id| is not null, let |reference context| be the - result of [=trying=] to [=get a browsing context=] with + result of [=trying=] to [=get a browsing context=] with |session| and |reference context id|. Otherwise let |reference context| be null. 1. If |reference context| is not null and is not a [=top-level browsing context=], @@ -2587,8 +2632,8 @@ The [=remote end steps=] with |command parameters| are: Note: Do not invoke the [=/focusing steps=] for the created browsing context if background is true. - 1. Let |context id| be the [=browsing context id=] of the newly created - [=/browsing context=]. + 1. Let |context id| be the result of [=trying=] to [=get context id= with + |session| and the newly created [=/browsing context=]. 1. Let |body| be a [=/map=] matching the browsingContext.CreateResult production, with the context field set to |context id|. @@ -2629,7 +2674,7 @@ or all top-level contexts when no parent is provided.
-The [=remote end steps=] with session and |command parameters| are: +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |root id| be the value of the root field of |command parameters| if present, or null otherwise. @@ -2640,7 +2685,7 @@ The [=remote end steps=] with session and |command parameters| 1. Let |contexts| be an empty [=/list=]. 1. If |root id| is not null, append the result of [=trying=] to - [=get a browsing context=] given |root id| to |contexts|. + [=get a browsing context=] with |session| and |root id| to |contexts|. Otherwise append all [=top-level browsing contexts=] to |contexts|. 1. Let |contexts info| be an empty [=/list=]. @@ -2648,7 +2693,7 @@ The [=remote end steps=] with session and |command parameters| 1. For each |context| of |contexts|: 1. Let |info| be the result of [=get the browsing context info=] given - |context|, |max depth|, and true. + |session|, |context|, |max depth|, and true. 1. Append |info| to |contexts info| @@ -2690,13 +2735,10 @@ command allows closing an open prompt
-The [=remote end steps=] with session and |command parameters| are: - -1. Let |context id| be the value of the context field of - |command parameters|. +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. Let |accept| be the value of the accept field of |command parameters| if present, or true otherwise. @@ -2758,13 +2800,10 @@ browsing context to the given URL.
-The [=remote end steps=] with session and |command parameters| are: - -1. Let |context id| be the value of the context field of - |command parameters|. +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. Assert: |context| is not null. @@ -2843,13 +2882,10 @@ PDF document represented as a Base64-encoded string. -The [=remote end steps=] with session and |command parameters| are: - -1. Let |context id| be the value of the context field of - |command parameters|. +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. If the implementation is unable to provide a paginated representation of |context| for any reason then return [=error=] with [=error code=] @@ -2970,13 +3006,10 @@ browsing context.
-The [=remote end steps=] with |command parameters| are: - -1. Let |context id| be the value of the context field of - |command parameters|. +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. Assert: |context| is not null. @@ -3032,11 +3065,10 @@ The browsingContext.setViewport command specific
-The [=remote end steps=] with |command parameters| are: - -1. Let |context id| be the value of the |command parameters|["context"] field. +The [=remote end steps=] with |session| and |command parameters| are: -1. Let |context| be the result of [=trying=] to [=get a browsing context=] with |context id|. +1. Let |context| be the result of [=trying=] to [=get a browsing context=] with + |session| and |command parameters|["context"]. 1. If |context| is not a [=top-level browsing context=], return [=error=] with [=error code=] [=invalid argument=]. @@ -3088,7 +3120,7 @@ To Recursively emit context created events given |session| and |conte To Emit a context created event given |session| and |context|: 1. Let |params| be the result of [=get the browsing context info=] given - |context|, 0, and true. + |session|, |context|, 0, and true. 1. Let |body| be a [=/map=] matching the browsingContext.ContextCreated production, with the @@ -3149,13 +3181,6 @@ Define the following [=browsing context tree discarded=] steps: 1. Let |context| be the browsing context being discarded. -1. Let |params| be the result of [=get the browsing context info=], given - |context|, 0, and true. - -1. Let |body| be a [=/map=] matching the - browsingContext.ContextDestroyed production, with the - params field set to |params|. - 1. Let |related browsing contexts| be a [=/set=] containing the result of [=get the parent browsing context=] with |context|, if that is not null, or an empty [=/set=] otherwise. @@ -3164,6 +3189,13 @@ Define the following [=browsing context tree discarded=] steps: given "browsingContext.contextDestroyed" and |related browsing contexts|: + 1. Let |params| be the result of [=get the browsing context info=], given + |session|, |context|, 0, and true. + + 1. Let |body| be a [=/map=] matching the + browsingContext.ContextDestroyed production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|. Issue: the way this hooks into HTML feels very fragile. See https://github.com/whatwg/html/issues/6194 @@ -3191,23 +3223,23 @@ become inaccessible but not yet get discarded because bfcache. The [=remote end event trigger=] is the WebDriver BiDi navigation started steps given |context| and |navigation status|: -1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - - 1. Let |body| be a [=/map=] matching the - browsingContext.NavigationStarted production, with the - params field set to |params|. - 1. Let |navigation id| be |navigation status|'s id. -1. Let |related browsing contexts| be a [=/set=] containing |context|. - 1. [=Resume=] with "navigation started", |navigation id|, and |navigation status|. +1. Let |related browsing contexts| be a [=/set=] containing |context|. + 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.navigationStarted" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |session|, + |context| and |navigation status|. + + 1. Let |body| be a [=/map=] matching the + browsingContext.NavigationStarted production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3230,23 +3262,23 @@ started steps given |context| and |navigation status|: The [=remote end event trigger=] is the WebDriver BiDi fragment navigated steps given |context| and |navigation status|: -1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - -1. Let |body| be a [=/map=] matching the - browsingContext.FragmentNavigated production, with the - params field set to |params|. - 1. Let |navigation id| be |navigation status|'s id. -1. Let |related browsing contexts| be a [=/set=] containing |context|. - 1. [=Resume=] with "fragment navigated", |navigation id|, and |navigation status|. +1. Let |related browsing contexts| be a [=/set=] containing |context|. + 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.fragmentNavigated" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |session|, + |context| and |navigation status|. + + 1. Let |body| be a [=/map=] matching the + browsingContext.FragmentNavigated production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3269,23 +3301,23 @@ navigated steps given |context| and |navigation status|: The [=remote end event trigger=] is the WebDriver BiDi DOM content loaded steps given |context| and |navigation status|: -1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - -1. Let |body| be a [=/map=] matching the - browsingContext.DomContentLoaded production, with the - params field set to |params|. - -1. Let |related browsing contexts| be a [=/set=] containing |context|. - 1. Let |navigation id| be |navigation status|'s id. 1. [=Resume=] with "domContentLoaded", |navigation id|, and |navigation status|. +1. Let |related browsing contexts| be a [=/set=] containing |context|. + 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.domContentLoaded" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |session|, |context| + and |navigation status|. + + 1. Let |body| be a [=/map=] matching the + browsingContext.DomContentLoaded production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3308,22 +3340,22 @@ loaded steps given |context| and |navigation status|: The [=remote end event trigger=] is the WebDriver BiDi load complete steps given |context| and |navigation status|: -1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - -1. Let |body| be a [=/map=] matching the browsingContext.Load - production, with the params field set to |params|. - -1. Let |related browsing contexts| be a [=/set=] containing |context|. - 1. Let |navigation id| be |navigation status|'s id. 1. [=Resume=] with "load", |navigation id| and |navigation status|. +1. Let |related browsing contexts| be a [=/set=] containing |context|. + 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.load" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |session|, + |context| and |navigation status|. + + 1. Let |body| be a [=/map=] matching the browsingContext.Load + production, with the params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3346,22 +3378,22 @@ complete steps given |context| and |navigation status|: The [=remote end event trigger=] is the WebDriver BiDi download started steps given |context| and |navigation status|: - 1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - - 1. Let |body| be a [=/map=] matching the - browsingContext.DownloadWillBegin production, with the - params field set to |params|. - 1. Let |navigation id| be |navigation status|'s id. - 1. Let |related browsing contexts| be a [=/set=] containing |context|. - 1. [=Resume=] with "download started", |navigation id|, and |navigation status|. + 1. Let |related browsing contexts| be a [=/set=] containing |context|. + 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.downloadWillBegin" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |session|, |context| + and |navigation status|. + + 1. Let |body| be a [=/map=] matching the + browsingContext.DownloadWillBegin production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3384,13 +3416,6 @@ started steps given |context| and |navigation status|: The [=remote end event trigger=] is the WebDriver BiDi navigation aborted steps given |context| and |navigation status|: -1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - -1. Let |body| be a [=/map=] matching the - browsingContext.NavigationAborted production, with the - params field set to |params|. - 1. Let |navigation id| be |navigation status|'s id. 1. Let |related browsing contexts| be a [=/set=] containing |context|. @@ -3400,6 +3425,13 @@ aborted steps given |context| and |navigation status|: 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.navigationAborted" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |session|, + |context| and |navigation status|. + + 1. Let |body| be a [=/map=] matching the + browsingContext.NavigationAborted production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3423,22 +3455,22 @@ aborted steps given |context| and |navigation status|: The [=remote end event trigger=] is the WebDriver BiDi navigation failed steps given |context| and |navigation status|: -1. Let |params| be the result of [=get the navigation info=] given |context| - and |navigation status|. - -1. Let |body| be a [=/map=] matching the - browsingContext.NavigationFailed production, with the - params field set to |params|. - 1. Let |navigation id| be |navigation status|'s id. -1. Let |related browsing contexts| be a [=/set=] containing |context|. - 1. [=Resume=] with "navigation failed", |navigation id|, and |navigation status|. +1. Let |related browsing contexts| be a [=/set=] containing |context|. + 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.navigationFailed" and |related browsing contexts|: + 1. Let |params| be the result of [=get the navigation info=] given |context| + and |navigation status|. + + 1. Let |body| be a [=/map=] matching the + browsingContext.NavigationFailed production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3470,23 +3502,28 @@ closed steps given |window|, |accepted| and optional |user text| 1. Let |context| be |window|'s [=/browsing context=]. -1. Let |context id| be the [=browsing context id=] for |context|. - -1. Let |params| be a [=/map=] matching the - browsingContext.UserPromptClosedParameters production with the - context field set to |context id|, the accepted - field set to |accepted|, and the userText field set to |user - text| if |user text| is not null or omitted otherwise. - -1. Let |body| be a [=/map=] matching the - BrowsingContextUserPromptClosedEvent production, with the - params field set to |params|. - 1. Let |related browsing contexts| be a [=/set=] containing |context|. 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.userPromptClosed" and |related browsing contexts|: + 1. Let |context id result| be [=get context id=] with |session| and |context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. + + 1. Let |params| be a [=/map=] matching the + browsingContext.UserPromptClosedParameters production with the + context field set to |context id|, the accepted + field set to |accepted|, and the userText field set to |user + text| if |user text| is not null or omitted otherwise. + + 1. Let |body| be a [=/map=] matching the + BrowsingContextUserPromptClosedEvent production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3519,24 +3556,29 @@ opened steps given |window|, |type|, |message|, and optional |default valu 1. Let |context| be |window|'s [=/browsing context=]. -1. Let |context id| be the [=browsing context id=] for |context|. - -1. Let |params| be a [=/map=] matching the - browsingContext.UserPromptOpenedParameters production with the - context field set to |context id|, the type field - set to |type|, the message field set to |message|, and the - defaultValue field set to |default value| if |default value| is - not null or omitted otherwise. - -1. Let |body| be a [=/map=] matching the - browsingContext.UserPromptOpened production, with the - params field set to |params|. - 1. Let |related browsing contexts| be a [=/set=] containing |context|. 1. For each |session| in the [=set of sessions for which an event is enabled=] given "browsingContext.userPromptOpened" and |related browsing contexts|: + 1. Let |context id result| be [=get context id=] with |session| and |context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. + + 1. Let |params| be a [=/map=] matching the + browsingContext.UserPromptOpenedParameters production with the + context field set to |context id|, the type field + set to |type|, the message field set to |message|, and the + defaultValue field set to |default value| if |default value| is + not null or omitted otherwise. + + 1. Let |body| be a [=/map=] matching the + browsingContext.UserPromptOpened production, with the + params field set to |params|. + 1. [=Emit an event=] with |session| and |body|.
@@ -3755,8 +3797,13 @@ To process a network event given |session|, |event|, and |request|: 1. Let |environment settings| be |request|'s [=request/window=] 1. If there is a [=/browsing context=] whose [=active window=] is |environment - settings|' [=environment settings object/global object=], let |context id| - be the [=browsing context id=] for that context. + settings|' [=environment settings object/global object=], let |context id result| + be [=get context id=] with |session| and that context. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. 1. Let |redirect count| be |request|'s [=redirect count=]. @@ -5778,7 +5825,12 @@ To run WebDriver BiDi preload scripts given |environment setti 1. Let |top level context| be |browsing context|’s [=top-level browsing context=]. - 1. Let |context id| be |top level context|'s id. + 1. Let |context id result| be [=get context id=] with |session| and |top level context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. 1. If contexts does not [=list/contains|contain=] |context id|, return. @@ -6480,7 +6532,7 @@ To get the browsing context with given |realm|:
-To get the realm info given |environment settings|: +To get the realm info given |session| and |environment settings|: 1. Let |realm| be |environment settings|' [=realm execution context=]'s Realm component. @@ -6497,8 +6549,16 @@ To get the realm info given |environment settings|:
1. Let |document| be |environment settings|' [=relevant global object=]'s associated Document. + 1. Let |browsing context| be |document|'s [=/browsing context=]. - 1. Let |context id| be the [=browsing context id=] for |browsing context|. + + 1. Let |context id result| be the [=get context id=] with |session| and |browsing context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. + 1. Let |realm info| be a [=/map=] matching the script.WindowRealmInfo production, with the realm field set to |realm id|, the origin field set to |origin|, and the context field set to |context id|. @@ -6509,11 +6569,21 @@ To get the realm info given |environment settings|: 1. Let |document| be |global object|'s wrapped {{Window}}'s associated Document. + 1. Let |browsing context| be |document|'s [=/browsing context=]. - 1. Let |context id| be the [=browsing context id=] for |browsing context|. + + 1. Let |context id result| be [=get context id=] with |session| and |browsing context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. + 1. Let |sandbox name| be the result of [=get a sandbox name=] given |realm|. + 1. Assert: |sandbox name| is not null. + 1. Let |realm info| be a [=/map=] matching the script.WindowRealmInfo production, with the realm field set to |realm id|, the origin field set to |origin|, the context field set to |context id|, @@ -7245,7 +7315,12 @@ an |ownership type|, a |serialization internal map|, a |realm| and a |session|: 1. Let |browsing context| be |window|'s [=Window/browsing context=]. - 1. Let |context id| be the [=browsing context id=] for |browsing context|. + 1. Let |context id result| be [=get context id=] with |session| and |browsing context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. 1. Let |serialized| be a [=/map=] matching the script.WindowProxyProperties production in the [=local end @@ -7556,7 +7631,7 @@ an optional browsingContext.BrowsingContext in which a script related event occurred.
-To get the source given |source realm|: +To get the source given |session| and |source realm|: 1. Let |realm| be the [=realm id=] for |source realm|. @@ -7569,7 +7644,13 @@ To get the source given |source realm|: 1. Let |browsing context| be |document|’s [=Document/browsing context=]. - 1. Let |context id| be the [=browsing context id=] for |browsing context|. + 1. Let |context id result| be [=get context id=] with |session| and |browsing + context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. Otherwise let |browsing context| be null. @@ -7608,12 +7689,12 @@ This is useful in cases where a context identifier can stand in for the realm associated with the context's active document.
-To get a realm from a target given |target|: +To get a realm from a target given |session| and |target|: 1. If |target| matches the script.ContextTarget production: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |target|["context"]. + with |session| and |target|["context"]. 1. If |target| does not contain a field named "sandbox", or |target|["sandbox"] is an empty string: @@ -7687,15 +7768,18 @@ The [=remote end steps=] given |session| and |command parameters| are: 1. Let |arguments| be the arguments field of |command parameters| if present, or an empty [=/list=] otherwise. -1. Let the |contexts| be the value of the contexts field of |command parameters| if it is present or null if it isn’t. +1. Let the |contexts| be the value of the contexts field of + |command parameters| if it is present or null if it isn’t. 1. If |contexts| is not null: 1. For each |context id| of |contexts|: - 1. Let |context| be the result of [=trying=] to [=get a browsing context=] with |context id|. + 1. Let |context| be the result of [=trying=] to [=get a browsing context=] + with |session| and |context id|. - 1. If |context| is not a [=top-level browsing context=], return [=error=] with [=error code=] [=invalid argument=]. + 1. If |context| is not a [=top-level browsing context=], return [=error=] + with [=error code=] [=invalid argument=]. 1. Let |sandbox| be the value of the "sandbox" field in |command parameters|, if present, or null otherwise. @@ -7744,10 +7828,10 @@ other handles or strong ECMAScript references.
-The [=remote end steps=] with |command parameters| are: +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |realm| be the result of [=trying=] to [=get a realm from a target=] - given the value of the target field of |command parameters|. + with |session| and |command parameters|["target"]. 1. Let |handles| the value of the handles field of |command parameters|. @@ -7848,7 +7932,7 @@ Note: the |function declaration| is parenthesized and evaluated. The [=remote end steps=] with |session| and |command parameters| are: 1. Let |realm| be the result of [=trying=] to [=get a realm from a target=] - given the value of the target field of |command parameters|. + with |session| and |command parameters|["target"]. 1. Let |realm id| be |realm|'s [=realm id=]. @@ -7991,7 +8075,7 @@ that likely isn't what clients want. The [=remote end steps=] given |session| and |command parameters| are: 1. Let |realm| be the result of [=trying=] to [=get a realm from a target=] - given the value of the target field of |command parameters|. + with |session| and |command parameters|["target"]. 1. Let |realm id| be |realm|'s [=realm id=]. @@ -8086,7 +8170,7 @@ realm associated with the [=document=] currently loaded in a specified
-The [=remote end steps=] with session and |command parameters| are: +The [=remote end steps=] with |session| and |command parameters| are: 1. Let |environment settings| be a [=/list=] of all the [=environment settings objects=] that have their [=execution ready flag=] set. @@ -8094,7 +8178,7 @@ The [=remote end steps=] with session and |command parameters| 1. If |command parameters| contains context: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |command parameters|["context"]. + with |session| and |command parameters|["context"]. 1. Let |document| be |context|'s [=active document=]. @@ -8118,7 +8202,8 @@ The [=remote end steps=] with session and |command parameters| 1. For each |settings| of |environment settings|: - 1. Let |realm info| be the result of [=get the realm info=] given |settings| + 1. Let |realm info| be the result of [=get the realm info=] given |session| + and |settings| 1. If |command parameters| contains type and |realm info|["type"] is not equal to |command @@ -8234,7 +8319,7 @@ given |session|, |realm|, |channel properties|, and |message|: |message|, |serialization options|, |ownership type|, a new [=/map=] as serialization internal map and |realm|. - 1. Let |source| be the [=get the source=] with |realm|. + 1. Let |source| be the [=get the source=] with |session| and |realm|. 1. Let |params| be a [=/map=] matching the script.MessageParameters production, with the @@ -8274,20 +8359,20 @@ object: 1. Let |environment settings| be the newly created [=environment settings object=]. -1. Let |realm info| be the result of [=get the realm info=] given - |environment settings|. - -1. If |realm info| is null, return. - 1. Let |related browsing contexts| be the result of [=get related browsing contexts=] given |environment settings|. -1. Let |body| be a [=/map=] matching the script.RealmCreated - production, with the params field set to |realm info|. - 1. For each |session| in the [=set of sessions for which an event is enabled=] given "script.realmCreated" and |related browsing contexts|: + 1. Let |realm info| be the result of [=get the realm info=] given + |session| and |environment settings|. + + 1. If |realm info| is null, continue. + + 1. Let |body| be a [=/map=] matching the script.RealmCreated + production, with the params field set to |realm info|. + 1. [=Emit an event=] with |session| and |body|.
@@ -8317,7 +8402,8 @@ The [=remote end subscribe steps=] with [=subscribe priority=] 2, given Otherwise, if |include global| is false, continue. - 1. Let |realm info| be the result of [=get the realm info=] given |settings| + 1. Let |realm info| be the result of [=get the realm info=] given |session| + and |settings|. 1. Let |body| be a [=/map=] matching the script.RealmCreated production, with the params field set to |realm info|. @@ -8441,7 +8527,14 @@ To buffer a log event given |session|, |contexts| and |event|: 1. For each |context| of |contexts|: - 1. Append the [=browsing context id=] for |context| to |context ids|. + 1. Let |context id result| be [=get context id=] with |session| to and |context|. + + 1. Assert: |context id result| is not [=error=]. This would imply that the browsing + context doesn't have an active document. + + 1. Set |context id| to |context id result|'s data. + + 1. [=list/Append=] |context id| to |context ids|. 1. For each |context id| in |context ids|: @@ -8593,7 +8686,8 @@ Define the following [=console steps=] with |method|, |args|, and 1. Add |serialized arg| to |serialized args|. - 1. Let |source| be the result of [=get the source=] given [=current Realm Record=]. + 1. Let |source| be the result of [=get the source=] with |session| and + [=current Realm Record=]. 1. If |method| is "assert", "error", "trace", or "warn", let |stack| be the [=current @@ -8632,18 +8726,20 @@ ignore>line number, column number, |message| and 1. Let |stack| be the [=stack trace for an exception=] with the exception corresponding to the error being reported. -1. Let |source| be the result of [=get the source=] given [=current Realm Record=]. - -1. Let |entry| be a [=/map=] matching the log.JavascriptLogEntry production, - with level set to "error", text set to - |message|, source set to |source|, and the timestamp - field set to |timestamp|. - 1. Let |related browsing contexts| be the result of [=get related browsing contexts=] given |settings|. 1. For each |session| in [=active BiDi sessions=]: + 1. Let |source| be the result of [=get the source=] given |session| and + [=current Realm Record=]. + + 1. Let |entry| be a [=/map=] matching the log.JavascriptLogEntry production, + with level set to "error", text set to + |message|, source set to |source|, and the timestamp + field set to |timestamp|. + + 1. If [=event is enabled=] with |session|, "log.entryAdded" and |related browsing contexts|, [=emit an event=] with |session| and |body|. @@ -8920,11 +9016,8 @@ specified sequence of user input actions. The [=remote end steps=] with |session| and |command parameters| are: -1. Let |context id| be the value of the context field of - |command parameters|. - 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. Let |input state| be [=get the input state=] with |session| and |context|'s [=top-level browsing context=]. @@ -8973,13 +9066,10 @@ state associated with the current session.
-The [=remote end steps=] given |session|, and |command parameters| are: - -1. Let |context id| be the value of the context field of - |command parameters|. +The [=remote end steps=] given |session| and |command parameters| are: 1. Let |context| be the result of [=trying=] to [=get a browsing context=] - with |context id|. + with |session| and |command parameters|["context"]. 1. Let |top-level context| be |context|'s [=top-level browsing context=]. From e9e85fe38f4dfa4f58acf0426fa271fa63d868c9 Mon Sep 17 00:00:00 2001 From: jgraham Date: Mon, 2 Oct 2023 14:06:12 +0100 Subject: [PATCH 2/2] Update index.bs Co-authored-by: Thiago Perrotta --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index eb9ae019..19896078 100644 --- a/index.bs +++ b/index.bs @@ -1808,7 +1808,7 @@ events relating to [=navigables=]. Note: For historic reasons this module is called browsingContext rather than navigable, and the protocol uses the term -context to refer to navigables, particuarly as a field in command +context to refer to navigables, particularly as a field in command and response parameters. Issue: Update the spec to use [=navigable=] consistently and remove