<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Add WebAutomationSessionProxy for WebProcess side automation tasks"
   href="https://bugs.webkit.org/show_bug.cgi?id=155221#c7">Comment # 7</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Add WebAutomationSessionProxy for WebProcess side automation tasks"
   href="https://bugs.webkit.org/show_bug.cgi?id=155221">bug 155221</a>
              from <span class="vcard"><a class="email" href="mailto:timothy&#64;apple.com" title="Timothy Hatcher &lt;timothy&#64;apple.com&gt;"> <span class="fn">Timothy Hatcher</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=273551&amp;action=diff" name="attach_273551" title="WIP Sketch v2">attachment 273551</a> <a href="attachment.cgi?id=273551&amp;action=edit" title="WIP Sketch v2">[details]</a></span>
WIP Sketch v2

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

<span class="quote">&gt; Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp:258
&gt; +    page-&gt;process().send(Messages::WebAutomationSessionProxy::EvaluateJavaScript(page-&gt;mainFrame()-&gt;frameID(), WTF::emptyString()), 0);</span >

Note: mainFrame can be null. It is null when the WebPageProxy is first created. I am not sure on when it is available yet, be we should null check it.

<span class="quote">&gt; Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in:25
&gt; +messages -&gt; WebAutomationSession {
&gt; +    Test()
&gt; +}</span >

We will likely need these messages to the UIProcess to implement execute_async or any other events.

<span class="quote">&gt; Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp:101
&gt; +    JSRetainPtr&lt;JSStringRef&gt; testString(Adopt, JSStringCreateWithUTF8CString(&quot;test&quot;));
&gt; +    JSObjectRef testFunction = (JSObjectRef)JSObjectGetProperty(context, scriptObject, testString.get(), &amp;exception);
&gt; +    RELEASE_ASSERT(!exception);
&gt; +    RELEASE_ASSERT(JSObjectIsFunction(context, testFunction));
&gt; +
&gt; +    JSObjectCallAsFunction(context, testFunction, nullptr, 0, nullptr, &amp;exception);
&gt; +    RELEASE_ASSERT(!exception);</span >

Just a test. This would call JSEvaluateScript and pass the result to the injected script for processing (turning elements into handles, etc.)

<span class="quote">&gt; Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js:43
&gt; +    test()
&gt; +    {
&gt; +        console.log(&quot;Hello World!&quot;);
&gt; +    }</span >

This gets called in the end by requesting the refresh endpoint right now.

<span class="quote">&gt; Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:1584
&gt; +    if (auto automationSessionProxy = WebProcess::singleton().automationSessionProxy())
&gt; +        automationSessionProxy-&gt;didClearWindowObjectForFrame(*m_frame);</span >

Needed so we unprotect our script object ref.</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>