From 97714332f9b7b52ccf5d9cc50a26d4e35af9b36e Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 25 May 2021 16:57:56 +0100 Subject: [PATCH] Specify a browsingContext.reload command 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. --- index.bs | 210 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 70 deletions(-) diff --git a/index.bs b/index.bs index 63eb447d..d06d9fe9 100644 --- a/index.bs +++ b/index.bs @@ -1699,7 +1699,8 @@ navigation status struct, which has the following items: BrowsingContextCommand = ( BrowsingContextGetTreeCommand // - BrowsingContextNavigateCommand + BrowsingContextNavigateCommand // + BrowsingContextReloadCommand ) @@ -1830,6 +1831,106 @@ To get the browsing context info given |context|, 1. Return |contexts info| + + +
+To await a navigation given |context|, |request| and optionally +|history handling| (default: "default") and |ignore cache| (default: false): + +1. Let |navigation id| be the string representation of a + [[!RFC4122|UUID]] based on truly random, or pseudo-random numbers. + +1. [=Navigate=] |context| with resource |request|, and using |context| as the + [=source browsing context=], with navigation id |navigation id|, and history + handling |history handling|. If |ignore cache| is true, the navigation must + not load resources from the HTTP cache. + + Issue: property specify how the |ignore cache| flag works. This needs to + consider whether only the first load of a resource bypasses the cache + (i.e. whether this is like initially clearing the cache and proceeding like + normal), or whether resources not directly loaded by the HTML parser + (e.g. loads initiated by scripts or stylesheets) also bypass the cache. + +1. Let (|event received|, |navigate status|) be [=await=] given + «"navigation started", "navigation failed", + and "fragment navigated"» and |navigation id|. + +1. Assert: |navigate status|'s id is |navigation id|. + +1. If |navigate status|'s status is "complete": + + 1. Let |body| be a [=map=] matching the + BrowsingContextNavigateResult production, with the + navigation field set to |navigation id|, and the + url 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. 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. + +1. If |navigate status|'s status is "canceled" return [=error=] + with [=error code=] [=unknown error=]. + + TODO: is this the right way to handle errors here? + +1. Assert: |navigate status|'s status is "pending" and + |navigation id| is not null. + +1. If |wait condition| is "none": + + 1. Let |body| be a [=map=] matching the + BrowsingContextNavigateResult production, with the + navigation field set to |navigation id|, and the + url 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. Run the [=WebDriver-BiDi navigation started=] steps given |context| + and |navigate status| + +1. Run the [=WebDriver-BiDi navigation started=] steps given |context| + and |navigate status| + + Note: this event was previously suppressed to ensure that it would come + after the command response in the case that |wait condition| is + "none". + + Issue: Replace this suppression mechanism with an event queue. + +1. If |wait condition| is "interactive", let |event name| be + "domContentLoaded", otherwise let |event name| be + "load". + +1. Let (|event received|, |status|) be [=await=] given «|event name|, + "download started", "navigation aborted", + "navigation failed"» and |navigation id|. + +1. If |event received| is "navigation failed" + 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 + BrowsingContextNavigateResult production, with the + navigation field set to |status|'s id, and the + url field set to the result of the [=URL serializer=] given + |status|'s url. + +1. Return [=success=] with data |body|. + +
#### The browsingContext.Navigation Type #### {#type-browsingContext-Navigation} @@ -1994,93 +2095,62 @@ The [=remote end steps=] with |command parameters| are: 1. Let |request| be a new [=/request=] whose URL is |url record|. - 1. Let |navigation id| be the string representation of a - [[!RFC4122|UUID]] based on truly random, or pseudo-random numbers. - - 1. [=Navigate=] |context| with resource |request|, and using |context| as the - [=source browsing context=], and with navigation id |navigation id|. - - 1. Let (|event received|, |navigate status|) be [=await=] given - «"navigation started", "navigation failed", - and "fragment navigated"» and |navigation id|. - - 1. Assert: |navigate status|'s id is |navigation id|. - - 1. If |navigate status|'s status is "complete": - - 1. Let |body| be a [=map=] matching the - BrowsingContextNavigateResult production, with the - navigation field set to |navigation id|, and the - url field set to the result of the [=URL serializer=] given - |navigate status|'s url. + 1. Return the result of [=await a navigation=] with |context| and |request|. - 1. Return [=success=] with data |body|, 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. - - 1. If |navigate status|'s status is "canceled" return [=error=] - with [=error code=] [=unknown error=]. - - TODO: is this the right way to handle errors here? + - 1. Assert: |navigate status|'s status is "pending" and - |navigation id| is not null. +#### The browsingContext.reload Command #### {#command-browsingContext-reload} - 1. If |wait condition| is "none": +The browsingContext.reload command reloads a +browsing context. - 1. Let |body| be a [=map=] matching the - BrowsingContextNavigateResult production, with the - navigation field set to |navigation id|, and the - url field set to the result of the [=URL serializer=] given - |navigate status|'s url. +
+
Command Type
+
+
+      BrowsingContextReloadCommand = {
+        method: "browsingContext.reload",
+        params: BrowsingContextReloadParameters
+      }
 
-    1. Return [=success=] with data |body|, and then run the following steps [=in
-       parallel=]:
+      BrowsingContextReloadParameters = {
+        context: BrowsingContext,
+        ?ignoreCache: boolean,
+        ?wait: ReadinessState,
+      }
+      
+
+
- 1. Run the [=WebDriver-BiDi navigation started=] steps given |context| - and |navigate status| +
+The [=remote end steps=] with |command parameters| are: - 1. Run the [=WebDriver-BiDi navigation started=] steps given |context| - and |navigate status| +1. Let |context id| be the value of the context field of + |command parameters|. - Note: this event was previously suppressed to ensure that it would come - after the command response in the case that |wait condition| is - "none". +1. Let |context| be the result of [=trying=] to [=get a browsing context=] + with |context id|. - Issue: Replace this suppression mechanism with an event queue. +1. Assert: |context| is not null. - 1. If |wait condition| is "interactive", let |event name| be - "domContentLoaded", otherwise let |event name| be - "load". +1. Let |ignore cache| be the the value of the ignoreCache field of |command + parameters| if present, or false otherwise. - 1. Let (|event received|, |status|) be [=await=] given «|event name|, - "download started", "navigation aborted", - "navigation failed"» and |navigation id|. +1. Let |wait condition| be the value of the wait field of |command + parameters| if present, or "none" otherwise. - 1. If |event received| is "navigation failed" - return [=error=] with [=error code=] [=unknown error=]. +1. Let |document| be |context|'s [=active document=]. - 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 |URL| be |document|'s URL. - 1. Let |body| be a [=map=] matching the - BrowsingContextNavigateResult production, with the - navigation field set to |status|'s id, and the - url field set to the result of the [=URL serializer=] given - |status|'s url. +1. Let |request| be a new [=/request=] whose URL is |URl|. - 1. Return [=success=] with data |body|. +1. Return the result of [=await a navigation=] with |context|, |request|, + history handling "reload", and ignore cache |ignore cache|.
+ ### Events ### {#module-contexts-events} #### The browsingContext.contextCreated Event #### {#event-browsingContext-contextCreated}