Skip to content

Commit

Permalink
Specify a browsingContext.reload command
Browse files Browse the repository at this point in the history
This works just like navigation, except it has no URL and instead
takes an additional parameter to allow specifying a
force-reload. However adding this into HTML looks like a pretty
significant task, so for now the spec just handwaves how it will
behave.
  • Loading branch information
jgraham committed Jun 4, 2021
1 parent b16fbd6 commit 5812fae
Showing 1 changed file with 121 additions and 44 deletions.
165 changes: 121 additions & 44 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,8 @@ is a set that is initially empty.

BrowsingContextCommand = (
BrowsingContextGetTreeCommand //
BrowsingContextNavigateCommand
BrowsingContextNavigateCommand //
BrowsingContextReloadCommand
)
</pre>

Expand Down Expand Up @@ -1738,6 +1739,69 @@ To <dfn>get the navigation info</dfn>, given |context| and |navigation status|:

### Commands ### {#module-browsingContext-commands}

<div algorithm>

To <dfn>wait for navigation to complete</dfn> given |navigate status| and |wait
condition|:

1. Let |navigation id| be |navigate status|'s id

1. If |navigate status|'s status is "<code>complete</code>" |navigation id| is
null:

1. Let |body| be a [=map=] matching the
<code>BrowsingContextNavigateResult</code> production, with the
<code>navigation</code> field set to null, and the <code>url</code> field
set to the result of the [=URL serializer=] given |navigate status|'s url.

1. Return [=success=] with data |body|

Note: this is the case if the navigation only caused the fragment to change.

1. If |navigate status|'s status is "<code>canceled</code>" return [=error=]
with [=error code=] [=unknown error=].

TODO: is this the right way to handle errors here?

1. Assert: |navigate status|'s status is "<code>pending</code>" and
|navigation id| is not null.

1. If |wait condition| is "<code>none</code>":

1. Let |body| be a [=map=] matching the
<code>BrowsingContextNavigateResult</code> production, with the
<code>navigation</code> field set to |navigation id|, and the
<code>url</code> field set to the result of the [=URL serializer=] given
|navigate status|'s url.

1. Return [=success=] with data |body|.

1. If |wait condition| is "<code>interactive</code>", let |event name| be
"<code>domContentLoaded</code>", otherwise let |event name| be
"<code>load</code>".

1. Let (|event received|, |status|) be [=await=] given «|event name|,
"<code>download started</code>", "<code>navigation failed</code>"» and
|navigation id|.

1. If |event received| is "<code>navigation failed</code>"
return [=error=] with [=error code=] [=unknown error=].

Issue: Are we surfacing enough information about what failed and why with
an error here? What error code do we want? Is there going to be a problem
where local ends parse the implementation-defined strings to figure out
what actually went wrong?

1. Let |body| be a [=map=] matching the
<code>BrowsingContextNavigateResult</code> production, with the
<code>navigation</code> field set to |status|'s id, and the
<code>url</code> field set to the result of the [=URL serializer=] given
|status|'s url.

1. Return [=success=] with data |body|.

</div>

#### The browsingContext.getTree Command #### {#command-browsingContext-getTree}

The <dfn export for=commands>browsingContext.getTree</dfn> command returns a
Expand Down Expand Up @@ -1860,67 +1924,72 @@ The [=remote end steps=] with |command parameters| are:

1. Remove |context id| from the [=set of contexts with an ongoing navigate=].

1. Let |navigation id| be |navigate status|'s id

1. If |navigate status|'s status is "<code>complete</code>" |navigation id| is
null:

1. Let |body| be a [=map=] matching the
<code>BrowsingContextNavigateResult</code> production, with the
<code>navigation</code> field set to null, and the <code>url</code> field
set to the result of the [=URL serializer=] given |navigate status|'s url.

1. Return [=success=] with data |body|, and then run the following steps [=in
parallel=]:
1. Return the result of [=wait for navigation to complete=], given |navigate
status| and |wait condition|, and then run the following steps [=in
parallel=]:

1. Run the [=WebDriver-BiDi fragment navigated=] steps given |context|
and |navigate status|

Note: this is the case if the navigation only caused the fragment to
change. The parallel steps here ensure that we return the command result
before emitting the event, so the navigation id is known.
</div>

1. If |navigate status|'s status is "<code>cancelled</code>" return [=error=]
with [=error code=] [=unknown error=].
#### The browsingContext.reload Command #### {#command-browsingContext-reload}

TODO: is this the right way to handle errors here?
The <dfn export for=commands>browsingContext.reload</dfn> command reloads a
browsing context.

1. Assert: |navigate status|'s status is "<code>pending</code>" and
|navigation id| is not null.
<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
BrowsingContextReloadCommand = {
method: "browsingContext.reload",
params: BrowsingContextReloadParameters
}

1. If |wait condition| is "<code>none</code>":
BrowsingContextReloadParameters = {
context: BrowsingContext,
?ignoreCache: boolean,
?wait: ReadinessState,
}
</pre>
</dd>
</dl>

1. Let |body| be a [=map=] matching the
<code>BrowsingContextNavigateResult</code> production, with the
<code>navigation</code> field set to |navigation id|, and the
<code>url</code> field set to the result of the [=URL serializer=] given
|navigate status|'s url.
<div algorithm="remote end steps for browsingContext.reload">
The [=remote end steps=] with |command parameters| are:

1. Return [=success=] with data |body|.
1. Let |context id| be the value of the <code>context</code> field of
|command parameters|.

1. If |wait condition| is "<code>interactive</code>", let |event name| be
"<code>domContentLoaded</code>", otherwise let |event name| be
"<code>load</code>".
1. Let |context| be the result of [=trying=] to [=get a browsing context=]
with |context id|.

1. Let (|event received|, |status|) be [=await=] given «|event name|,
"<code>download started</code>", "<code>navigation failed</code>"» and
|navigation id|.
1. Assert: |context| is not null.

1. If |event received| is "<code>navigation failed</code>"
return [=error=] with [=error code=] [=unknown error=].
1. Let |ignore cache| be the the value of the <code>ignoreCache</code> field of |command
parameters| if present, or false otherwise.

Issue: Are we surfacing enough information about what failed and why with
an error here? What error code do we want? Is there going to be a problem
where local ends parse the implementation-defined strings to figure out
what actually went wrong?
1. Let |wait condition| be the value of the <code>wait</code> field of |command
parameters| if present, or "<code>none</code>" otherwise.

1. Let |body| be a [=map=] matching the
<code>BrowsingContextNavigateResult</code> production, with the
<code>navigation</code> field set to |status|'s id, and the
<code>url</code> field set to the result of the [=URL serializer=] given
|status|'s url.
1. Let |document| be |context|'s [=active document=].

1. Return [=success=] with data |body|.
1. Let |URL| be |document|'s <a spec=DOM>URL</a>.

1. Let |navigate status| be the result of [=navigate|navigating=] |context| to
|URL| with historyHandling set to "<code>reload</code>" and using |context|
as the [=source browsing context=].

Issue: this also needs to pass |ignore cache|, which will cause any fetches
caused by navigation to have [=cache mode=] "<code>reload</code>".
See https://github.com/whatwg/html/issues/6718

1. Return the result of [=wait for navigation to complete=], given |navigate
status| and |wait condition|.

</div>

Expand Down Expand Up @@ -2034,6 +2103,11 @@ started</dfn> steps given |context| and |navigation status|:

1. [=Emit an event=] with |body| and |related browsing contexts|.

1. Let |navigation id| be |navigation status|'s id.

1. [=Resume=] with "<code>navigation started</code>", |navigation id|, and
|navigation status|. </div>

</div>

#### The browsingContext.fragmentNavigated Event #### {#event-browsingContext-fragmentNavigated}
Expand Down Expand Up @@ -2117,7 +2191,10 @@ loaded</dfn> steps given |context| and |navigation status|:
1. Let |navigation id| be |navigation status|'s id.

1. [=Resume=] with "<code>domContentLoaded</code>", |navigation id|, and
|navigation status|. </div>
|navigation status|.

</div>


#### The browsingContext.load Event #### {#event-browsingContext-load}

Expand Down

0 comments on commit 5812fae

Please sign in to comment.