Title: [239074] trunk/Source/WebKit
Revision
239074
Author
bb...@apple.com
Date
2018-12-11 09:39:16 -0800 (Tue, 11 Dec 2018)

Log Message

SimulatedInputDispatcher::transitionInputSourceToState() can reuse a moved-from completion handler
https://bugs.webkit.org/show_bug.cgi?id=191155
<rdar://problem/45745569>

Reviewed by Joseph Pecoraro.

* UIProcess/Automation/SimulatedInputDispatcher.cpp:
(WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
Add an ASSERT to guard against unexpected inputs where >1 VirtualKey changes per state.
webkitdriver needs to be updated to not produce such states in this scenario, but this will
avoid a runtime crash caused by trying to call a moved-out completion handler a second time.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (239073 => 239074)


--- trunk/Source/WebKit/ChangeLog	2018-12-11 15:14:51 UTC (rev 239073)
+++ trunk/Source/WebKit/ChangeLog	2018-12-11 17:39:16 UTC (rev 239074)
@@ -1,3 +1,17 @@
+2018-12-11  Brian Burg  <bb...@apple.com>
+
+        SimulatedInputDispatcher::transitionInputSourceToState() can reuse a moved-from completion handler
+        https://bugs.webkit.org/show_bug.cgi?id=191155
+        <rdar://problem/45745569>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UIProcess/Automation/SimulatedInputDispatcher.cpp:
+        (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
+        Add an ASSERT to guard against unexpected inputs where >1 VirtualKey changes per state.
+        webkitdriver needs to be updated to not produce such states in this scenario, but this will
+        avoid a runtime crash caused by trying to call a moved-out completion handler a second time.
+
 2018-12-11  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r239071.

Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp (239073 => 239074)


--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp	2018-12-11 15:14:51 UTC (rev 239073)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp	2018-12-11 17:39:16 UTC (rev 239074)
@@ -297,8 +297,13 @@
             LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyRelease[key=%c] for transition to %d.%d", this, a.pressedCharKey.value(), m_keyframeIndex, m_inputSourceStateIndex);
             m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, a.pressedCharKey.value(), WTFMove(eventDispatchFinished));
         } else if (a.pressedVirtualKeys != b.pressedVirtualKeys) {
+            bool simulatedAnInteraction = false;
             for (VirtualKey key : b.pressedVirtualKeys) {
                 if (!a.pressedVirtualKeys.contains(key)) {
+                    ASSERT_WITH_MESSAGE(!simulatedAnInteraction, "Only one VirtualKey may differ at a time between two input source states.");
+                    if (simulatedAnInteraction)
+                        continue;
+                    simulatedAnInteraction = true;
 #if !LOG_DISABLED
                     String virtualKeyName = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(key);
                     LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyPress[key=%s] for transition to %d.%d", this, virtualKeyName.utf8().data(), m_keyframeIndex, m_inputSourceStateIndex);
@@ -309,6 +314,10 @@
 
             for (VirtualKey key : a.pressedVirtualKeys) {
                 if (!b.pressedVirtualKeys.contains(key)) {
+                    ASSERT_WITH_MESSAGE(!simulatedAnInteraction, "Only one VirtualKey may differ at a time between two input source states.");
+                    if (simulatedAnInteraction)
+                        continue;
+                    simulatedAnInteraction = true;
 #if !LOG_DISABLED
                     String virtualKeyName = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(key);
                     LOG(Automation, "SimulatedInputDispatcher[%p]: simulating KeyRelease[key=%s] for transition to %d.%d", this, virtualKeyName.utf8().data(), m_keyframeIndex, m_inputSourceStateIndex);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to