<?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>28060</bug_id>
          
          <creation_ts>2015-02-19 22:53:58 +0000</creation_ts>
          <short_desc>Should be possible to return errors with executeAsyncScript</short_desc>
          <delta_ts>2016-09-20 11:30: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>Linux</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>
          
          <blocked>24121</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter>jleyba</reporter>
          <assigned_to name="Browser Testing and Tools WG">public-browser-tools-testing</assigned_to>
          <cc>dburns</cc>
    
    <cc>juangj</cc>
    
    <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>118043</commentid>
    <comment_count>0</comment_count>
    <who name="">jleyba</who>
    <bug_when>2015-02-19 22:53:58 +0000</bug_when>
    <thetext>The callback provided to the executeAsyncScript function only accepts a single argument that is always treated as a successful completion. It should be possible for users to call this function with an error to indicate their script failed.

Node.js has popularized the &quot;Error-first&quot; callback approach: errors are passed as the first argument, successful values the second.

Another option would be to standardize on the Error-type. If the callback is invoked with an instanceof Error, the script is marked as a failure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123970</commentid>
    <comment_count>1</comment_count>
    <who name="">jleyba</who>
    <bug_when>2015-10-27 17:54:44 +0000</bug_when>
    <thetext>Here&apos;s another option:

Change executeScript to recognize Promise[1] return values and eliminate executeAsyncScript as a command.

If executeScript returns a promise, wait for it to settle. If the promise is resolved, use the resolved value as the command result. If the promise is rejected, return the reason with the command failure.

If the promise doesn&apos;t resolve before the script timeout expires, fail the command.

If there is a page unload event before the promise is resolved, fail the command (covering existing behavior of executeAsyncScript).

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>