Changeset 208816 in webkit


Ignore:
Timestamp:
Nov 16, 2016 3:05:00 PM (7 years ago)
Author:
Simon Fraser
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:

Make TestRunner::callUIScriptCallback() async in DumpRenderTree to match WebKitTestRunner behavior.
This fixes ui-side-script-with-callback.html in WK1, which failed because the second runUIScript()
would occur inside the completion callback from the first. This no longer happens.

  • DumpRenderTree/TestRunner.cpp:

(TestRunner::callUIScriptCallback):

  • TestRunnerShared/UIScriptContext/UIScriptContext.cpp:

(UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):

LayoutTests:

Move the tests that use runUIScript into their own directory for easier TestExpectations management,
and fix TestExpectations to match.

  • TestExpectations:
  • fast/harness/uiscriptcontroller/concurrent-ui-side-scripts-expected.txt: Renamed from LayoutTests/fast/harness/concurrent-ui-side-scripts-expected.txt.
  • fast/harness/uiscriptcontroller/concurrent-ui-side-scripts.html: Renamed from LayoutTests/fast/harness/concurrent-ui-side-scripts.html.
  • fast/harness/uiscriptcontroller/ui-side-script-unregister-callback-expected.txt: Copied from LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt.
  • fast/harness/uiscriptcontroller/ui-side-script-unregister-callback.html: Copied from LayoutTests/fast/harness/ui-side-script-unregister-callback.html.
  • fast/harness/uiscriptcontroller/ui-side-script-with-callback-expected.txt: Renamed from LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt.
  • fast/harness/uiscriptcontroller/ui-side-script-with-callback.html: Renamed from LayoutTests/fast/harness/ui-side-script-unregister-callback.html.
  • fast/harness/uiscriptcontroller/ui-side-scripts-expected.txt: Renamed from LayoutTests/fast/harness/ui-side-scripts-expected.txt.
  • fast/harness/uiscriptcontroller/ui-side-scripts.html: Renamed from LayoutTests/fast/harness/ui-side-scripts.html.
  • platform/mac/TestExpectations:
Location:
trunk
Files:
1 added
6 edited
2 copied
6 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208815 r208816  
     12016-11-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        UIScriptController: script with no async tasks fails if an earlier script registered a callback
     4        https://bugs.webkit.org/show_bug.cgi?id=164762
     5
     6        Reviewed by Wenson Hsieh.
     7       
     8        Move the tests that use runUIScript into their own directory for easier TestExpectations management,
     9        and fix TestExpectations to match.
     10
     11        * TestExpectations:
     12        * fast/harness/uiscriptcontroller/concurrent-ui-side-scripts-expected.txt: Renamed from LayoutTests/fast/harness/concurrent-ui-side-scripts-expected.txt.
     13        * fast/harness/uiscriptcontroller/concurrent-ui-side-scripts.html: Renamed from LayoutTests/fast/harness/concurrent-ui-side-scripts.html.
     14        * fast/harness/uiscriptcontroller/ui-side-script-unregister-callback-expected.txt: Copied from LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt.
     15        * fast/harness/uiscriptcontroller/ui-side-script-unregister-callback.html: Copied from LayoutTests/fast/harness/ui-side-script-unregister-callback.html.
     16        * fast/harness/uiscriptcontroller/ui-side-script-with-callback-expected.txt: Renamed from LayoutTests/fast/harness/ui-side-script-unregister-callback-expected.txt.
     17        * fast/harness/uiscriptcontroller/ui-side-script-with-callback.html: Renamed from LayoutTests/fast/harness/ui-side-script-unregister-callback.html.
     18        * fast/harness/uiscriptcontroller/ui-side-scripts-expected.txt: Renamed from LayoutTests/fast/harness/ui-side-scripts-expected.txt.
     19        * fast/harness/uiscriptcontroller/ui-side-scripts.html: Renamed from LayoutTests/fast/harness/ui-side-scripts.html.
     20        * platform/mac/TestExpectations:
     21
    1222016-11-16  Alex Christensen  <achristensen@webkit.org>
    223
  • trunk/LayoutTests/TestExpectations

    r208807 r208816  
    5757
    5858# Only Mac and iOS have an implementation of UIScriptController::doAsyncTask().
    59 fast/harness/ui-side-scripts.html [ Skip ]
    60 fast/harness/concurrent-ui-side-scripts.html [ Skip ]
     59fast/harness/uiscriptcontroller [ Skip ]
    6160
    6261# This test only makes sense on Mac
  • trunk/LayoutTests/fast/harness/uiscriptcontroller/ui-side-script-unregister-callback.html

    r208815 r208816  
    33<html>
    44<head>
    5     <script src="../../resources/js-test-pre.js"></script>
     5    <script src="../../../resources/js-test-pre.js"></script>
    66    <script>
    77       
     
    5959
    6060<pre id="results"></pre>
    61 <script src="../../resources/js-test-post.js"></script>
     61<script src="../../../resources/js-test-post.js"></script>
    6262</body>
    6363</html>
  • trunk/LayoutTests/fast/harness/uiscriptcontroller/ui-side-script-with-callback-expected.txt

    r208815 r208816  
    1 Test that a second immediate UI script returns if an earlier script registered then unregistered a callback
     1Test that a second immediate UI script returns if an earlier script registered a callback
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/fast/harness/uiscriptcontroller/ui-side-script-with-callback.html

    r208815 r208816  
    33<html>
    44<head>
    5     <script src="../../resources/js-test-pre.js"></script>
     5    <script src="../../../resources/js-test-pre.js"></script>
    66    <script>
    77       
     
    1111        {
    1212            return `(function() {
    13                 uiController.didEndScrollingCallback = function() { };
    14                 uiController.didEndScrollingCallback = undefined;
     13                uiController.willBeginZoomingCallback = function() {};
    1514
    1615                uiController.doAsyncTask(function() {
     
    3029        function runTest()
    3130        {
    32             description('Test that a second immediate UI script returns if an earlier script registered then unregistered a callback');
     31            description('Test that a second immediate UI script returns if an earlier script registered a callback');
    3332
    3433            if (!window.testRunner) {
     
    5958
    6059<pre id="results"></pre>
    61 <script src="../../resources/js-test-post.js"></script>
     60<script src="../../../resources/js-test-post.js"></script>
    6261</body>
    6362</html>
  • trunk/LayoutTests/platform/mac/TestExpectations

    r208815 r208816  
    2626fast/attachment/attachment-subtitle-resize.html [ Pass ]
    2727
    28 fast/harness/ui-side-scripts.html [ Pass ]
    29 fast/harness/concurrent-ui-side-scripts.html [ Pass ]
     28fast/harness/uiscriptcontroller [ Pass ]
    3029
    3130#//////////////////////////////////////////////////////////////////////////////////////////
  • trunk/Tools/ChangeLog

    r208795 r208816  
     12016-11-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        UIScriptController: script with no async tasks fails if an earlier script registered a callback
     4        https://bugs.webkit.org/show_bug.cgi?id=164762
     5
     6        Reviewed by Wenson Hsieh.
     7       
     8        Make TestRunner::callUIScriptCallback() async in DumpRenderTree to match WebKitTestRunner behavior.
     9        This fixes ui-side-script-with-callback.html in WK1, which failed because the second runUIScript()
     10        would occur inside the completion callback from the first. This no longer happens.
     11
     12        * DumpRenderTree/TestRunner.cpp:
     13        (TestRunner::callUIScriptCallback):
     14        * TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
     15        (UIScriptContext::tryToCompleteUIScriptForCurrentParentCallback):
     16
    1172016-11-16  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/Tools/DumpRenderTree/TestRunner.cpp

    r208509 r208816  
    5252#include <wtf/MathExtras.h>
    5353#include <wtf/RefPtr.h>
     54#include <wtf/RunLoop.h>
    5455#include <wtf/StdLibExtras.h>
    5556#include <wtf/text/WTFString.h>
     
    23932394void TestRunner::callUIScriptCallback(unsigned callbackID, JSStringRef result)
    23942395{
    2395     JSContextRef context = mainFrameJSContext();
    2396     JSValueRef resultValue = JSValueMakeString(context, result);
    2397     callTestRunnerCallback(callbackID, 1, &resultValue);
     2396    JSRetainPtr<JSStringRef> protectedResult(result);
     2397   
     2398    RunLoop::main().dispatch([protectedThis = makeRef(*this), callbackID, protectedResult]() mutable {
     2399        JSContextRef context = protectedThis->mainFrameJSContext();
     2400        JSValueRef resultValue = JSValueMakeString(context, protectedResult.get());
     2401        protectedThis->callTestRunnerCallback(callbackID, 1, &resultValue);
     2402    });
    23982403}
    23992404
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp

    r208795 r208816  
    173173
    174174    m_delegate.uiScriptDidComplete(scriptResult, m_currentScriptCallbackID);
     175   
     176    // Unregister tasks associated with this callback
     177    m_callbacks.removeIf([&](auto& keyAndValue) {
     178        return keyAndValue.value.parentScriptCallbackID == m_currentScriptCallbackID;
     179    });
     180   
    175181    m_currentScriptCallbackID = 0;
    176182    if (result)
Note: See TracChangeset for help on using the changeset viewer.