<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - toJSDOMWindow() does not handle objects that descend from the JS DOM Window (crashes on use)"
   href="https://bugs.webkit.org/show_bug.cgi?id=146785#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - toJSDOMWindow() does not handle objects that descend from the JS DOM Window (crashes on use)"
   href="https://bugs.webkit.org/show_bug.cgi?id=146785">bug 146785</a>
              from <span class="vcard"><a class="email" href="mailto:mark.lam&#64;apple.com" title="Mark Lam &lt;mark.lam&#64;apple.com&gt;"> <span class="fn">Mark Lam</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=256676&amp;action=diff" name="attach_256676" title="Patch">attachment 256676</a> <a href="attachment.cgi?id=256676&amp;action=edit" title="Patch">[details]</a></span>
Patch

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

Some suggestions below.  I’m also not convinced yet that this fix should be implemented in the toJSDOMWindow() function.  I’m currently researching the issue.

<span class="quote">&gt; Source/WebCore/bindings/js/JSDOMWindowBase.cpp:253
&gt; +        const ClassInfo* classInfo = asObject(value)-&gt;classInfo();</span >

You’ve already computed the JSObject* above.  You can simplify this to:
    const ClassInfo* classInfo = object-&gt;classInfo();

<span class="quote">&gt; Source/WebCore/bindings/js/JSDOMWindowBase.cpp:255
&gt; +            return jsCast&lt;JSDOMWindow*&gt;(asObject(value));</span >

Ditto.  You can simplify this to:
    return jsCast&lt;JSDOMWindow*&gt;(object);

<span class="quote">&gt; Source/WebCore/bindings/js/JSDOMWindowBase.cpp:257
&gt; +            return jsCast&lt;JSDOMWindowShell*&gt;(asObject(value))-&gt;window();</span >

Ditto.  Simplify to:
    return jsCast&lt;JSDOMWindowShell*&gt;(object)-&gt;window();</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>