This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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'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 <a>alert dialogs</a> created during <code><a>beforeunload</a></code> are subject to <a>unexpected alert handling</a>.” And a definition of alert dialogs: “<code><a>Window.alert</a></code>, <code><a>Window.confirm</a></code>, and <code><a>Window.prompt</a></code> are considered <dfn>alert dialogs</dfn>.” Then some text on how to handle the dialogs: “<a>Alert dialogs</a> block document script execution and WebDriver behaves the same way. When <a>alert dialogs</a> are created commands are free to choose if they should affect their response. The following steps may be run when a command requests <dfn>unexpected alert handling</dfn> on <var>request</var>: <ul> <li>If the <a>current alert</a> is defined: <ul> <li>Let <var>response</var>'s status be <a>unexpected alert open</a>. <li>Return response and abort the remaining steps. </ul> <li>Otherwise, return. </ul>” Then the definition of “current alert”: “The remote end must keep a global state <dfn>current alert</dfn> that is an initially left undefined <a>alert</a>. When any of the <a>alert dialogs</a> 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.