Title: [208769] trunk
Revision
208769
Author
[email protected]
Date
2016-11-15 16:23:36 -0800 (Tue, 15 Nov 2016)

Log Message

UIScriptController: setting a callback to undefined should unregister it
https://bugs.webkit.org/show_bug.cgi?id=164796

Reviewed by Dean Jackson.
Tools:

"Immediate" UI scripts (those that don't schedule any async tasks) should return
immediately, without the need to call uiScriptComplete(). However, this is broken if
an earlier UI script registered a callback (since no-one clears that callback after the
first script completes).

Make possible the workaround of setting the callback to undefined, which previously did
not clear the callback registration.

* TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
(UIScriptContext::registerCallback):
* TestRunnerShared/UIScriptContext/UIScriptContext.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::platformClearAllCallbacks):

LayoutTests:

* fast/harness/ui-side-script-unregister-callback-expected.txt: Added.
* fast/harness/ui-side-script-unregister-callback.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208768 => 208769)


--- trunk/LayoutTests/ChangeLog	2016-11-16 00:23:01 UTC (rev 208768)
+++ trunk/LayoutTests/ChangeLog	2016-11-16 00:23:36 UTC (rev 208769)
@@ -1,3 +1,13 @@
+2016-11-15  Simon Fraser  <[email protected]>
+
+        UIScriptController: setting a callback to undefined should unregister it
+        https://bugs.webkit.org/show_bug.cgi?id=164796
+
+        Reviewed by Dean Jackson.
+
+        * fast/harness/ui-side-script-unregister-callback-expected.txt: Added.
+        * fast/harness/ui-side-script-unregister-callback.html: Added.
+
 2016-11-15  Ryan Haddad  <[email protected]>
 
         Marking http/tests/cache/disk-cache/disk-cache-remove-several-pending-writes.html as flaky.

Added: trunk/LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt (0 => 208769)


--- trunk/LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt	2016-11-16 00:23:36 UTC (rev 208769)
@@ -0,0 +1,11 @@
+Test that a second immediate UI script returns if an earlier script registered then unregistered a callback
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS scriptResult is "async task complete"
+PASS scriptResult is "immediate script complete"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/harness/ui-side-script-unregister-callback.html (0 => 208769)


--- trunk/LayoutTests/fast/harness/ui-side-script-unregister-callback.html	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/ui-side-script-unregister-callback.html	2016-11-16 00:23:36 UTC (rev 208769)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script src=""
+    <script>
+        
+        var jsTestIsAsync = true;
+        
+        function getAsyncTaskScript()
+        {
+            return `(function() {
+                uiController.didEndScrollingCallback = function() { };
+                uiController.didEndScrollingCallback = undefined;
+
+                uiController.doAsyncTask(function() {
+                    uiController.uiScriptComplete('async task complete');
+                });
+            })();`;
+        }
+
+        function getImmediateScript()
+        {
+            return `(function() {
+                return 'immediate script complete';
+            })();`;
+        }
+    
+        var scriptResult;
+        function runTest()
+        {
+            description('Test that a second immediate UI script returns if an earlier script registered then unregistered a callback');
+
+            if (!window.testRunner) {
+                debug('This test requires testRunner');
+                return;
+            }
+
+            if (!testRunner.runUIScript) {
+                debug('This test requires runUIScript');
+                return;
+            }
+
+            testRunner.runUIScript(getAsyncTaskScript(), function(result) {
+                scriptResult = result;
+                shouldBeEqualToString('scriptResult', 'async task complete');
+
+                testRunner.runUIScript(getImmediateScript(), function(result) {
+                    scriptResult = result;
+                    shouldBeEqualToString('scriptResult', 'immediate script complete');
+                    finishJSTest();
+                });
+            });
+        }
+        window.addEventListener('load', runTest, false);
+    </script>
+</head>
+<body>
+
+<pre id="results"></pre>
+<script src=""
+</body>
+</html>

Modified: trunk/Tools/ChangeLog (208768 => 208769)


--- trunk/Tools/ChangeLog	2016-11-16 00:23:01 UTC (rev 208768)
+++ trunk/Tools/ChangeLog	2016-11-16 00:23:36 UTC (rev 208769)
@@ -1,3 +1,24 @@
+2016-11-15  Simon Fraser  <[email protected]>
+
+        UIScriptController: setting a callback to undefined should unregister it
+        https://bugs.webkit.org/show_bug.cgi?id=164796
+
+        Reviewed by Dean Jackson.
+        
+        "Immediate" UI scripts (those that don't schedule any async tasks) should return
+        immediately, without the need to call uiScriptComplete(). However, this is broken if
+        an earlier UI script registered a callback (since no-one clears that callback after the
+        first script completes).
+
+        Make possible the workaround of setting the callback to undefined, which previously did
+        not clear the callback registration.
+
+        * TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
+        (UIScriptContext::registerCallback):
+        * TestRunnerShared/UIScriptContext/UIScriptContext.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::platformClearAllCallbacks):
+
 2016-11-14  Mark Lam  <[email protected]>
 
         Enhance run-jsc-stress-test script to allow optional test specific options to be added for all test run configurations.

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp (208768 => 208769)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp	2016-11-16 00:23:01 UTC (rev 208768)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp	2016-11-16 00:23:36 UTC (rev 208769)
@@ -117,6 +117,9 @@
     if (m_callbacks.contains(type))
         unregisterCallback(type);
 
+    if (JSValueIsUndefined(m_context.get(), taskCallback))
+        return 0;
+
     return prepareForAsyncTask(taskCallback, type);
 }
 

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h (208768 => 208769)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h	2016-11-16 00:23:01 UTC (rev 208768)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h	2016-11-16 00:23:36 UTC (rev 208769)
@@ -49,7 +49,8 @@
 const unsigned firstNonPersistentCallbackID = 1000;
 
 typedef enum  {
-    CallbackTypeWillBeginZooming = 0,
+    CallbackTypeInvalid = 0,
+    CallbackTypeWillBeginZooming,
     CallbackTypeDidEndZooming,
     CallbackTypeDidShowKeyboard,
     CallbackTypeDidHideKeyboard,

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (208768 => 208769)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2016-11-16 00:23:01 UTC (rev 208768)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2016-11-16 00:23:36 UTC (rev 208769)
@@ -498,6 +498,11 @@
 void UIScriptController::platformClearAllCallbacks()
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    
+    webView.didStartFormControlInteractionCallback = nil;
+    webView.didEndFormControlInteractionCallback = nil;
+    webView.didShowForcePressPreviewCallback = nil;
+    webView.didDismissForcePressPreviewCallback = nil;
     webView.didEndZoomingCallback = nil;
     webView.willBeginZoomingCallback = nil;
     webView.didHideKeyboardCallback = nil;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to