<?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>26158</bug_id>
          
          <creation_ts>2014-06-20 20:28:44 +0000</creation_ts>
          <short_desc>JSON serialization of element does not make clear that JSON represents an element</short_desc>
          <delta_ts>2014-07-28 21:53:46 +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>RESOLVED</bug_status>
          <resolution>FIXED</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>20860</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Jim Evans">james.h.evans.jr</reporter>
          <assigned_to name="Browser Testing and Tools WG">public-browser-tools-testing</assigned_to>
          <cc>dburns</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>108138</commentid>
    <comment_count>0</comment_count>
    <who name="Jim Evans">james.h.evans.jr</who>
    <bug_when>2014-06-20 20:28:44 +0000</bug_when>
    <thetext>Section 9.1 states that the WebElement interface has an attribute named &quot;id&quot;. Thus, when serialized, a reference to an element when returned from a JavaScript execution would look like this:

{&quot;id&quot;: &quot;&lt;element id&gt;&quot;}

Now consider returning a JavaScript object literal with the following JSON definition:

{&quot;id&quot;: &quot;this is my super ID value&quot;}

It will be impossible to distinguish between a legitimate WebElement reference, and an object literal when evaluating the returned JSON value. The Selenium open-source project mitigates this by using a property name of &quot;ELEMENT&quot; instead of &quot;id&quot; for element references. Using &quot;id&quot; is problematic, merely because there are any number of uses for returning an object with an &quot;id&quot; property. Renaming the property to something like &quot;webdriverElementId&quot; would likely resolve the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108139</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Evans">james.h.evans.jr</who>
    <bug_when>2014-06-20 20:30:56 +0000</bug_when>
    <thetext>Adding an additional concrete example using Java from the existing OSS project language bindings:

JavascriptExecutor executor = (JavascriptExecutor)driver;
 
// Can value1 be cast to a WebElement in the Java bindings?
// It should be able to, because that&apos;s what it represents.
Object value1 = executor.executeScript(&quot;return document.getElementById(&apos;foo&apos;);&quot;);
 
// value2 should be castable to a Map&lt;String, Object&gt;, because
// we&apos;re returning an object literal, but how can the language
// binding know that the result *isn&apos;t* a WebElement. There&apos;s
// no way to tell the difference by looking only at the serialized
// JSON response.
Object value2 = executor.executeScript(&quot;return { \&quot;id\&quot;: \&quot;this is my fake element id\&quot; };&quot;);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109392</commentid>
    <comment_count>2</comment_count>
    <who name="David Burns :automatedtester">dburns</who>
    <bug_when>2014-07-28 16:43:41 +0000</bug_when>
    <thetext>This will be updated as http://www.w3.org/2014/07/07-testing-minutes.html#action25</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109424</commentid>
    <comment_count>3</comment_count>
    <who name="David Burns :automatedtester">dburns</who>
    <bug_when>2014-07-28 21:53:46 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webdriver/rev/d81488ae4045

I did not update section 14 with this patch as that section is currently being rewritten after f2f in London</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>