Title: [192314] trunk
Revision
192314
Author
wenson_hs...@apple.com
Date
2015-11-11 10:15:56 -0800 (Wed, 11 Nov 2015)

Log Message

UI-side scripts in WebKitTestRunner should wait until event handling completes before finishing
https://bugs.webkit.org/show_bug.cgi?id=151101
<rdar://problem/23428601>

Reviewed by Simon Fraser.

Tools:

WebKitTestRunner may still crash in the scenario where a marker event is dequeued and handled
after uiScriptComplete has been called. This patch teaches the UI script execution context to
defer script completion until all non-persistent tasks (currently tap, double tap and hardware
keyboard) have been handled, so marker events will no longer bleed through tests.

We accomplish this by changing the behavior of uiScriptComplete. When calling uiScriptComplete,
we store that a request to complete the UI-side script for the current parent callback has been
made. Subsequently, when a callback (either persistent or non-persistent) finishes invoking and
a request has been made to complete the UI script (this request may have been made when running
a previous callback) we check if all the non-persistent callbacks that have the same parent
callback as the current one have finished. If so, we complete the callback immediately;
otherwise, we wait until the in-flight non-persistent callbacks finish execution to complete the
UI script.

This patch also refactors some logic in UIScriptContext. It introduces a new convention for
assigning IDs to callbacks: IDs 1000 and above are treated as non-persistent callbacks, whereas
IDs between 0 and 999 are persistent task callbacks. This is similar to the existing convention
for assigning IDs in the 100s range to parent callbacks, and allows us to easily differentiate
between callbacks that are persistent and non-persistent, as well as determine when an existing
persistent callback must be unregistered before a new callback function can be set.

* WebKitTestRunner/UIScriptContext/UIScriptContext.cpp:
(isPersistentCallbackID):
(UIScriptContext::runUIScript):
(UIScriptContext::nextTaskCallbackID):
(UIScriptContext::prepareForAsyncTask):
(UIScriptContext::asyncTaskComplete):
(UIScriptContext::registerCallback):
(UIScriptContext::fireCallback):
(UIScriptContext::requestUIScriptCompletion):
(UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):
(UIScriptContext::currentParentCallbackHasOutstandingAsyncTasks):
(UIScriptContext::uiScriptComplete): Deleted.
* WebKitTestRunner/UIScriptContext/UIScriptContext.h:
(WTR::UIScriptContext::currentParentCallbackIsPendingCompletion):
* WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setWillBeginZoomingCallback):
(WTR::UIScriptController::willBeginZoomingCallback):
(WTR::UIScriptController::setDidEndZoomingCallback):
(WTR::UIScriptController::didEndZoomingCallback):
(WTR::UIScriptController::setDidShowKeyboardCallback):
(WTR::UIScriptController::didShowKeyboardCallback):
(WTR::UIScriptController::setDidHideKeyboardCallback):
(WTR::UIScriptController::didHideKeyboardCallback):
(WTR::UIScriptController::uiScriptComplete):
* WebKitTestRunner/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::doAsyncTask):
(WTR::UIScriptController::zoomToScale):
(WTR::UIScriptController::singleTapAtPoint):
(WTR::UIScriptController::doubleTapAtPoint):
(WTR::UIScriptController::typeCharacterUsingHardwareKeyboard):
(WTR::UIScriptController::platformSetWillBeginZoomingCallback):
(WTR::UIScriptController::platformSetDidEndZoomingCallback):
(WTR::UIScriptController::platformSetDidShowKeyboardCallback):
(WTR::UIScriptController::platformSetDidHideKeyboardCallback):
(WTR::UIScriptController::platformClearAllCallbacks): Deleted.
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::doAsyncTask):

LayoutTests:

Ensures that all tests using UIScriptController properly complete the UI script from within
a completion callback.

* fast/events/ios/clicking-document-should-not-trigger-focus.html:
* fast/events/ios/input-value-after-oninput.html:
* fast/events/ios/single-tap-generates-click.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192313 => 192314)


--- trunk/LayoutTests/ChangeLog	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/LayoutTests/ChangeLog	2015-11-11 18:15:56 UTC (rev 192314)
@@ -1,3 +1,18 @@
+2015-11-10  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        UI-side scripts in WebKitTestRunner should wait until event handling completes before finishing
+        https://bugs.webkit.org/show_bug.cgi?id=151101
+        <rdar://problem/23428601>
+
+        Reviewed by Simon Fraser.
+
+        Ensures that all tests using UIScriptController properly complete the UI script from within
+        a completion callback.
+
+        * fast/events/ios/clicking-document-should-not-trigger-focus.html:
+        * fast/events/ios/input-value-after-oninput.html:
+        * fast/events/ios/single-tap-generates-click.html:
+
 2015-11-10  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: Make indexes actually index.

Modified: trunk/LayoutTests/fast/events/ios/clicking-document-should-not-trigger-focus.html (192313 => 192314)


--- trunk/LayoutTests/fast/events/ios/clicking-document-should-not-trigger-focus.html	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/LayoutTests/fast/events/ios/clicking-document-should-not-trigger-focus.html	2015-11-11 18:15:56 UTC (rev 192314)
@@ -5,10 +5,14 @@
     <head>
         <script id="ui-script" type="text/plain">
             (function() {
-                uiController.singleTapAtPoint(100, 300);
+                uiController.singleTapAtPoint(100, 300, function() {
+                    uiController.uiScriptComplete("");
+                });
             })();
         </script>
         <script>
+            var uiScriptHasCompleted = false;
+            var clickHasBeenHandled = false;
             if (window.testRunner) {
                 testRunner.dumpAsText();
                 testRunner.waitUntilDone();
@@ -24,11 +28,17 @@
                 document.addEventListener("click", function() {
                     document.body.appendChild(document.createTextNode("The currently focused element is of type " + document.activeElement.tagName));
                     document.body.appendChild(document.createElement("br"));
-                    if (window.testRunner)
+                    clickHasBeenHandled = true;
+                    if (window.testRunner && uiScriptHasCompleted)
                         testRunner.notifyDone();
                 });
-                if (window.testRunner && testRunner.runUIScript)
-                    testRunner.runUIScript(getUIScript(), function() { });
+                if (window.testRunner && testRunner.runUIScript) {
+                    testRunner.runUIScript(getUIScript(), function() {
+                        uiScriptHasCompleted = true;
+                        if (clickHasBeenHandled)
+                            testRunner.notifyDone();
+                    });
+                }
             }
         </script>
     </head>

Modified: trunk/LayoutTests/fast/events/ios/input-value-after-oninput.html (192313 => 192314)


--- trunk/LayoutTests/fast/events/ios/input-value-after-oninput.html	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/LayoutTests/fast/events/ios/input-value-after-oninput.html	2015-11-11 18:15:56 UTC (rev 192314)
@@ -4,15 +4,18 @@
     <meta name="viewport" content="initial-scale=1.0">
     <script id="ui-script" type="text/plain">
         (function() {
-            uiController.singleTapAtPoint(50, 25, function() {
-                uiController.didShowKeyboardCallback = function() {
-                    uiController.typeCharacterUsingHardwareKeyboard("a", function() { });
-                }
-            });
+            uiController.didShowKeyboardCallback = function() {
+                uiController.typeCharacterUsingHardwareKeyboard("a", function() {
+                    uiController.uiScriptComplete();
+                });
+            }
+            uiController.singleTapAtPoint(50, 25, function() {});
         })();
     </script>
 
     <script>
+        var uiScriptHasCompleted = false;
+        var _oninputHasBeenHandled_ = false;
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.waitUntilDone();
@@ -25,7 +28,9 @@
 
         function handleValueChanged(value) {
             document.getElementById("console").textContent = "Successfully handled oninput, value is now \"" + value.toLowerCase() + "\"";
-            testRunner.notifyDone();
+            _oninputHasBeenHandled_ = true;
+            if (uiScriptHasCompleted)
+                testRunner.notifyDone();
         }
 
         function runTest()
@@ -33,7 +38,11 @@
             if (!window.testRunner || !testRunner.runUIScript)
                 return;
 
-            testRunner.runUIScript(getUIScript(), function(result) { });
+            testRunner.runUIScript(getUIScript(), function() {
+                uiScriptHasCompleted = true;
+                if (oninputHasBeenHandled)
+                    testRunner.notifyDone();
+            });
         }
     </script>
 </head>

Modified: trunk/LayoutTests/fast/events/ios/single-tap-generates-click.html (192313 => 192314)


--- trunk/LayoutTests/fast/events/ios/single-tap-generates-click.html	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/LayoutTests/fast/events/ios/single-tap-generates-click.html	2015-11-11 18:15:56 UTC (rev 192314)
@@ -5,10 +5,14 @@
     <meta name="viewport" content="width=device-width">
     <script id="ui-script" type="text/plain">
         (function() {
-            uiController.singleTapAtPoint(50, 50);
+            uiController.singleTapAtPoint(50, 50, function() {
+                uiController.uiScriptComplete();
+            });
         })();
     </script>
     <script>
+        var uiScriptHasCompleted = false;
+        var boxHasBeenClicked = false;
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.waitUntilDone();
@@ -23,7 +27,9 @@
         {
             if (testRunner.runUIScript) {
                 testRunner.runUIScript(getUIScript(), function() {
-                    // Just wait for the tap.
+                    uiScriptHasCompleted = true;
+                    if (boxHasBeenClicked)
+                        testRunner.notifyDone();
                 });
             }
         }
@@ -31,7 +37,8 @@
         function boxClicked(event)
         {
             document.getElementById('target').textContent = 'PASS: received click event at ' + event.clientX + ' ' + event.clientY;
-            if (window.testRunner)
+            boxHasBeenClicked = true;
+            if (uiScriptHasCompleted && window.testRunner)
                 testRunner.notifyDone();
         }
     </script>

Modified: trunk/Tools/ChangeLog (192313 => 192314)


--- trunk/Tools/ChangeLog	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/ChangeLog	2015-11-11 18:15:56 UTC (rev 192314)
@@ -1,3 +1,71 @@
+2015-11-10  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        UI-side scripts in WebKitTestRunner should wait until event handling completes before finishing
+        https://bugs.webkit.org/show_bug.cgi?id=151101
+        <rdar://problem/23428601>
+
+        Reviewed by Simon Fraser.
+
+        WebKitTestRunner may still crash in the scenario where a marker event is dequeued and handled
+        after uiScriptComplete has been called. This patch teaches the UI script execution context to
+        defer script completion until all non-persistent tasks (currently tap, double tap and hardware
+        keyboard) have been handled, so marker events will no longer bleed through tests.
+
+        We accomplish this by changing the behavior of uiScriptComplete. When calling uiScriptComplete,
+        we store that a request to complete the UI-side script for the current parent callback has been
+        made. Subsequently, when a callback (either persistent or non-persistent) finishes invoking and
+        a request has been made to complete the UI script (this request may have been made when running
+        a previous callback) we check if all the non-persistent callbacks that have the same parent
+        callback as the current one have finished. If so, we complete the callback immediately;
+        otherwise, we wait until the in-flight non-persistent callbacks finish execution to complete the
+        UI script.
+
+        This patch also refactors some logic in UIScriptContext. It introduces a new convention for
+        assigning IDs to callbacks: IDs 1000 and above are treated as non-persistent callbacks, whereas
+        IDs between 0 and 999 are persistent task callbacks. This is similar to the existing convention
+        for assigning IDs in the 100s range to parent callbacks, and allows us to easily differentiate
+        between callbacks that are persistent and non-persistent, as well as determine when an existing
+        persistent callback must be unregistered before a new callback function can be set.
+
+        * WebKitTestRunner/UIScriptContext/UIScriptContext.cpp:
+        (isPersistentCallbackID):
+        (UIScriptContext::runUIScript):
+        (UIScriptContext::nextTaskCallbackID):
+        (UIScriptContext::prepareForAsyncTask):
+        (UIScriptContext::asyncTaskComplete):
+        (UIScriptContext::registerCallback):
+        (UIScriptContext::fireCallback):
+        (UIScriptContext::requestUIScriptCompletion):
+        (UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):
+        (UIScriptContext::currentParentCallbackHasOutstandingAsyncTasks):
+        (UIScriptContext::uiScriptComplete): Deleted.
+        * WebKitTestRunner/UIScriptContext/UIScriptContext.h:
+        (WTR::UIScriptContext::currentParentCallbackIsPendingCompletion):
+        * WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::setWillBeginZoomingCallback):
+        (WTR::UIScriptController::willBeginZoomingCallback):
+        (WTR::UIScriptController::setDidEndZoomingCallback):
+        (WTR::UIScriptController::didEndZoomingCallback):
+        (WTR::UIScriptController::setDidShowKeyboardCallback):
+        (WTR::UIScriptController::didShowKeyboardCallback):
+        (WTR::UIScriptController::setDidHideKeyboardCallback):
+        (WTR::UIScriptController::didHideKeyboardCallback):
+        (WTR::UIScriptController::uiScriptComplete):
+        * WebKitTestRunner/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::doAsyncTask):
+        (WTR::UIScriptController::zoomToScale):
+        (WTR::UIScriptController::singleTapAtPoint):
+        (WTR::UIScriptController::doubleTapAtPoint):
+        (WTR::UIScriptController::typeCharacterUsingHardwareKeyboard):
+        (WTR::UIScriptController::platformSetWillBeginZoomingCallback):
+        (WTR::UIScriptController::platformSetDidEndZoomingCallback):
+        (WTR::UIScriptController::platformSetDidShowKeyboardCallback):
+        (WTR::UIScriptController::platformSetDidHideKeyboardCallback):
+        (WTR::UIScriptController::platformClearAllCallbacks): Deleted.
+        * WebKitTestRunner/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::doAsyncTask):
+
 2015-11-10  Daniel Bates  <daba...@apple.com>
 
         Teach Makefile to build LayoutTestRelay when building for iOS Simulator

Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.cpp (192313 => 192314)


--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.cpp	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.cpp	2015-11-11 18:15:56 UTC (rev 192314)
@@ -36,6 +36,11 @@
 
 using namespace WTR;
 
+static inline bool isPersistentCallbackID(unsigned callbackID)
+{
+    return callbackID < firstNonPersistentCallbackID;
+}
+
 UIScriptContext::UIScriptContext(UIScriptContextDelegate& delegate)
     : m_context(Adopt, JSGlobalContextCreate(nullptr))
     , m_delegate(delegate)
@@ -59,20 +64,22 @@
     
     if (!hasOutstandingAsyncTasks()) {
         JSValueRef stringifyException = nullptr;
-        JSRetainPtr<JSStringRef> resultString(Adopt, JSValueToStringCopy(m_context.get(), result, &stringifyException));
-        uiScriptComplete(resultString.get());
-        m_currentScriptCallbackID = 0;
+        requestUIScriptCompletion(JSValueToStringCopy(m_context.get(), result, &stringifyException));
+        tryToCompleteUIScriptForCurrentParentCallback();
     }
 }
 
-unsigned UIScriptContext::nextTaskCallbackID()
+unsigned UIScriptContext::nextTaskCallbackID(CallbackType type)
 {
-    return ++m_nextTaskCallbackID;
+    if (type == CallbackTypeNonPersistent)
+        return ++m_nextTaskCallbackID + firstNonPersistentCallbackID;
+
+    return type;
 }
 
-unsigned UIScriptContext::prepareForAsyncTask(JSValueRef callback)
+unsigned UIScriptContext::prepareForAsyncTask(JSValueRef callback, CallbackType type)
 {
-    unsigned callbackID = nextTaskCallbackID();
+    unsigned callbackID = nextTaskCallbackID(type);
     
     JSValueProtect(m_context.get(), callback);
     Task task;
@@ -99,12 +106,16 @@
     JSObjectCallAsFunction(m_context.get(), callbackObject, JSContextGetGlobalObject(m_context.get()), 0, nullptr, &exception);
     JSValueUnprotect(m_context.get(), task.callback);
     
+    tryToCompleteUIScriptForCurrentParentCallback();
     m_currentScriptCallbackID = 0;
 }
 
-unsigned UIScriptContext::registerCallback(JSValueRef taskCallback)
+unsigned UIScriptContext::registerCallback(JSValueRef taskCallback, CallbackType type)
 {
-    return prepareForAsyncTask(taskCallback);
+    if (m_callbacks.contains(type))
+        unregisterCallback(type);
+
+    return prepareForAsyncTask(taskCallback, type);
 }
 
 void UIScriptContext::unregisterCallback(unsigned callbackID)
@@ -133,14 +144,31 @@
     exception = nullptr;
     JSObjectCallAsFunction(m_context.get(), callbackObject, JSContextGetGlobalObject(m_context.get()), 0, nullptr, &exception);
     
+    tryToCompleteUIScriptForCurrentParentCallback();
     m_currentScriptCallbackID = 0;
 }
 
-void UIScriptContext::uiScriptComplete(JSStringRef result)
+void UIScriptContext::requestUIScriptCompletion(JSStringRef result)
 {
+    ASSERT(m_currentScriptCallbackID);
+    if (currentParentCallbackIsPendingCompletion())
+        return;
+
+    // This request for the UI script to complete is not fulfilled until the last non-persistent task for the parent callback is finished.
+    m_uiScriptResultsPendingCompletion.add(m_currentScriptCallbackID, result ? JSStringRetain(result) : nullptr);
+}
+
+void UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback()
+{
+    if (!currentParentCallbackIsPendingCompletion() || currentParentCallbackHasOutstandingAsyncTasks())
+        return;
+
+    JSStringRef result = m_uiScriptResultsPendingCompletion.take(m_currentScriptCallbackID);
     WKRetainPtr<WKStringRef> uiScriptResult = adoptWK(WKStringCreateWithJSString(result));
     m_delegate.uiScriptDidComplete(uiScriptResult.get(), m_currentScriptCallbackID);
     m_currentScriptCallbackID = 0;
+    if (result)
+        JSStringRelease(result);
 }
 
 JSObjectRef UIScriptContext::objectFromRect(const WKRect& rect) const
@@ -155,3 +183,15 @@
     return object;
 }
 
+bool UIScriptContext::currentParentCallbackHasOutstandingAsyncTasks() const
+{
+    for (auto entry : m_callbacks) {
+        unsigned callbackID = entry.key;
+        Task task = entry.value;
+        if (task.parentScriptCallbackID == m_currentScriptCallbackID && !isPersistentCallbackID(callbackID))
+            return true;
+    }
+
+    return false;
+}
+

Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h (192313 => 192314)


--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h	2015-11-11 18:15:56 UTC (rev 192314)
@@ -39,25 +39,35 @@
     virtual void uiScriptDidComplete(WKStringRef result, unsigned callbackID) = 0;
 };
 
+const unsigned firstNonPersistentCallbackID = 1000;
+
+typedef enum  {
+    CallbackTypeWillBeginZooming = 0,
+    CallbackTypeDidEndZooming,
+    CallbackTypeDidShowKeyboard,
+    CallbackTypeDidHideKeyboard,
+    CallbackTypeNonPersistent = firstNonPersistentCallbackID
+} CallbackType;
+
 class UIScriptContext {
 public:
 
     UIScriptContext(UIScriptContextDelegate&);
 
     void runUIScript(WKStringRef script, unsigned scriptCallbackID);
-    void uiScriptComplete(JSStringRef);
+    void requestUIScriptCompletion(JSStringRef);
 
     // For one-shot tasks callbacks.
-    unsigned prepareForAsyncTask(JSValueRef taskCallback);
+    unsigned prepareForAsyncTask(JSValueRef taskCallback, CallbackType);
     void asyncTaskComplete(unsigned taskCallbackID);
 
     // For persistent callbacks.
-    unsigned registerCallback(JSValueRef taskCallback);
+    unsigned registerCallback(JSValueRef taskCallback, CallbackType);
     JSValueRef callbackWithID(unsigned callbackID);
     void unregisterCallback(unsigned callbackID);
     void fireCallback(unsigned callbackID);
 
-    unsigned nextTaskCallbackID();
+    unsigned nextTaskCallbackID(CallbackType);
 
     JSObjectRef objectFromRect(const WKRect&) const;
 
@@ -65,12 +75,16 @@
     JSRetainPtr<JSGlobalContextRef> m_context;
     
     bool hasOutstandingAsyncTasks() const { return !m_callbacks.isEmpty(); }
+    bool currentParentCallbackIsPendingCompletion() const { return m_uiScriptResultsPendingCompletion.contains(m_currentScriptCallbackID); }
+    bool currentParentCallbackHasOutstandingAsyncTasks() const;
+    void tryToCompleteUIScriptForCurrentParentCallback();
     
     struct Task {
         unsigned parentScriptCallbackID { 0 };
         JSValueRef callback { nullptr };
     };
     HashMap<unsigned, Task> m_callbacks;
+    HashMap<unsigned, JSStringRef> m_uiScriptResultsPendingCompletion;
 
     UIScriptContextDelegate& m_delegate;
     RefPtr<UIScriptController> m_controller;

Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp (192313 => 192314)


--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp	2015-11-11 18:15:56 UTC (rev 192314)
@@ -55,46 +55,46 @@
 
 void UIScriptController::setWillBeginZoomingCallback(JSValueRef callback)
 {
-    m_willBeginZoomingCallback = m_context.registerCallback(callback);
+    m_context.registerCallback(callback, CallbackTypeWillBeginZooming);
     platformSetWillBeginZoomingCallback();
 }
 
 JSValueRef UIScriptController::willBeginZoomingCallback() const
 {
-    return m_context.callbackWithID(m_willBeginZoomingCallback);
+    return m_context.callbackWithID(CallbackTypeWillBeginZooming);
 }
 
 void UIScriptController::setDidEndZoomingCallback(JSValueRef callback)
 {
-    m_didEndZoomingCallback = m_context.registerCallback(callback);
+    m_context.registerCallback(callback, CallbackTypeDidEndZooming);
     platformSetDidEndZoomingCallback();
 }
 
 JSValueRef UIScriptController::didEndZoomingCallback() const
 {
-    return m_context.callbackWithID(m_didEndZoomingCallback);
+    return m_context.callbackWithID(CallbackTypeDidEndZooming);
 }
 
 void UIScriptController::setDidShowKeyboardCallback(JSValueRef callback)
 {
-    m_didShowKeyboardCallback = m_context.registerCallback(callback);
+    m_context.registerCallback(callback, CallbackTypeDidShowKeyboard);
     platformSetDidShowKeyboardCallback();
 }
 
 JSValueRef UIScriptController::didShowKeyboardCallback() const
 {
-    return m_context.callbackWithID(m_didShowKeyboardCallback);
+    return m_context.callbackWithID(CallbackTypeDidShowKeyboard);
 }
 
 void UIScriptController::setDidHideKeyboardCallback(JSValueRef callback)
 {
-    m_didHideKeyboardCallback = m_context.registerCallback(callback);
+    m_context.registerCallback(callback, CallbackTypeDidHideKeyboard);
     platformSetDidHideKeyboardCallback();
 }
 
 JSValueRef UIScriptController::didHideKeyboardCallback() const
 {
-    return m_context.callbackWithID(m_didHideKeyboardCallback);
+    return m_context.callbackWithID(CallbackTypeDidHideKeyboard);
 }
 
 #if !PLATFORM(IOS)
@@ -157,7 +157,7 @@
 
 void UIScriptController::uiScriptComplete(JSStringRef result)
 {
-    m_context.uiScriptComplete(result);
+    m_context.requestUIScriptCompletion(result);
     platformClearAllCallbacks();
 }
 

Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h (192313 => 192314)


--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h	2015-11-11 18:15:56 UTC (rev 192314)
@@ -84,11 +84,6 @@
     JSObjectRef objectFromRect(const WKRect&) const;
 
     UIScriptContext& m_context;
-
-    unsigned m_willBeginZoomingCallback { 0 };
-    unsigned m_didEndZoomingCallback { 0 };
-    unsigned m_didShowKeyboardCallback { 0 };
-    unsigned m_didHideKeyboardCallback { 0 };
 };
 
 }

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (192313 => 192314)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2015-11-11 18:15:56 UTC (rev 192314)
@@ -42,7 +42,7 @@
 
 void UIScriptController::doAsyncTask(JSValueRef callback)
 {
-    unsigned callbackID = m_context.prepareForAsyncTask(callback);
+    unsigned callbackID = m_context.prepareForAsyncTask(callback, CallbackTypeNonPersistent);
 
     dispatch_async(dispatch_get_main_queue(), ^{
         m_context.asyncTaskComplete(callbackID);
@@ -53,7 +53,7 @@
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
 
-    unsigned callbackID = m_context.prepareForAsyncTask(callback);
+    unsigned callbackID = m_context.prepareForAsyncTask(callback, CallbackTypeNonPersistent);
 
     [webView zoomToScale:scale animated:YES completionHandler:^{
         m_context.asyncTaskComplete(callbackID);
@@ -77,7 +77,7 @@
 
 void UIScriptController::singleTapAtPoint(long x, long y, JSValueRef callback)
 {
-    unsigned callbackID = m_context.prepareForAsyncTask(callback);
+    unsigned callbackID = m_context.prepareForAsyncTask(callback, CallbackTypeNonPersistent);
 
     [[HIDEventGenerator sharedHIDEventGenerator] tap:globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y) completionBlock:^{
         m_context.asyncTaskComplete(callbackID);
@@ -86,7 +86,7 @@
 
 void UIScriptController::doubleTapAtPoint(long x, long y, JSValueRef callback)
 {
-    unsigned callbackID = m_context.prepareForAsyncTask(callback);
+    unsigned callbackID = m_context.prepareForAsyncTask(callback, CallbackTypeNonPersistent);
 
     [[HIDEventGenerator sharedHIDEventGenerator] doubleTap:globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y) completionBlock:^{
         m_context.asyncTaskComplete(callbackID);
@@ -95,7 +95,7 @@
 
 void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback)
 {
-    unsigned callbackID = m_context.prepareForAsyncTask(callback);
+    unsigned callbackID = m_context.prepareForAsyncTask(callback, CallbackTypeNonPersistent);
 
     // Assumes that the keyboard is already shown.
     [[HIDEventGenerator sharedHIDEventGenerator] keyDown:toWTFString(toWK(character)) completionBlock:^{
@@ -129,7 +129,7 @@
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     webView.willBeginZoomingCallback = ^{
-        m_context.fireCallback(m_willBeginZoomingCallback);
+        m_context.fireCallback(CallbackTypeWillBeginZooming);
     };
 }
 
@@ -137,7 +137,7 @@
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     webView.didEndZoomingCallback = ^{
-        m_context.fireCallback(m_didEndZoomingCallback);
+        m_context.fireCallback(CallbackTypeDidEndZooming);
     };
 }
 
@@ -145,7 +145,7 @@
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     webView.didShowKeyboardCallback = ^{
-        m_context.fireCallback(m_didShowKeyboardCallback);
+        m_context.fireCallback(CallbackTypeDidShowKeyboard);
     };
 }
 
@@ -153,17 +153,13 @@
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     webView.didHideKeyboardCallback = ^{
-        m_context.fireCallback(m_didHideKeyboardCallback);
+        m_context.fireCallback(CallbackTypeDidHideKeyboard);
     };
 }
 
 void UIScriptController::platformClearAllCallbacks()
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
-    m_didEndZoomingCallback = 0;
-    m_willBeginZoomingCallback = 0;
-    m_didHideKeyboardCallback = 0;
-    m_didShowKeyboardCallback = 0;
     webView.didEndZoomingCallback = nil;
     webView.willBeginZoomingCallback = nil;
     webView.didHideKeyboardCallback = nil;

Modified: trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm (192313 => 192314)


--- trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm	2015-11-11 18:12:53 UTC (rev 192313)
+++ trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm	2015-11-11 18:15:56 UTC (rev 192314)
@@ -32,7 +32,7 @@
 
 void UIScriptController::doAsyncTask(JSValueRef callback)
 {
-    unsigned callbackID = m_context.prepareForAsyncTask(callback);
+    unsigned callbackID = m_context.prepareForAsyncTask(callback, CallbackTypeNonPersistent);
 
     dispatch_async(dispatch_get_main_queue(), ^{
         m_context.asyncTaskComplete(callbackID);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to