<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26962</bug_id>
          
          <creation_ts>2014-10-03 16:23:42 +0000</creation_ts>
          <short_desc>Define what response should be sent when an alert is open</short_desc>
          <delta_ts>2014-10-03 16:23:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Browser Test/Tools WG</product>
          <component>WebDriver</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andreas Tolfsen">ato</reporter>
          <assigned_to name="Browser Testing and Tools WG">public-browser-tools-testing</assigned_to>
          <cc>mike</cc>
          
          <qa_contact name="Browser Testing and Tools WG">public-browser-tools-testing</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112657</commentid>
    <comment_count>0</comment_count>
    <who name="Andreas Tolfsen">ato</who>
    <bug_when>2014-10-03 16:23:42 +0000</bug_when>
    <thetext>Section 5.2.1 says that “If any modal dialog box, such as those opened by on window.onbeforeunload or window.alert, is opened at any point in the page load, a response MUST be sent.”

Because we need to do this as a precondition for almost all commands I suggest we make it a definition that each command&apos;s algorithm can refer to.

The language also need to be cleaned up, and I suggest something along the lines of:

- Define a global state that signifies whether an alert dialogue is open.
- Create a definition of how what steps to take when the previous state is true, including the steps to populate the response with the correct status.
- Add this as a precondition to all commands where we need to check for this.

I imagine we can use a language like this for the POST /session/{session_id}/url command:

“All &lt;a&gt;alert dialogs&lt;/a&gt; created during &lt;code&gt;&lt;a&gt;beforeunload&lt;/a&gt;&lt;/code&gt; are subject to &lt;a&gt;unexpected alert handling&lt;/a&gt;.”

And a definition of alert dialogs:

“&lt;code&gt;&lt;a&gt;Window.alert&lt;/a&gt;&lt;/code&gt;, &lt;code&gt;&lt;a&gt;Window.confirm&lt;/a&gt;&lt;/code&gt;, and &lt;code&gt;&lt;a&gt;Window.prompt&lt;/a&gt;&lt;/code&gt; are considered &lt;dfn&gt;alert dialogs&lt;/dfn&gt;.”

Then some text on how to handle the dialogs:

“&lt;a&gt;Alert dialogs&lt;/a&gt; block document script execution and WebDriver behaves the same way.  When &lt;a&gt;alert dialogs&lt;/a&gt; are created commands are free to choose if they should affect their response.  The following steps may be run when a command requests &lt;dfn&gt;unexpected alert handling&lt;/dfn&gt; on &lt;var&gt;request&lt;/var&gt;:

&lt;ul&gt;
 &lt;li&gt;If the &lt;a&gt;current alert&lt;/a&gt; is defined:
  &lt;ul&gt;
   &lt;li&gt;Let &lt;var&gt;response&lt;/var&gt;&apos;s status be &lt;a&gt;unexpected alert open&lt;/a&gt;.
   &lt;li&gt;Return response and abort the remaining steps.
  &lt;/ul&gt;
 &lt;li&gt;Otherwise, return.
&lt;/ul&gt;”

Then the definition of “current alert”:

“The remote end must keep a global state &lt;dfn&gt;current alert&lt;/dfn&gt; that is an initially left undefined &lt;a&gt;alert&lt;/a&gt;.  When any of the &lt;a&gt;alert dialogs&lt;/a&gt; appear, this state must be updated with a reference to that alert.”

And then we need a definition of an “alert” struct which we can use in the algorithm for interacting with the alert.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>