Skip to content

[WebDriver BiDi] report download complete / canceled #11289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 52 additions & 18 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -4608,10 +4608,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x="navigation-status-complete" data-x-href="https://w3c.github.io/webdriver-bidi/#navigation-status-complete">navigation status complete</dfn></li>
<li><dfn data-x="navigation-status-url" data-x-href="https://w3c.github.io/webdriver-bidi/#navigation-status-url">navigation status url</dfn></li>
<li><dfn data-x="navigation-status-suggested-filename" data-x-href="https://w3c.github.io/webdriver-bidi/#navigation-status-suggested-filename">navigation status suggested filename</dfn></li>
<li><dfn data-x="navigation-status-downloaded-filepath" data-x-href="https://w3c.github.io/webdriver-bidi/#navigation-status-downloaded-filepath">navigation status downloaded filepath</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-aborted">WebDriver BiDi navigation aborted</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-committed">WebDriver BiDi navigation committed</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-failed">WebDriver BiDi navigation failed</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-started">WebDriver BiDi navigation started</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-end">WebDriver BiDi download end</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-download-started">WebDriver BiDi download started</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-fragment-navigated">WebDriver BiDi fragment navigated</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-dom-content-loaded">WebDriver BiDi DOM content loaded</dfn></li>
Expand Down Expand Up @@ -25788,17 +25790,60 @@ document.body.appendChild(wbr);</code></pre>
</ol>

<p>To <dfn>handle as a download</dfn> a <span data-x="concept-response">response</span>
<var>response</var>:</p>
<var>response</var> with an optional <span data-x="navigable">navigable</span>-or-null
<var>navigable</var> (default null) and an optional <span>navigation ID</span>-or-null
<var>navigationId</var> (default null):</p>

<ol>
<li><p>Let <var>suggestedFilename</var> be the result of <span>getting the suggested
filename</span> for <var>response</var>.</p></li>

<li><p>Provide the user with a way to save <var>response</var> for later use. If the user agent
needs a filename, it should use <var>suggestedFilename</var>. Report any problems downloading the
file to the user.</p></li>
needs a filename, it should use <var>suggestedFilename</var>.</p></li>

<li><p>Return <var>suggestedFilename</var>.</p></li>
<li><p>If <var>navigable</var> is not null and <var>navigationId</var> is not null, then invoke
<span>WebDriver BiDi download started</span> with <var>navigable</var> and a
new <span>WebDriver BiDi navigation status</span> whose <span
data-x="navigation-status-id">id</span> is <var>navigationId</var>, <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-complete">complete</code>", <span
data-x="navigation-status-url">url</span> is <var>response</var>'s <span
data-x="concept-response-url">URL</span>, and <span
data-x="navigation-status-suggested-filename">suggestedFilename</span> is
<var>suggestedFilename</var>.</p></li>

<li>
<p>If the file downloading was canceled by user or by the user agent, or if the file downloading
faced any problems, then:</p>

<ol>
<li><p>If <var>navigable</var> is not null and <var>navigationId</var> is not null, then
invoke <span>WebDriver BiDi download end</span> with <var>navigable</var> and a new
<span>WebDriver BiDi navigation status</span> whose <span
data-x="navigation-status-id">id</span> is <var>navigationId</var>, <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-canceled">canceled</code>", <span
data-x="navigation-status-url">url</span> is <var>response</var>'s <span
data-x="concept-response-url">URL</span>.</p></li>
</ol>
</li>

<li>
<p>When the file downloading successfully completed:</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if these steps "if the file downloading was canceled by user or by the user agent, or if the file downloading faced any problems" and "When the file downloading successfully completed" are specific enough and also they define steps that do not happen in the order of the algorithm but I will defer to the HTML spec reviewers on this.


<ol>
<li><p>If <var>navigable</var> is not null and <var>navigationId</var> is not null, then
invoke <span>WebDriver BiDi download end</span> with <var>navigable</var> and a new
<span>WebDriver BiDi navigation status</span> whose <span
data-x="navigation-status-id">id</span> is <var>navigationId</var>, <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-complete">complete</code>", <span
data-x="navigation-status-downloaded-filepath">downloadedFilepath</span> is an absolute path
of the downloaded file if available, otherwise null, <span
data-x="navigation-status-url">url</span> is <var>response</var>'s <span
data-x="concept-response-url">URL</span>.</p></li>
</ol>
</li>
</ol>

<p>To <dfn data-x="getting the suggested filename">get the suggested filename</dfn> for a <span
Expand Down Expand Up @@ -103334,20 +103379,9 @@ location.href = '#foo';</code></pre>
<var>uaAllowsDownloading</var> are true, then:</p>

<ol>
<li><p>Let <var>suggestedFilename</var> be the result of <span data-x="handle as a
download">handling as a download</span> <var>navigationParams</var>'s <span
data-x="navigation-params-response">response</span>.</p></li>

<li><p>Invoke <span>WebDriver BiDi download started</span> with <var>navigable</var> and a
new <span>WebDriver BiDi navigation status</span> whose <span
data-x="navigation-status-id">id</span> is <var>navigationId</var>, <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-complete">complete</code>", <span
data-x="navigation-status-url">url</span> is <var>navigationParams</var>'s <span
data-x="navigation-params-response">response</span>'s <span
data-x="concept-response-url">URL</span>, and <span
data-x="navigation-status-suggested-filename">suggestedFilename</span> is
<var>suggestedFilename</var>.</p></li>
<li><p><span data-x="handle as a download">Handle as a download</span>
<var>navigationParams</var>'s <span data-x="navigation-params-response">response</span>
with <var>navigable</var> and <var>navigationId</var>.</p></li>
</ol>
</li>
</ol>
Expand Down