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

Log Message

UIScriptController: script with no async tasks fails if an earlier script registered a callback
https://bugs.webkit.org/show_bug.cgi?id=164762

Reviewed by Wenson Hsieh.
Tools:

UIScriptContext::runUIScript() considers a script to be "immediate" if that script doesn't
queue any async tasks. However, if an earlier UI script registered a callback, UIScriptContext::runUIScript()
would consider that an outstanding task.

Fix by unregistering any callbacks associated with the current UI script when uiScriptComplete() is called.

* TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
(UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):

LayoutTests:

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

Modified Paths

Added Paths

Diff

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


--- trunk/LayoutTests/ChangeLog	2016-11-16 00:23:36 UTC (rev 208769)
+++ trunk/LayoutTests/ChangeLog	2016-11-16 00:23:39 UTC (rev 208770)
@@ -1,5 +1,15 @@
 2016-11-15  Simon Fraser  <[email protected]>
 
+        UIScriptController: script with no async tasks fails if an earlier script registered a callback
+        https://bugs.webkit.org/show_bug.cgi?id=164762
+
+        Reviewed by Wenson Hsieh.
+
+        * fast/harness/ui-side-script-with-callback-expected.txt: Added.
+        * fast/harness/ui-side-script-with-callback.html: Added.
+
+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
 

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


--- trunk/LayoutTests/fast/harness/ui-side-script-with-callback-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/ui-side-script-with-callback-expected.txt	2016-11-16 00:23:39 UTC (rev 208770)
@@ -0,0 +1,11 @@
+Test that a second immediate UI script returns if an earlier script registered 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-with-callback.html (0 => 208770)


--- trunk/LayoutTests/fast/harness/ui-side-script-with-callback.html	                        (rev 0)
+++ trunk/LayoutTests/fast/harness/ui-side-script-with-callback.html	2016-11-16 00:23:39 UTC (rev 208770)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script src=""
+    <script>
+        
+        var jsTestIsAsync = true;
+        
+        function getAsyncTaskScript()
+        {
+            return `(function() {
+                uiController.willBeginZoomingCallback = function() {};
+
+                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 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 (208769 => 208770)


--- trunk/Tools/ChangeLog	2016-11-16 00:23:36 UTC (rev 208769)
+++ trunk/Tools/ChangeLog	2016-11-16 00:23:39 UTC (rev 208770)
@@ -1,5 +1,21 @@
 2016-11-15  Simon Fraser  <[email protected]>
 
+        UIScriptController: script with no async tasks fails if an earlier script registered a callback
+        https://bugs.webkit.org/show_bug.cgi?id=164762
+
+        Reviewed by Wenson Hsieh.
+        
+        UIScriptContext::runUIScript() considers a script to be "immediate" if that script doesn't
+        queue any async tasks. However, if an earlier UI script registered a callback, UIScriptContext::runUIScript()
+        would consider that an outstanding task.
+        
+        Fix by unregistering any callbacks associated with the current UI script when uiScriptComplete() is called.
+
+        * TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
+        (UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):
+
+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
 

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


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp	2016-11-16 00:23:36 UTC (rev 208769)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp	2016-11-16 00:23:39 UTC (rev 208770)
@@ -172,6 +172,12 @@
     String scriptResult(JSStringGetCharactersPtr(result), JSStringGetLength(result));
 
     m_delegate.uiScriptDidComplete(scriptResult, m_currentScriptCallbackID);
+    
+    // Unregister tasks associated with this callback
+    m_callbacks.removeIf([&](auto& keyAndValue) {
+        return keyAndValue.value.parentScriptCallbackID == m_currentScriptCallbackID;
+    });
+    
     m_currentScriptCallbackID = 0;
     if (result)
         JSStringRelease(result);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to