<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198913] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198913">198913</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2016-03-31 13:52:38 -0700 (Thu, 31 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Automation: Add support for script timeouts to the evaluateJavaScriptFunction command

https://bugs.webkit.org/show_bug.cgi?id=156052
rdar://problem/25457151

Reviewed by Brian Burg.

* UIProcess/Automation/Automation.json: Added callbackTimeout to evaluateJavaScriptFunction.
Also made expectsImplicitCallbackArgument optional, since it is not required. Added JavaScriptTimeout error.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::evaluateJavaScriptFunction): Added callbackTimeout.
* UIProcess/Automation/WebAutomationSession.h:
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::evaluateJavaScriptCallback): Send JavaScriptTimeout error if the timeout fired.
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Added callbackTimeout.
* WebProcess/Automation/WebAutomationSessionProxy.h:
* WebProcess/Automation/WebAutomationSessionProxy.js:
(AutomationSessionProxy.prototype.evaluateJavaScriptFunction): Set a timeout to fire if the
callback is not called, then return an error.
* WebProcess/Automation/WebAutomationSessionProxy.messages.in:
(EvaluateJavaScriptFunction): Added callbackTimeout parameter.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationAutomationjson">trunk/Source/WebKit2/UIProcess/Automation/Automation.json</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessionh">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxycpp">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyh">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyjs">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxymessagesin">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-03-30  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
+        Web Automation: Add support for script timeouts to the evaluateJavaScriptFunction command
+
+        https://bugs.webkit.org/show_bug.cgi?id=156052
+        rdar://problem/25457151
+
+        Reviewed by Brian Burg.
+
+        * UIProcess/Automation/Automation.json: Added callbackTimeout to evaluateJavaScriptFunction.
+        Also made expectsImplicitCallbackArgument optional, since it is not required. Added JavaScriptTimeout error.
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::evaluateJavaScriptFunction): Added callbackTimeout.
+        * UIProcess/Automation/WebAutomationSession.h:
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::evaluateJavaScriptCallback): Send JavaScriptTimeout error if the timeout fired.
+        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Added callbackTimeout.
+        * WebProcess/Automation/WebAutomationSessionProxy.h:
+        * WebProcess/Automation/WebAutomationSessionProxy.js:
+        (AutomationSessionProxy.prototype.evaluateJavaScriptFunction): Set a timeout to fire if the
+        callback is not called, then return an error.
+        * WebProcess/Automation/WebAutomationSessionProxy.messages.in:
+        (EvaluateJavaScriptFunction): Added callbackTimeout parameter.
+
</ins><span class="cx"> 2016-03-31  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebKit should set Original URL of a download request correctly
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationAutomationjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx">             &quot;enum&quot;: [
</span><span class="cx">                 &quot;InternalError&quot;,
</span><span class="cx">                 &quot;JavaScriptError&quot;,
</span><ins>+                &quot;JavaScriptTimeout&quot;,
</ins><span class="cx">                 &quot;WindowNotFound&quot;,
</span><span class="cx">                 &quot;FrameNotFound&quot;,
</span><span class="cx">                 &quot;NodeNotFound&quot;,
</span><span class="lines">@@ -280,7 +281,8 @@
</span><span class="cx">                 { &quot;name&quot;: &quot;frameHandle&quot;, &quot;$ref&quot;: &quot;FrameHandle&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;The handle for the frame the script should be evaluated. The main frame is used if this parameter empty string or excluded.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;function&quot;, &quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;The script to evaluate in the browsing context. It must be a function result.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;arguments&quot;, &quot;type&quot;: &quot;array&quot;, &quot;items&quot;: { &quot;type&quot;: &quot;string&quot; }, &quot;description&quot;: &quot;The arguments to pass to the function when called. They will be parsed as JSON before calling the function.&quot; },
</span><del>-                { &quot;name&quot;: &quot;expectsImplicitCallbackArgument&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;description&quot;: &quot;The function expects a callback function as the last argument. It is expected to call this callback with a result.&quot; }
</del><ins>+                { &quot;name&quot;: &quot;expectsImplicitCallbackArgument&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;The function expects a callback function as the last argument. It is expected to call this callback with a result.&quot; },
+                { &quot;name&quot;: &quot;callbackTimeout&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;The timeout in milliseconds that the implicit callback is expected to be called in, otherwise a &lt;code&gt;JavaScriptTimeout&lt;/code&gt; error is returned.&quot; }
</ins><span class="cx">             ],
</span><span class="cx">             &quot;returns&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;result&quot;, &quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;The result returned by the called function. It is JSON encoded after the function returns or calls the callback.&quot; }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -395,7 +395,7 @@
</span><span class="cx">     page-&gt;reload(reloadFromOrigin, contentBlockersEnabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAutomationSession::evaluateJavaScriptFunction(Inspector::ErrorString&amp; errorString, const String&amp; browsingContextHandle, const String* optionalFrameHandle, const String&amp; function, const Inspector::InspectorArray&amp; arguments, bool expectsImplicitCallbackArgument, Ref&lt;EvaluateJavaScriptFunctionCallback&gt;&amp;&amp; callback)
</del><ins>+void WebAutomationSession::evaluateJavaScriptFunction(Inspector::ErrorString&amp; errorString, const String&amp; browsingContextHandle, const String* optionalFrameHandle, const String&amp; function, const Inspector::InspectorArray&amp; arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref&lt;EvaluateJavaScriptFunctionCallback&gt;&amp;&amp; callback)
</ins><span class="cx"> {
</span><span class="cx">     WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
</span><span class="cx">     if (!page)
</span><span class="lines">@@ -414,10 +414,13 @@
</span><span class="cx">         argumentsVector.uncheckedAppend(argumentString);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    bool expectsImplicitCallbackArgument = optionalExpectsImplicitCallbackArgument ? *optionalExpectsImplicitCallbackArgument : false;
+    int callbackTimeout = optionalCallbackTimeout ? *optionalCallbackTimeout : 0;
+
</ins><span class="cx">     uint64_t callbackID = m_nextEvaluateJavaScriptCallbackID++;
</span><span class="cx">     m_evaluateJavaScriptFunctionCallbacks.set(callbackID, WTFMove(callback));
</span><span class="cx"> 
</span><del>-    page-&gt;process().send(Messages::WebAutomationSessionProxy::EvaluateJavaScriptFunction(frame-&gt;frameID(), function, argumentsVector, expectsImplicitCallbackArgument, callbackID), 0);
</del><ins>+    page-&gt;process().send(Messages::WebAutomationSessionProxy::EvaluateJavaScriptFunction(frame-&gt;frameID(), function, argumentsVector, expectsImplicitCallbackArgument, callbackTimeout, callbackID), 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebAutomationSession::didEvaluateJavaScriptFunction(uint64_t callbackID, const String&amp; result, const String&amp; errorType)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     void goBackInBrowsingContext(Inspector::ErrorString&amp;, const String&amp;) override;
</span><span class="cx">     void goForwardInBrowsingContext(Inspector::ErrorString&amp;, const String&amp;) override;
</span><span class="cx">     void reloadBrowsingContext(Inspector::ErrorString&amp;, const String&amp;) override;
</span><del>-    void evaluateJavaScriptFunction(Inspector::ErrorString&amp;, const String&amp; browsingContextHandle, const String* optionalFrameHandle, const String&amp; function, const Inspector::InspectorArray&amp; arguments, bool expectsImplicitCallbackArgument, Ref&lt;Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback&gt;&amp;&amp;) override;
</del><ins>+    void evaluateJavaScriptFunction(Inspector::ErrorString&amp;, const String&amp; browsingContextHandle, const String* optionalFrameHandle, const String&amp; function, const Inspector::InspectorArray&amp; arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref&lt;Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback&gt;&amp;&amp;) override;
</ins><span class="cx">     void performMouseInteraction(Inspector::ErrorString&amp;, const String&amp; handle, const Inspector::InspectorObject&amp; requestedPosition, const String&amp; mouseButton, const String&amp; mouseInteraction, const Inspector::InspectorArray&amp; keyModifiers, RefPtr&lt;Inspector::Protocol::Automation::Point&gt;&amp; updatedPosition) override;
</span><span class="cx">     void performKeyboardInteractions(Inspector::ErrorString&amp;, const String&amp; handle, const Inspector::InspectorArray&amp; interactions) override;
</span><span class="cx">     void takeScreenshot(Inspector::ErrorString&amp;, const String&amp; handle, Ref&lt;Inspector::AutomationBackendDispatcherHandler::TakeScreenshotCallback&gt;&amp;&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -126,10 +126,11 @@
</span><span class="cx"> 
</span><span class="cx"> static JSValueRef evaluateJavaScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
</span><span class="cx"> {
</span><del>-    ASSERT_ARG(argumentCount, argumentCount == 3);
</del><ins>+    ASSERT_ARG(argumentCount, argumentCount == 4);
</ins><span class="cx">     ASSERT_ARG(arguments, JSValueIsNumber(context, arguments[0]));
</span><span class="cx">     ASSERT_ARG(arguments, JSValueIsNumber(context, arguments[1]));
</span><span class="cx">     ASSERT_ARG(arguments, JSValueIsString(context, arguments[2]));
</span><ins>+    ASSERT_ARG(arguments, JSValueIsBoolean(context, arguments[3]));
</ins><span class="cx"> 
</span><span class="cx">     auto automationSessionProxy = WebProcess::singleton().automationSessionProxy();
</span><span class="cx">     if (!automationSessionProxy)
</span><span class="lines">@@ -139,8 +140,20 @@
</span><span class="cx">     uint64_t callbackID = JSValueToNumber(context, arguments[1], exception);
</span><span class="cx">     JSRetainPtr&lt;JSStringRef&gt; result(Adopt, JSValueToStringCopy(context, arguments[2], exception));
</span><span class="cx"> 
</span><del>-    automationSessionProxy-&gt;didEvaluateJavaScriptFunction(frameID, callbackID, result-&gt;string(), String());
</del><ins>+    bool resultIsErrorName = JSValueToBoolean(context, arguments[3]);
</ins><span class="cx"> 
</span><ins>+    if (resultIsErrorName) {
+        if (result-&gt;string() == &quot;JavaScriptTimeout&quot;) {
+            String errorType = Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::JavaScriptTimeout);
+            automationSessionProxy-&gt;didEvaluateJavaScriptFunction(frameID, callbackID, String(), errorType);
+        } else {
+            ASSERT_NOT_REACHED();
+            String errorType = Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InternalError);
+            automationSessionProxy-&gt;didEvaluateJavaScriptFunction(frameID, callbackID, String(), errorType);
+        }
+    } else
+        automationSessionProxy-&gt;didEvaluateJavaScriptFunction(frameID, callbackID, result-&gt;string(), String());
+
</ins><span class="cx">     return JSValueMakeUndefined(context);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -212,7 +225,7 @@
</span><span class="cx">         WebProcess::singleton().parentProcessConnection()-&gt;send(Messages::WebAutomationSession::DidEvaluateJavaScriptFunction(callbackID, String(), errorType), 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAutomationSessionProxy::evaluateJavaScriptFunction(uint64_t frameID, const String&amp; function, Vector&lt;String&gt; arguments, bool expectsImplicitCallbackArgument, uint64_t callbackID)
</del><ins>+void WebAutomationSessionProxy::evaluateJavaScriptFunction(uint64_t frameID, const String&amp; function, Vector&lt;String&gt; arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID)
</ins><span class="cx"> {
</span><span class="cx">     WebFrame* frame = WebProcess::singleton().webFrame(frameID);
</span><span class="cx">     if (!frame)
</span><span class="lines">@@ -225,8 +238,6 @@
</span><span class="cx">     JSValueRef exception = nullptr;
</span><span class="cx">     JSGlobalContextRef context = frame-&gt;jsContext();
</span><span class="cx"> 
</span><del>-    JSObjectRef callbackFunction = JSObjectMakeFunctionWithCallback(context, nullptr, evaluateJavaScriptCallback);
-
</del><span class="cx">     if (expectsImplicitCallbackArgument) {
</span><span class="cx">         auto result = m_webFramePendingEvaluateJavaScriptCallbacksMap.add(frameID, Vector&lt;uint64_t&gt;());
</span><span class="cx">         result.iterator-&gt;value.append(callbackID);
</span><span class="lines">@@ -238,7 +249,8 @@
</span><span class="cx">         JSValueMakeBoolean(context, expectsImplicitCallbackArgument),
</span><span class="cx">         JSValueMakeNumber(context, frameID),
</span><span class="cx">         JSValueMakeNumber(context, callbackID),
</span><del>-        callbackFunction
</del><ins>+        JSObjectMakeFunctionWithCallback(context, nullptr, evaluateJavaScriptCallback),
+        JSValueMakeNumber(context, callbackTimeout)
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     callPropertyFunction(context, scriptObject, ASCIILiteral(&quot;evaluateJavaScriptFunction&quot;), WTF_ARRAY_LENGTH(functionArguments), functionArguments, &amp;exception);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">     void didReceiveMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;);
</span><span class="cx"> 
</span><span class="cx">     // Called by WebAutomationSessionProxy messages
</span><del>-    void evaluateJavaScriptFunction(uint64_t frameID, const String&amp; function, Vector&lt;String&gt; arguments, bool expectsImplicitCallbackArgument, uint64_t callbackID);
</del><ins>+    void evaluateJavaScriptFunction(uint64_t frameID, const String&amp; function, Vector&lt;String&gt; arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID);
</ins><span class="cx">     void resolveChildFrameWithOrdinal(uint64_t frameID, uint32_t ordinal, uint64_t callbackID);
</span><span class="cx">     void resolveChildFrameWithNodeHandle(uint64_t frameID, const String&amp; nodeHandle, uint64_t callbackID);
</span><span class="cx">     void resolveChildFrameWithName(uint64_t frameID, const String&amp; name, uint64_t callbackID);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.js        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Public
</span><span class="cx"> 
</span><del>-    evaluateJavaScriptFunction(functionString, argumentStrings, expectsImplicitCallbackArgument, frameID, callbackID, resultCallback)
</del><ins>+    evaluateJavaScriptFunction(functionString, argumentStrings, expectsImplicitCallbackArgument, frameID, callbackID, resultCallback, callbackTimeout)
</ins><span class="cx">     {
</span><span class="cx">         // The script is expected to be a function declaration. Evaluate it inside parenthesis to get the function value.
</span><span class="cx">         let functionValue = evaluate(&quot;(&quot; + functionString + &quot;)&quot;);
</span><span class="lines">@@ -47,13 +47,19 @@
</span><span class="cx">             throw new TypeError(&quot;Script did not evaluate to a function.&quot;);
</span><span class="cx"> 
</span><span class="cx">         let argumentValues = argumentStrings.map(this._jsonParse, this);
</span><del>-        let callback = (result) =&gt; resultCallback(frameID, callbackID, this._jsonStringify(result));
</del><span class="cx"> 
</span><ins>+        let timeoutIdentifier = 0;
+
+        let reportResult = (result) =&gt; { clearTimeout(timeoutIdentifier); resultCallback(frameID, callbackID, this._jsonStringify(result), false); }
+        let reportTimeoutError = () =&gt; { clearTimeout(timeoutIdentifier); resultCallback(frameID, callbackID, &quot;JavaScriptTimeout&quot;, true); }
+
</ins><span class="cx">         if (expectsImplicitCallbackArgument) {
</span><del>-            argumentValues.push(callback);
</del><ins>+            timeoutIdentifier = setTimeout(reportTimeoutError, callbackTimeout);
+
+            argumentValues.push(reportResult);
</ins><span class="cx">             functionValue.apply(null, argumentValues);
</span><span class="cx">         } else
</span><del>-            callback(functionValue.apply(null, argumentValues));
</del><ins>+            reportResult(functionValue.apply(null, argumentValues));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     nodeForIdentifier(identifier)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in (198912 => 198913)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in        2016-03-31 20:43:41 UTC (rev 198912)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in        2016-03-31 20:52:38 UTC (rev 198913)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> 
</span><span class="cx"> messages -&gt; WebAutomationSessionProxy {
</span><del>-    EvaluateJavaScriptFunction(uint64_t frameID, String function, Vector&lt;String&gt; arguments, bool expectsImplicitCallbackArgument, uint64_t callbackID)
</del><ins>+    EvaluateJavaScriptFunction(uint64_t frameID, String function, Vector&lt;String&gt; arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID)
</ins><span class="cx"> 
</span><span class="cx">     ResolveChildFrameWithOrdinal(uint64_t frameID, uint32_t ordinal, uint64_t callbackID)
</span><span class="cx">     ResolveChildFrameWithNodeHandle(uint64_t frameID, String nodeHandle, uint64_t callbackID)
</span></span></pre>
</div>
</div>

</body>
</html>