Title: [219650] trunk/Source/WebKit
Revision
219650
Author
carlo...@webkit.org
Date
2017-07-18 23:08:29 -0700 (Tue, 18 Jul 2017)

Log Message

Web Automation: evaluateJavaScriptFunction should always notify the web process before returning early
https://bugs.webkit.org/show_bug.cgi?id=174623

Reviewed by Brian Burg.

It currently returns early if page, frame or scriptObject are nullptr, in which cases the UI process is not
notified. This causes test testShouldNotBeAbleToDoAnythingTheFrameIsDeletedFromUnderUs to hang, because message
DidEvaluateJavaScriptFunction is never sent when the given frame no longer exists. We should send
DidEvaluateJavaScriptFunction with WindowNotFound in case of page is nullptr and FrameNotFound if the frame is
nullptr. The scriptObject early return is actually wrong, because scriptObjectForFrame creates a new script if
there's isn't one for the given frame.

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (219649 => 219650)


--- trunk/Source/WebKit/ChangeLog	2017-07-19 06:07:00 UTC (rev 219649)
+++ trunk/Source/WebKit/ChangeLog	2017-07-19 06:08:29 UTC (rev 219650)
@@ -1,5 +1,22 @@
 2017-07-18  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        Web Automation: evaluateJavaScriptFunction should always notify the web process before returning early
+        https://bugs.webkit.org/show_bug.cgi?id=174623
+
+        Reviewed by Brian Burg.
+
+        It currently returns early if page, frame or scriptObject are nullptr, in which cases the UI process is not
+        notified. This causes test testShouldNotBeAbleToDoAnythingTheFrameIsDeletedFromUnderUs to hang, because message
+        DidEvaluateJavaScriptFunction is never sent when the given frame no longer exists. We should send
+        DidEvaluateJavaScriptFunction with WindowNotFound in case of page is nullptr and FrameNotFound if the frame is
+        nullptr. The scriptObject early return is actually wrong, because scriptObjectForFrame creates a new script if
+        there's isn't one for the given frame.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):
+
+2017-07-18  Carlos Garcia Campos  <cgar...@igalia.com>
+
         Web Automation: pending evaluate script callbacks are stored with the wrong frame ID when using the default main frame
         https://bugs.webkit.org/show_bug.cgi?id=174622
 

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (219649 => 219650)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2017-07-19 06:07:00 UTC (rev 219649)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2017-07-19 06:08:29 UTC (rev 219650)
@@ -230,16 +230,20 @@
 void WebAutomationSessionProxy::evaluateJavaScriptFunction(uint64_t pageID, uint64_t frameID, const String& function, Vector<String> arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID)
 {
     WebPage* page = WebProcess::singleton().webPage(pageID);
-    if (!page)
+    if (!page) {
+        WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidEvaluateJavaScriptFunction(callbackID, { },
+            Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::WindowNotFound)), 0);
         return;
-
+    }
     WebFrame* frame = frameID ? WebProcess::singleton().webFrame(frameID) : page->mainWebFrame();
-    if (!frame)
+    if (!frame) {
+        WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidEvaluateJavaScriptFunction(callbackID, { },
+            Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::FrameNotFound)), 0);
         return;
+    }
 
     JSObjectRef scriptObject = scriptObjectForFrame(*frame);
-    if (!scriptObject)
-        return;
+    ASSERT(scriptObject);
 
     frameID = frame->frameID();
     JSValueRef exception = nullptr;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to