<html>
    <head>
      <base href="https://bugs.webkit.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:gsnedders@apple.com" title="Sam Sneddon [:gsnedders] <gsnedders@apple.com>"> <span class="fn">Sam Sneddon [:gsnedders]</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Elements cloned into an iframe cannot be accessed by webdriver"
   href="https://bugs.webkit.org/show_bug.cgi?id=228270">bug 228270</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>gsnedders@apple.com
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Elements cloned into an iframe cannot be accessed by webdriver"
   href="https://bugs.webkit.org/show_bug.cgi?id=228270#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Elements cloned into an iframe cannot be accessed by webdriver"
   href="https://bugs.webkit.org/show_bug.cgi?id=228270">bug 228270</a>
              from <span class="vcard"><a class="email" href="mailto:gsnedders@apple.com" title="Sam Sneddon [:gsnedders] <gsnedders@apple.com>"> <span class="fn">Sam Sneddon [:gsnedders]</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=434175&action=diff" name="attach_434175" title="Patch">attachment 434175</a> <a href="attachment.cgi?id=434175&action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=434175&action=review">https://bugs.webkit.org/attachment.cgi?id=434175&action=review</a>

(Non-reviewer r-)

<span class="quote">> Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js:213
> +          (value.nodeType == NodeType.ELEMENT || value.nodeType == NodeType.DOCUMENT || value instanceof ShadowRoot);</span >

The "value instanceof ShadowRoot" check still suffers from the exact same problem as described above.

My suggestion here would be something like:

let constructor = value.constructor;
do {
    if (constructor.name === "Element") return true;
} while(constructor = Object.getPrototypeOf(constructor));
return false;

(With whatever else is needed to make that safe, not thought too much about this! Still need to check that value is a non-null object, at least.)

Also: per spec this is just used by <a href="https://w3c.github.io/webdriver/#dfn-internal-json-clone-algorithm">https://w3c.github.io/webdriver/#dfn-internal-json-clone-algorithm</a>, and in that case per spec we simply want to check if its an instanceof Element; so do we even want to allow other Nodes?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>