Title: [265515] trunk
Revision
265515
Author
[email protected]
Date
2020-08-11 14:04:11 -0700 (Tue, 11 Aug 2020)

Log Message

iOS: Scrolling and touch events sporadically stop working after navigating
https://bugs.webkit.org/show_bug.cgi?id=215368
<rdar://problem/65801531>

Reviewed by Wenson Hsieh.

Source/WebKit:

Test: fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html

WebPageProxy::handlePreventableTouchEvent keeps a counter of the number
of outstanding "preventable" touch events that it is waiting to hear
from the Web Content process about. This counter is incremented when the
event is dispatched to the Web Content process's EventHandler queue,
and decremented when the reply (whether it was handled or not) comes
back from the Web Content process. While the counter is non-zero, all
deferrable gestures remain deferred (and when it returns to zero, the
WKDeferringGestureRecognizer gate is lifted, and events are allowed to flow).
This means that it is very important that every event eventually reply
about its handling status.

Before this change, when the Web Content process is navigating, and reaches didCommitLoad,
it cleared all queued touch events, without replying to to the UI process.
Thus, there is a small window of time in which an incoming touch event will
end up in the queue, *not* get dispatched/replied, and then get dropped on
the floor in didCommitLoad. Most events do not meet this fate, because they
are handled promptly, and commitLoad/didCommitLoad tend to be very quick.
However, if the Web Content process ends up spending any significant amount
of time under commitLoad (say, in an unload handler, or in media frameworks),
any incoming touch events during that time will get lost, and the UI process'
count of outstanding events will end up getting stuck non-zero.

Fix this by always pretending that the page ate any events that were outstanding
when didCommitLoad occurs, instead of just dropping them on the floor.

* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::doneWithTouchEvent):
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::takeQueuedTouchEventsForPage):
(WebKit::EventDispatcher::clearQueuedTouchEventsForPage): Deleted.
(WebKit::EventDispatcher::getQueuedTouchEventsForPage): Deleted.
Also, rename getQueuedTouchEventsForPage to takeQueuedTouchEventsForPage,
since it removes the queue from EventDispatcher's set.

* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::touchEventSync):
(WebKit::WebPage::didCommitLoad):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::cancelAsynchronousTouchEvents):

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::runUIScriptImmediately):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::runUISideScriptImmediately):
(WTR::TestInvocation::runUISideScriptAfterUpdateCallback):
* WebKitTestRunner/TestInvocation.h:
Add a variant of runUISideScript that runs the script without
waiting for a rendering update.

It makes sense for the default runUISideScript to wait for a rendering
update -- nearly every test is either unaffected or improved by this --
but for the test for this bug, since we have hung the Web Content process
main thread intentionally, we will not see a rendering update, and so
the UI-side script will never run.

LayoutTests:

* fast/events/touch/ios/resources/finish-test-after-scrolling-with-touch-event-handlers.html: Added.
* fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start-expected.txt: Added.
* fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html: Added.
Add a test that ensures that a page that dispatches events in beforeunload,
receiving preventable touch events during the next page's commitLoad does not result
in scrolling being stuck.

Before this change, this test would time out.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265514 => 265515)


--- trunk/LayoutTests/ChangeLog	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/LayoutTests/ChangeLog	2020-08-11 21:04:11 UTC (rev 265515)
@@ -1,3 +1,20 @@
+2020-08-11  Tim Horton  <[email protected]>
+
+        iOS: Scrolling and touch events sporadically stop working after navigating
+        https://bugs.webkit.org/show_bug.cgi?id=215368
+        <rdar://problem/65801531>
+
+        Reviewed by Wenson Hsieh.
+
+        * fast/events/touch/ios/resources/finish-test-after-scrolling-with-touch-event-handlers.html: Added.
+        * fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start-expected.txt: Added.
+        * fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html: Added.
+        Add a test that ensures that a page that dispatches events in beforeunload,
+        receiving preventable touch events during the next page's commitLoad does not result
+        in scrolling being stuck.
+
+        Before this change, this test would time out.
+
 2020-08-11  Darin Adler  <[email protected]>
 
         LayoutTest accessibility/mac/select-element-selection-with-optgroups.html is a flaky failure

Added: trunk/LayoutTests/fast/events/touch/ios/resources/finish-test-after-scrolling-with-touch-event-handlers.html (0 => 265515)


--- trunk/LayoutTests/fast/events/touch/ios/resources/finish-test-after-scrolling-with-touch-event-handlers.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/resources/finish-test-after-scrolling-with-touch-event-handlers.html	2020-08-11 21:04:11 UTC (rev 265515)
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+<head>
+    <script src=""
+    <style>
+    html, body {
+        width: 100%;
+        height: 100%;
+        margin: 0;
+    }
+
+    #scroller {
+        overflow: scroll;
+        width: 200px;
+        height: 200px;
+        border: 2px solid black;
+    }
+
+    #content {
+        width: 100%;
+        height: 1000px;
+    }
+    </style>
+    <script>
+        async function finishTest() {
+            const scroller = document.getElementById("scroller");
+            scroller.addEventListener("touchstart", () => { });
+            scroller.addEventListener("touchend", () => { });
+            scroller.addEventListener("scroll", () => { 
+                content.textContent = "Scrolled!";
+                testRunner.notifyDone()
+            }, { once : true });
+
+            const eventStreamData = new UIHelper.EventStreamBuilder()
+                .begin(100, 190)
+                .move(100, 10, 1)
+                .move(100, 190, 1)
+                .move(100, 100, 0.5)
+                .end()
+                .takeResult();
+
+            await UIHelper.sendEventStream(eventStreamData);
+        }
+
+        addEventListener("load", finishTest);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div id="content"></div>
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start-expected.txt (0 => 265515)


--- trunk/LayoutTests/fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start-expected.txt	2020-08-11 21:04:11 UTC (rev 265515)
@@ -0,0 +1 @@
+Scrolled!

Added: trunk/LayoutTests/fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html (0 => 265515)


--- trunk/LayoutTests/fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html	2020-08-11 21:04:11 UTC (rev 265515)
@@ -0,0 +1,33 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+<head>
+    <script src=""
+    <script>
+        function runTest() {
+            const tapper = document.getElementById("tapper");
+            tapper.addEventListener("touchstart", () => { });
+            tapper.addEventListener("touchend", () => { });
+
+            const x = tapper.offsetLeft + (tapper.offsetWidth / 2);
+            const y = tapper.offsetTop + (tapper.offsetHeight / 2);
+
+            window._onbeforeunload_ = function() {
+                testRunner.runUIScriptImmediately(`
+                    uiController.doubleTapAtPoint(${x}, ${y}, .01, function() {
+                        uiController.uiScriptComplete();
+                    });`);
+            };
+
+            window.location.href = ""
+        }
+
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+        addEventListener("load", runTest);
+    </script>
+</head>
+<body>
+    <div id="tapper">Tap Here</div>
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (265514 => 265515)


--- trunk/Source/WebKit/ChangeLog	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/ChangeLog	2020-08-11 21:04:11 UTC (rev 265515)
@@ -1,3 +1,55 @@
+2020-08-11  Tim Horton  <[email protected]>
+
+        iOS: Scrolling and touch events sporadically stop working after navigating
+        https://bugs.webkit.org/show_bug.cgi?id=215368
+        <rdar://problem/65801531>
+
+        Reviewed by Wenson Hsieh.
+
+        Test: fast/events/touch/ios/touch-event-stall-after-navigating-with-pending-asynchronous-touch-start.html
+
+        WebPageProxy::handlePreventableTouchEvent keeps a counter of the number
+        of outstanding "preventable" touch events that it is waiting to hear
+        from the Web Content process about. This counter is incremented when the
+        event is dispatched to the Web Content process's EventHandler queue,
+        and decremented when the reply (whether it was handled or not) comes
+        back from the Web Content process. While the counter is non-zero, all
+        deferrable gestures remain deferred (and when it returns to zero, the
+        WKDeferringGestureRecognizer gate is lifted, and events are allowed to flow).
+        This means that it is very important that every event eventually reply
+        about its handling status.
+
+        Before this change, when the Web Content process is navigating, and reaches didCommitLoad,
+        it cleared all queued touch events, without replying to to the UI process.
+        Thus, there is a small window of time in which an incoming touch event will
+        end up in the queue, *not* get dispatched/replied, and then get dropped on
+        the floor in didCommitLoad. Most events do not meet this fate, because they
+        are handled promptly, and commitLoad/didCommitLoad tend to be very quick.
+        However, if the Web Content process ends up spending any significant amount
+        of time under commitLoad (say, in an unload handler, or in media frameworks),
+        any incoming touch events during that time will get lost, and the UI process'
+        count of outstanding events will end up getting stuck non-zero.
+
+        Fix this by always pretending that the page ate any events that were outstanding
+        when didCommitLoad occurs, instead of just dropping them on the floor.
+
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::doneWithTouchEvent):
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::takeQueuedTouchEventsForPage):
+        (WebKit::EventDispatcher::clearQueuedTouchEventsForPage): Deleted.
+        (WebKit::EventDispatcher::getQueuedTouchEventsForPage): Deleted.
+        Also, rename getQueuedTouchEventsForPage to takeQueuedTouchEventsForPage,
+        since it removes the queue from EventDispatcher's set.
+
+        * WebProcess/WebPage/EventDispatcher.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::touchEventSync):
+        (WebKit::WebPage::didCommitLoad):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::cancelAsynchronousTouchEvents):
+
 2020-08-11  Philippe Normand  <[email protected]>
 
         [GStreamer] gst-full standalone library support

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (265514 => 265515)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-08-11 21:04:11 UTC (rev 265515)
@@ -450,9 +450,9 @@
 }
 
 #if ENABLE(TOUCH_EVENTS)
-void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& nativeWebtouchEvent, bool eventHandled)
+void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& nativeWebTouchEvent, bool eventHandled)
 {
-    [m_contentView _webTouchEvent:nativeWebtouchEvent preventsNativeGestures:eventHandled];
+    [m_contentView _webTouchEvent:nativeWebTouchEvent preventsNativeGestures:eventHandled];
 }
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (265514 => 265515)


--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2020-08-11 21:04:11 UTC (rev 265515)
@@ -176,15 +176,9 @@
 #endif
 
 #if ENABLE(IOS_TOUCH_EVENTS)
-void EventDispatcher::clearQueuedTouchEventsForPage(const WebPage& webPage)
+void EventDispatcher::takeQueuedTouchEventsForPage(const WebPage& webPage, TouchEventQueue& destinationQueue)
 {
     LockHolder locker(&m_touchEventsLock);
-    m_touchEvents.remove(webPage.identifier());
-}
-
-void EventDispatcher::getQueuedTouchEventsForPage(const WebPage& webPage, TouchEventQueue& destinationQueue)
-{
-    LockHolder locker(&m_touchEventsLock);
     destinationQueue = m_touchEvents.take(webPage.identifier());
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h (265514 => 265515)


--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h	2020-08-11 21:04:11 UTC (rev 265515)
@@ -63,9 +63,7 @@
 
 #if ENABLE(IOS_TOUCH_EVENTS)
     using TouchEventQueue = Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>;
-
-    void clearQueuedTouchEventsForPage(const WebPage&);
-    void getQueuedTouchEventsForPage(const WebPage&, TouchEventQueue&);
+    void takeQueuedTouchEventsForPage(const WebPage&, TouchEventQueue&);
 #endif
 
     void initializeConnection(IPC::Connection*);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (265514 => 265515)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-08-11 21:04:11 UTC (rev 265515)
@@ -2985,7 +2985,7 @@
     m_pendingSynchronousTouchEventReply = WTFMove(reply);
 
     EventDispatcher::TouchEventQueue queuedEvents;
-    WebProcess::singleton().eventDispatcher().getQueuedTouchEventsForPage(*this, queuedEvents);
+    WebProcess::singleton().eventDispatcher().takeQueuedTouchEventsForPage(*this, queuedEvents);
     dispatchAsynchronousTouchEvents(queuedEvents);
 
     bool handled = true;
@@ -5987,7 +5987,9 @@
     m_lastLayerTreeTransactionIdAndPageScaleBeforeScalingPage = WTF::nullopt;
 
 #if ENABLE(IOS_TOUCH_EVENTS)
-    WebProcess::singleton().eventDispatcher().clearQueuedTouchEventsForPage(*this);
+    EventDispatcher::TouchEventQueue queuedEvents;
+    WebProcess::singleton().eventDispatcher().takeQueuedTouchEventsForPage(*this, queuedEvents);
+    cancelAsynchronousTouchEvents(queuedEvents);
 #endif
 #endif // PLATFORM(IOS_FAMILY)
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (265514 => 265515)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2020-08-11 21:04:11 UTC (rev 265515)
@@ -759,6 +759,7 @@
 
 #if PLATFORM(IOS_FAMILY) && ENABLE(IOS_TOUCH_EVENTS)
     void dispatchAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue);
+    void cancelAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue);
 #endif
 
     bool hasRichlyEditableSelection() const;

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (265514 => 265515)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-08-11 21:04:11 UTC (rev 265515)
@@ -3943,6 +3943,15 @@
             send(Messages::WebPageProxy::BoolCallback(handled, *eventAndCallbackID.second));
     }
 }
+
+void WebPage::cancelAsynchronousTouchEvents(const Vector<std::pair<WebTouchEvent, Optional<CallbackID>>, 1>& queue)
+{
+    for (auto& eventAndCallbackID : queue) {
+        if (!eventAndCallbackID.second)
+            continue;
+        send(Messages::WebPageProxy::BoolCallback(true, *eventAndCallbackID.second));
+    }
+}
 #endif
 
 void WebPage::computePagesForPrintingAndDrawToPDF(WebCore::FrameIdentifier frameID, const PrintInfo& printInfo, CallbackID callbackID, Messages::WebPage::ComputePagesForPrintingAndDrawToPDF::DelayedReply&& reply)

Modified: trunk/Tools/ChangeLog (265514 => 265515)


--- trunk/Tools/ChangeLog	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Tools/ChangeLog	2020-08-11 21:04:11 UTC (rev 265515)
@@ -1,3 +1,29 @@
+2020-08-11  Tim Horton  <[email protected]>
+
+        iOS: Scrolling and touch events sporadically stop working after navigating
+        https://bugs.webkit.org/show_bug.cgi?id=215368
+        <rdar://problem/65801531>
+
+        Reviewed by Wenson Hsieh.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::runUIScriptImmediately):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+        (WTR::TestInvocation::runUISideScriptImmediately):
+        (WTR::TestInvocation::runUISideScriptAfterUpdateCallback):
+        * WebKitTestRunner/TestInvocation.h:
+        Add a variant of runUISideScript that runs the script without
+        waiting for a rendering update.
+
+        It makes sense for the default runUISideScript to wait for a rendering
+        update -- nearly every test is either unaffected or improved by this --
+        but for the test for this bug, since we have hung the Web Content process
+        main thread intentionally, we will not see a rendering update, and so
+        the UI-side script will never run.
+
 2020-08-11  Darin Adler  <[email protected]>
 
         LayoutTest accessibility/mac/select-element-selection-with-optgroups.html is a flaky failure

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (265514 => 265515)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2020-08-11 21:04:11 UTC (rev 265515)
@@ -275,6 +275,7 @@
 
     // UI Process Testing
     void runUIScript(DOMString script, object callback);
+    void runUIScriptImmediately(DOMString script, object callback);
 
     void clearTestRunnerCallbacks();
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (265514 => 265515)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2020-08-11 21:04:11 UTC (rev 265515)
@@ -1324,6 +1324,27 @@
     WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), testDictionary.get());
 }
 
+void TestRunner::runUIScriptImmediately(JSStringRef script, JSValueRef callback)
+{
+    unsigned callbackID = nextUIScriptCallbackID();
+    cacheTestRunnerCallback(callbackID, callback);
+
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("RunUIProcessScriptImmediately"));
+
+    WKRetainPtr<WKMutableDictionaryRef> testDictionary = adoptWK(WKMutableDictionaryCreate());
+
+    WKRetainPtr<WKStringRef> scriptKey = adoptWK(WKStringCreateWithUTF8CString("Script"));
+    WKRetainPtr<WKStringRef> scriptValue = adoptWK(WKStringCreateWithJSString(script));
+
+    WKRetainPtr<WKStringRef> callbackIDKey = adoptWK(WKStringCreateWithUTF8CString("CallbackID"));
+    WKRetainPtr<WKUInt64Ref> callbackIDValue = adoptWK(WKUInt64Create(callbackID));
+
+    WKDictionarySetItem(testDictionary.get(), scriptKey.get(), scriptValue.get());
+    WKDictionarySetItem(testDictionary.get(), callbackIDKey.get(), callbackIDValue.get());
+
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), testDictionary.get());
+}
+
 void TestRunner::runUIScriptCallback(unsigned callbackID, JSStringRef result)
 {
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::singleton().page()->page());

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (265514 => 265515)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2020-08-11 21:04:11 UTC (rev 265515)
@@ -350,6 +350,7 @@
     void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
 
     void runUIScript(JSStringRef script, JSValueRef callback);
+    void runUIScriptImmediately(JSStringRef script, JSValueRef callback);
     void runUIScriptCallback(unsigned callbackID, JSStringRef result);
 
     // Contextual menu actions

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (265514 => 265515)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2020-08-11 21:04:11 UTC (rev 265515)
@@ -775,6 +775,20 @@
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScriptImmediately")) {
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> scriptKey = adoptWK(WKStringCreateWithUTF8CString("Script"));
+        WKRetainPtr<WKStringRef> callbackIDKey = adoptWK(WKStringCreateWithUTF8CString("CallbackID"));
+
+        UIScriptInvocationData* invocationData = new UIScriptInvocationData();
+        invocationData->testInvocation = this;
+        invocationData->callbackID = (unsigned)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, callbackIDKey.get())));
+        invocationData->scriptString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, scriptKey.get()));
+        m_pendingUIScriptInvocationData = invocationData;
+        runUISideScriptImmediately(nullptr, invocationData);
+        return;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "InstallCustomMenuAction")) {
         auto messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
         WKRetainPtr<WKStringRef> nameKey = adoptWK(WKStringCreateWithUTF8CString("name"));
@@ -1861,7 +1875,7 @@
     return nullptr;
 }
 
-void TestInvocation::runUISideScriptAfterUpdateCallback(WKErrorRef, void* context)
+void TestInvocation::runUISideScriptImmediately(WKErrorRef, void* context)
 {
     UIScriptInvocationData* data = ""
     if (TestInvocation* invocation = data->testInvocation) {
@@ -1871,6 +1885,11 @@
     delete data;
 }
 
+void TestInvocation::runUISideScriptAfterUpdateCallback(WKErrorRef error, void* context)
+{
+    runUISideScriptImmediately(error, context);
+}
+
 void TestInvocation::runUISideScript(WKStringRef script, unsigned scriptCallbackID)
 {
     m_pendingUIScriptInvocationData = nullptr;

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (265514 => 265515)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2020-08-11 20:58:28 UTC (rev 265514)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2020-08-11 21:04:11 UTC (rev 265515)
@@ -130,6 +130,7 @@
         TestInvocation* testInvocation;
     };
     static void runUISideScriptAfterUpdateCallback(WKErrorRef, void* context);
+    static void runUISideScriptImmediately(WKErrorRef, void* context);
 
     bool shouldLogHistoryClientCallbacks() const;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to