<?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>28146</bug_id>
          
          <creation_ts>2015-03-05 17:00:41 +0000</creation_ts>
          <short_desc>[WebDriver Spec]: Add RegExp as valid Javascript Command Parameter type</short_desc>
          <delta_ts>2015-03-05 22:54:05 +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>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>20860</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="David Pisoni">dpisoni</reporter>
          <assigned_to name="Browser Testing and Tools WG">public-browser-tools-testing</assigned_to>
          <cc>dburns</cc>
    
    <cc>james</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>118363</commentid>
    <comment_count>0</comment_count>
    <who name="David Pisoni">dpisoni</who>
    <bug_when>2015-03-05 17:00:41 +0000</bug_when>
    <thetext>RegExps are not currently a supported type. When Selenium WebDriver encounters them in this context it will convert them to an empty object. I&apos;m not certain if there are cross-platform issues with this, but AFAIK RegExp is broadly supported so should be a decent candidate for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118370</commentid>
    <comment_count>1</comment_count>
    <who name="David Burns :automatedtester">dburns</who>
    <bug_when>2015-03-05 21:15:12 +0000</bug_when>
    <thetext>While RegExp would be awesome unfortunately there is no way to serialize a Regexp to JSON. YOu can still create your own execute_script and pass it the string that has a regexp.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118373</commentid>
    <comment_count>2</comment_count>
    <who name="James Graham">james</who>
    <bug_when>2015-03-05 22:49:42 +0000</bug_when>
    <thetext>Well sure there is, if we wanted to support this:

{some-defined-uuid: string-that-compiles-as-regexp}

(I don&apos;t have an opinion on whether this should be supported, but it is certainly *possible* to do so).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118374</commentid>
    <comment_count>3</comment_count>
    <who name="David Pisoni">dpisoni</who>
    <bug_when>2015-03-05 22:54:05 +0000</bug_when>
    <thetext>Right, this is the sort of thing I have in my client code to work around this. Makes for some ugliness and repetition in the client code... like so:

      // test/driver side
      if (Object.prototype.toString.call(mockDef.url) == &apos;[object RegExp]&apos;) {
        // Serialize RegExp with special prefix flag
        mockDef.url = REGEXFLAG + mockDef.url.source;
      }
/*/*/*/*/
      // browser side
      if (mockDef.url.indexOf(REGEXFLAG) === 0) {
        // Marshal RegExp from special string
        mockDef.url  = new RegExp(mockDef.url.substr(3));
      }

Ugly, and of course the REGEXFLAG constant needs to be defined on both sides as well.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>