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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>196847</bug_id>
          
          <creation_ts>2019-04-11 19:48:51 -0700</creation_ts>
          <short_desc>WebDriver: evaluating javascript shouldn&apos;t fail if a dialog is shown</short_desc>
          <delta_ts>2019-05-07 03:59:57 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebDriver</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=197655</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Devin Rousso">hi</reporter>
          <assigned_to name="Devin Rousso">hi</assigned_to>
          <cc>bburg</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>hi</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1526606</commentid>
    <comment_count>0</comment_count>
    <who name="Devin Rousso">hi</who>
    <bug_when>2019-04-11 19:48:51 -0700</bug_when>
    <thetext>We currently send an &quot;unexpected alert open error&quot; if a dialog is shown while evaluating javascript, but we really should be silently failing with no data.

&lt;https://github.com/w3c/webdriver/issues/1253&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1526607</commentid>
    <comment_count>1</comment_count>
    <who name="Devin Rousso">hi</who>
    <bug_when>2019-04-11 19:49:01 -0700</bug_when>
    <thetext>&lt;rdar://problem/49609396&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1526608</commentid>
    <comment_count>2</comment_count>
      <attachid>367279</attachid>
    <who name="Devin Rousso">hi</who>
    <bug_when>2019-04-11 19:50:01 -0700</bug_when>
    <thetext>Created attachment 367279
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1526892</commentid>
    <comment_count>3</comment_count>
      <attachid>367279</attachid>
    <who name="Blaze Burg">bburg</who>
    <bug_when>2019-04-12 13:20:09 -0700</bug_when>
    <thetext>Comment on attachment 367279
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1526899</commentid>
    <comment_count>4</comment_count>
      <attachid>367279</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-04-12 13:47:01 -0700</bug_when>
    <thetext>Comment on attachment 367279
Patch

Clearing flags on attachment: 367279

Committed r244230: &lt;https://trac.webkit.org/changeset/244230&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1526900</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-04-12 13:47:02 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1533833</commentid>
    <comment_count>6</comment_count>
      <attachid>367279</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2019-05-07 01:58:37 -0700</bug_when>
    <thetext>Comment on attachment 367279
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=367279&amp;action=review

&gt; Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:657
&gt; -                callback-&gt;sendFailure(unexpectedAlertOpenError);
&gt; +                callback-&gt;sendSuccess(emptyString());

This is not correct, because emptyString() is not a valid JSON serialized string. JSON::Value::parseJSON() will fail when trying to handle this result. I&apos;m not even sure this is the right fix, because evaluateJavaScriptFunction message is used for other commands than executeString and actions. We handle the executeScript case in WebDriver itself, considering a success when unexpected alert open error is received. We could do the same for the actions command. This commit has caused all user_prompts test to fail, because create_dialog() fixture always fails. It executes a script to create the dialog itself (ignoring NoSuchAlertException, indeed), that is always failing now because the response from evaluateJavaScriptFunction is not a valid JSON serialized string. So, we have two ways to fix this: 

1) Roll out this patch and handle unexpected alert open in the driver for executeScript and actions commands
2) Keep handling it here, but using &quot;null&quot; instead of emptyString(). This is what we do in the web process when the result of the script can&apos;t be json stringfied. (return JSON.stringify(original, (key, value) =&gt; this._replaceJSONValue(key, value)) || &quot;null&quot;;)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>367279</attachid>
            <date>2019-04-11 19:50:01 -0700</date>
            <delta_ts>2019-04-12 13:47:01 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-196847-20190411195001.patch</filename>
            <type>text/plain</type>
            <size>1752</size>
            <attacher name="Devin Rousso">hi</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nIGIvU291cmNlL1dlYktpdC9DaGFu
Z2VMb2cKaW5kZXggMTU3ZDNhMDRjMTI2NGNkNTJiNGVkYmIzZDRlNmU0YzkzMGMzNDdjMS4uZjgz
Y2QwZjI4YzQyNmE2NGIwYmM2NGE1OWE3MzFhMWIxNzFkZTM5MSAxMDA2NDQKLS0tIGEvU291cmNl
L1dlYktpdC9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYktpdC9DaGFuZ2VMb2cKQEAgLTEsMyAr
MSwxNCBAQAorMjAxOS0wNC0xMSAgRGV2aW4gUm91c3NvICA8ZHJvdXNzb0BhcHBsZS5jb20+CisK
KyAgICAgICAgV2ViRHJpdmVyOiBldmFsdWF0aW5nIGphdmFzY3JpcHQgc2hvdWxkbid0IGZhaWwg
aWYgYSBkaWFsb2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