Title: [219649] trunk/Source/WebKit
Revision
219649
Author
[email protected]
Date
2017-07-18 23:07:00 -0700 (Tue, 18 Jul 2017)

Log Message

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

Reviewed by Brian Burg.

The frameHandle argument is optional in evaluateJavaScriptFunction(), when not provided we pass 0 to the web
process. The proxy gets the web page main frame when received frame ID is 0, but the given frameID is
still used as key of m_webFramePendingEvaluateJavaScriptCallbacksMap and also passed to the _javascript_ function
as argument. I think r203442 was actually a workaround to this bug, making it even more hidden. Both
m_webFrameScriptObjectMap and m_webFramePendingEvaluateJavaScriptCallbacksMap should never have 0 as a
key, since they always use a frame ID, and the frame identifier counter starts at 1. This is causing test
testShouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError to hang, because when the page is unloaded
and didClearWindowObjectForFrame is called, we try to get the pending callbacks of frame 1, but they were stored
as frame 0 so DidEvaluateJavaScriptFunction message is never sent to the UI process.

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Use always the actual frameID from the WebFrame
we are using.
* WebProcess/Automation/WebAutomationSessionProxy.h: Do not allow 0 as a key of
m_webFramePendingEvaluateJavaScriptCallbacksMap and m_webFrameScriptObjectMap.

Modified Paths

Diff

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


--- trunk/Source/WebKit/ChangeLog	2017-07-19 05:47:23 UTC (rev 219648)
+++ trunk/Source/WebKit/ChangeLog	2017-07-19 06:07:00 UTC (rev 219649)
@@ -1,3 +1,26 @@
+2017-07-18  Carlos Garcia Campos  <[email protected]>
+
+        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
+
+        Reviewed by Brian Burg.
+
+        The frameHandle argument is optional in evaluateJavaScriptFunction(), when not provided we pass 0 to the web
+        process. The proxy gets the web page main frame when received frame ID is 0, but the given frameID is
+        still used as key of m_webFramePendingEvaluateJavaScriptCallbacksMap and also passed to the _javascript_ function
+        as argument. I think r203442 was actually a workaround to this bug, making it even more hidden. Both
+        m_webFrameScriptObjectMap and m_webFramePendingEvaluateJavaScriptCallbacksMap should never have 0 as a
+        key, since they always use a frame ID, and the frame identifier counter starts at 1. This is causing test
+        testShouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError to hang, because when the page is unloaded
+        and didClearWindowObjectForFrame is called, we try to get the pending callbacks of frame 1, but they were stored
+        as frame 0 so DidEvaluateJavaScriptFunction message is never sent to the UI process.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Use always the actual frameID from the WebFrame
+        we are using.
+        * WebProcess/Automation/WebAutomationSessionProxy.h: Do not allow 0 as a key of
+        m_webFramePendingEvaluateJavaScriptCallbacksMap and m_webFrameScriptObjectMap.
+
 2017-07-18  Andy Estes  <[email protected]>
 
         [Xcode] Enable CLANG_WARN_RANGE_LOOP_ANALYSIS

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


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2017-07-19 05:47:23 UTC (rev 219648)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2017-07-19 06:07:00 UTC (rev 219649)
@@ -241,6 +241,7 @@
     if (!scriptObject)
         return;
 
+    frameID = frame->frameID();
     JSValueRef exception = nullptr;
     JSGlobalContextRef context = frame->jsContext();
 

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h (219648 => 219649)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h	2017-07-19 05:47:23 UTC (rev 219648)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h	2017-07-19 06:07:00 UTC (rev 219649)
@@ -71,8 +71,8 @@
 
     String m_sessionIdentifier;
 
-    HashMap<uint64_t, JSObjectRef, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_webFrameScriptObjectMap;
-    HashMap<uint64_t, Vector<uint64_t>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_webFramePendingEvaluateJavaScriptCallbacksMap;
+    HashMap<uint64_t, JSObjectRef> m_webFrameScriptObjectMap;
+    HashMap<uint64_t, Vector<uint64_t>> m_webFramePendingEvaluateJavaScriptCallbacksMap;
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to