From d95609c17fe43ba1aae294acdff14cb3ae4d7c2b Mon Sep 17 00:00:00 2001 From: James Graham <james@hoppipolla.co.uk> Date: Wed, 12 Jun 2024 12:24:36 +0100 Subject: [PATCH 1/3] Don't require user prompt handler notify to match when creating session This would prevent creating a BiDi session for a browser that already has a HTTP session with the notify flag set for some prompt handler. --- index.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 3187af5b..177d7417 100644 --- a/index.html +++ b/index.html @@ -10545,11 +10545,7 @@ <h3>User Prompt Handler</h3> <li><p>If the <var>requested prompt handler</var>'s [=prompt handler configuration/handler=] is not equal to the <a>user prompt handler</a>'s [=prompt handler - configuration/handler=], or the <var>requested prompt - handler</var>'s [=prompt handler configuration/notify=] - is not equal to the <a>user prompt - handler</a>'s [=prompt handler configuration/handler=], - return false. + configuration/handler=], return false. </ol> </li> @@ -10558,6 +10554,12 @@ <h3>User Prompt Handler</h3> <li>Return true</li> </ol> +<p class="note">This does not check the <var>requested prompt +handler</var>'s [=prompt handler configuration/notify=] matches +the [=prompt handler configuration/handler=], because the [=prompt +handler configuration/notify=] component only affects the [=HTTP +session=], if any. + <p>To <dfn>update the user prompt handler</dfn> given <var>requested prompt handler</var>: <ol class=algorithm> From a63c0e89c615e106cf61646c49bf90ba8cf27a56 Mon Sep 17 00:00:00 2001 From: James Graham <james@hoppipolla.co.uk> Date: Thu, 13 Jun 2024 18:31:06 +0100 Subject: [PATCH 2/3] Make object-valued user prompt handler defaults always override Previously an object value for the unhandledPromptBehavior capability like: { "default": "dismiss" } was equivalent to the string value "dismiss" which for legacy reasons does not affect "beforeUnload" prompts. For WebDriver-BiDi session we'd ideally like to remove this special case and have the default value apply to all prompt types. Therefore this changes things so that an object value with a default key provides a default that applies to all prompt types, whereas the traditional string values only apply to alert/confirm/prompt dialogs. This preserves classic semantics for string-only values, but makes the object values behave in a more uniform way. --- index.html | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 177d7417..c97f7b73 100644 --- a/index.html +++ b/index.html @@ -10481,8 +10481,11 @@ <h3>User Prompt Handler</h3> <p class="note">This is to avoid [[WebDriver-BiDi]] monkey-patching the current spec. + <li><p>Let <var>is string value</var> be false. + <li><p>If <var>value</var> is a <a>string</a> set <var>value</var> to - the <a data-cite=infra>map</a> «["<code>default</code>" → <var>value</var>]». + the <a data-cite=infra>map</a> «["<code>fallbackDefault</code>" + → <var>value</var>]» and set <var>is string value</var> to true. <li><p>If <var>value</var> is not a <a data-cite=infra>map</a> return <a>error</a> with <a>error code</a> <a>invalid argument</a>. @@ -10492,9 +10495,9 @@ <h3>User Prompt Handler</h3> <li><p>For each <var>prompt type</var> → <var>handler</var> in <var>value</var>: <ol> - <li><p>If <a>valid prompt types</a> does - not [=map/contain=] <var>prompt type</var> return <a>error</a> - with <a>error code</a> <a>invalid argument</a>. + <li><p>If <var>is string value</var> is false and <a>valid prompt + types</a> does not [=map/contain=] <var>prompt type</var> + return <a>error</a> with <a>error code</a> <a>invalid argument</a>. <li><p>If <a>known prompt handlers</a> does not contain an entry with <a>handler key</a> <var>handler</var> return <a>error</a> @@ -10584,9 +10587,9 @@ <h3>User Prompt Handler</h3> <li><p>If the <a>user prompt handler</a> has [=map/size=] 1, and <a>user prompt handler</a> [=list/contains=] - "<code>default</code>", return the result of <a>serialize a prompt + "<code>fallbackDefault</code>", return the result of <a>serialize a prompt handler configuration</a> with <a>user prompt - handler</a>["<code>default</code>"]. + handler</a>["<code>fallbackDefault</code>"]. <li><p>Let <var>serialized</var> be an empty <a data-cite=infra>map</a>. @@ -10623,12 +10626,15 @@ <h3>User Prompt Handler</h3> <li><p>If <var>handlers</var> contains <var>type</var> return <var>handlers</var>[<var>type</var>]. + <li><p>If <var>handlers</var> contains "<code>default</code>" + return <var>handlers</var>["<code>default</code>"]. + <li><p>If <var>type</var> is "<code>beforeUnload</code>", return a <a>prompt handler configuration</a> with [=prompt handler configuration/handler=] "<code>accept</code>" and [=prompt handler configuration/notify=] false. - <li><p>If <var>handlers</var> contains "<code>default</code>" + <li><p>If <var>handlers</var> contains "<code>fallbackDefault</code>" return <var>handlers</var>["<code>default</code>"]. <li><p>Return a <a>prompt handler From add07f9c06019ad168e7be4012d9b942e16d070d Mon Sep 17 00:00:00 2001 From: James Graham <james@hoppipolla.co.uk> Date: Thu, 13 Jun 2024 18:36:44 +0100 Subject: [PATCH 3/3] Unconditionally return the unhandledPromptBehavior capability When creating a session, ensure that we always return the used value of this capability, whether or not it was passed in. --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index c97f7b73..152b43cf 100644 --- a/index.html +++ b/index.html @@ -2304,8 +2304,7 @@ <h3>Global State</h3> <li><p>Let <var>serialized user prompt handler</var> be <a>serialize the user prompt handler</a>. - <li><p>If <var>serialized user prompt handler</var> is not null, set - a property on <var>capabilities</var> with the name + <li><p>Set a property on <var>capabilities</var> with the name "<code>unhandledPromptBehavior</code>", and the value <var>serialized user prompt handler</var>. @@ -10583,7 +10582,8 @@ <h3>User Prompt Handler</h3> <p>To <dfn>serialize the user prompt handler</dfn>: <ol class=algorithm> - <li><p>If the <a>user prompt handler</a> is null, return null. + <li><p>If the <a>user prompt handler</a> is null, return + "<code>dismiss and notify</code>". <li><p>If the <a>user prompt handler</a> has [=map/size=] 1, and <a>user prompt handler</a> [=list/contains=]