⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249125 in webkit


Ignore:
Timestamp:
Aug 26, 2019, 5:18:57 PM (7 years ago)
Author:
Wenson Hsieh
Message:

Remove UIHelper.activateElementAtHumanSpeed
https://bugs.webkit.org/show_bug.cgi?id=201147

Reviewed by Tim Horton.

Tools:

Add plumbing for a new script controller hook to wait for the double tap delay to pass. On non-iOS, this
resolves immediately; on iOS, we inspect the content view for tap gestures that require more than one tap, and
find the value of the maximum double tap delay. We then delay for this amount of time before resolving.

  • TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
  • TestRunnerShared/UIScriptContext/UIScriptController.h:

(WTR::UIScriptController::doAfterDoubleTapDelay):

  • WebKitTestRunner/ios/UIScriptControllerIOS.h:
  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptControllerIOS::doAfterDoubleTapDelay):

LayoutTests:

This was used in layout tests that simulate repeated taps to work around <webkit.org/b/201129>, and should no
longer be needed after <https://trac.webkit.org/changeset/249112/webkit>. Instead, we can just use UIHelper's
activateElement as intended in cases where successive taps in the test does not result in a double-click; for
the cases where we need to avoid triggering double clicks when tapping (e.g. in several payment tests), use a
new script controller hook to wait for the double tap gesture delay before continuing.

  • fast/forms/ios/file-upload-panel.html:
  • http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt:

Rebaseline more line numbers.

  • http/tests/adClickAttribution/anchor-tag-attributes-validation.html:

Refactor this test so that the links are laid out in two (or more) columns to avoid firing the double click
gesture recognizer instead of the synthetic click gesture.

  • http/tests/resources/payment-request.js:

(activateThen):

Instead of using activateElementAtHumanSpeed, wait for the platform double tap delay first, and then simulate
a click using activateElement.

  • resources/ui-helper.js:

(window.UIHelper.waitForDoubleTapDelay):

Add a new UIHelper method to wait for the platform double tap delay. See Tools ChangeLog for more details.

(window.UIHelper):
(window.UIHelper.activateElementAtHumanSpeed.return.new.Promise): Deleted.
(window.UIHelper.activateElementAtHumanSpeed): Deleted.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249122 r249125  
     12019-08-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove UIHelper.activateElementAtHumanSpeed
     4        https://bugs.webkit.org/show_bug.cgi?id=201147
     5
     6        Reviewed by Tim Horton.
     7
     8        This was used in layout tests that simulate repeated taps to work around <webkit.org/b/201129>, and should no
     9        longer be needed after <https://trac.webkit.org/changeset/249112/webkit>. Instead, we can just use UIHelper's
     10        activateElement as intended in cases where successive taps in the test does not result in a double-click; for
     11        the cases where we need to avoid triggering double clicks when tapping (e.g. in several payment tests), use a
     12        new script controller hook to wait for the double tap gesture delay before continuing.
     13
     14        * fast/forms/ios/file-upload-panel.html:
     15        * http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt:
     16
     17        Rebaseline more line numbers.
     18
     19        * http/tests/adClickAttribution/anchor-tag-attributes-validation.html:
     20
     21        Refactor this test so that the links are laid out in two (or more) columns to avoid firing the double click
     22        gesture recognizer instead of the synthetic click gesture.
     23
     24        * http/tests/resources/payment-request.js:
     25        (activateThen):
     26
     27        Instead of using activateElementAtHumanSpeed, wait for the platform double tap delay first, and then simulate
     28        a click using activateElement.
     29
     30        * resources/ui-helper.js:
     31        (window.UIHelper.waitForDoubleTapDelay):
     32
     33        Add a new UIHelper method to wait for the platform double tap delay. See Tools ChangeLog for more details.
     34
     35        (window.UIHelper):
     36        (window.UIHelper.activateElementAtHumanSpeed.return.new.Promise): Deleted.
     37        (window.UIHelper.activateElementAtHumanSpeed): Deleted.
     38
    1392019-08-26  Devin Rousso  <drousso@apple.com>
    240
  • trunk/LayoutTests/fast/forms/ios/file-upload-panel.html

    r248145 r249125  
    5353        testInput.accept = accept;
    5454
    55         UIHelper.activateElementAtHumanSpeed(testInput).then(() => {
     55        UIHelper.activateElement(testInput).then(() => {
    5656            getFileUploadPickerMenuItems().then((_items) => {
    5757                items = _items;
  • trunk/LayoutTests/http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt

    r249112 r249125  
    1 CONSOLE MESSAGE: line 182: adcampaignid must have a non-negative value less than or equal to 63 for Ad Click Attribution.
    2 CONSOLE MESSAGE: line 182: adcampaignid must have a non-negative value less than or equal to 63 for Ad Click Attribution.
    3 CONSOLE MESSAGE: line 182: adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution.
    4 CONSOLE MESSAGE: line 182: adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution.
    5 CONSOLE MESSAGE: line 182: adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution.
    6 CONSOLE MESSAGE: line 182: addestination could not be converted to a valid HTTP-family URL.
    7 CONSOLE MESSAGE: line 182: addestination could not be converted to a valid HTTP-family URL.
    8 CONSOLE MESSAGE: line 182: addestination could not be converted to a valid HTTP-family URL.
    9 CONSOLE MESSAGE: line 182: Both adcampaignid and addestination need to be set for Ad Click Attribution to work.
    10 CONSOLE MESSAGE: line 182: Both adcampaignid and addestination need to be set for Ad Click Attribution to work.
    11 CONSOLE MESSAGE: line 182: addestination can not be the same site as the current website.
     1CONSOLE MESSAGE: line 155: adcampaignid must have a non-negative value less than or equal to 63 for Ad Click Attribution.
     2CONSOLE MESSAGE: line 155: adcampaignid must have a non-negative value less than or equal to 63 for Ad Click Attribution.
     3CONSOLE MESSAGE: line 155: adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution.
     4CONSOLE MESSAGE: line 155: adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution.
     5CONSOLE MESSAGE: line 155: adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution.
     6CONSOLE MESSAGE: line 155: addestination could not be converted to a valid HTTP-family URL.
     7CONSOLE MESSAGE: line 155: addestination could not be converted to a valid HTTP-family URL.
     8CONSOLE MESSAGE: line 155: addestination could not be converted to a valid HTTP-family URL.
     9CONSOLE MESSAGE: line 155: Both adcampaignid and addestination need to be set for Ad Click Attribution to work.
     10CONSOLE MESSAGE: line 155: Both adcampaignid and addestination need to be set for Ad Click Attribution to work.
     11CONSOLE MESSAGE: line 155: addestination can not be the same site as the current website.
    1212Test for validity of ad click attribution attributes on anchor tags.
    1313
  • trunk/LayoutTests/http/tests/adClickAttribution/anchor-tag-attributes-validation.html

    r247866 r249125  
    66    <script src="/js-test-resources/js-test.js"></script>
    77    <script src="/js-test-resources/ui-helper.js"></script>
     8    <style>
     9        .wide-link {
     10            width: 150px;
     11            display: inline-block;
     12        }
     13    </style>
    814</head>
    915<body onload="runAllTests()">
     
    1824        let anchorElement = document.createElement("a");
    1925        anchorElement.id = elementID;
     26        anchorElement.classList.add("wide-link");
    2027        anchorElement.adcampaignid = adCampaignID;
    2128        anchorElement.addestination = adDestination;
     
    2633
    2734    function activateElement(elementID, callback) {
    28         UIHelper.activateElementAtHumanSpeed(document.getElementById(elementID)).then(
     35        UIHelper.activateElement(document.getElementById(elementID)).then(
    2936            function () {
    3037                callback();
     
    4249        const anchorElement = createAdClickAttributionAnchorElement(currentElementID, adCampaignID, adDestination);
    4350        output.appendChild(anchorElement);
    44         const brElement = document.createElement("br");
    45         output.appendChild(brElement);
    4651        activateElement(currentElementID, callback);
    4752    }
  • trunk/LayoutTests/http/tests/resources/payment-request.js

    r247866 r249125  
    11function activateThen(completion)
    22{
    3     return new Promise(resolve => {
     3    return new Promise(async resolve => {
    44        var button = document.createElement("button");
    55        button.style["position"] = "absolute";
     
    99        };
    1010        document.body.insertBefore(button, document.body.firstChild);
    11         UIHelper.activateElementAtHumanSpeed(button);
     11        await UIHelper.waitForDoubleTapDelay();
     12        await UIHelper.activateElement(button);
    1213    });
    1314}
  • trunk/LayoutTests/resources/ui-helper.js

    r249112 r249125  
    170170        const y = element.offsetTop + element.offsetHeight / 2;
    171171        return UIHelper.activateAt(x, y);
    172     }
    173 
    174     static activateElementAtHumanSpeed(element)
    175     {
    176         const x = element.offsetLeft + element.offsetWidth / 2;
    177         const y = element.offsetTop + element.offsetHeight / 2;
    178 
    179         if (!this.isWebKit2() || !this.isIOSFamily()) {
    180             eventSender.mouseMoveTo(x, y);
    181             eventSender.mouseDown();
    182             eventSender.mouseUp();
    183             return Promise.resolve();
    184         }
    185 
    186         return new Promise(async (resolve) => {
    187             await new Promise(resolveAfterDelay => setTimeout(resolveAfterDelay, 350));
    188             testRunner.runUIScript(`
    189                 uiController.singleTapAtPoint(${x}, ${y}, function() {
    190                     uiController.uiScriptComplete();
    191                 });`, resolve);
    192         });
    193172    }
    194173
     
    10341013        });
    10351014    }
     1015
     1016    static waitForDoubleTapDelay()
     1017    {
     1018        const uiScript = `uiController.doAfterDoubleTapDelay(() => uiController.uiScriptComplete(""))`;
     1019        return new Promise(resolve => testRunner.runUIScript(uiScript, resolve));
     1020    }
    10361021}
  • trunk/Tools/ChangeLog

    r249124 r249125  
     12019-08-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove UIHelper.activateElementAtHumanSpeed
     4        https://bugs.webkit.org/show_bug.cgi?id=201147
     5
     6        Reviewed by Tim Horton.
     7
     8        Add plumbing for a new script controller hook to wait for the double tap delay to pass. On non-iOS, this
     9        resolves immediately; on iOS, we inspect the content view for tap gestures that require more than one tap, and
     10        find the value of the maximum double tap delay. We then delay for this amount of time before resolving.
     11
     12        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
     13        * TestRunnerShared/UIScriptContext/UIScriptController.h:
     14        (WTR::UIScriptController::doAfterDoubleTapDelay):
     15        * WebKitTestRunner/ios/UIScriptControllerIOS.h:
     16        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     17        (WTR::UIScriptControllerIOS::doAfterDoubleTapDelay):
     18
    1192019-08-26  Zhifei Fang  <zhifei_fang@apple.com>
    220
  • trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

    r249112 r249125  
    4848    void ensurePositionInformationIsUpToDateAt(long x, long y, object callback);
    4949    void doAfterVisibleContentRectUpdate(object callback);
     50
     51    void doAfterDoubleTapDelay(object callback);
    5052
    5153    void simulateAccessibilitySettingsChangeNotification(object callback);
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

    r249112 r249125  
    7474    virtual void doAfterVisibleContentRectUpdate(JSValueRef callback) { doAsyncTask(callback); }
    7575
     76    virtual void doAfterDoubleTapDelay(JSValueRef callback) { doAsyncTask(callback); }
     77
    7678    // Preferences
    7779
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h

    r249112 r249125  
    4444    void ensurePositionInformationIsUpToDateAt(long x, long y, JSValueRef) override;
    4545    void doAfterVisibleContentRectUpdate(JSValueRef) override;
     46    void doAfterDoubleTapDelay(JSValueRef) override;
    4647    void zoomToScale(double scale, JSValueRef) override;
    4748    void retrieveSpeakSelectionContent(JSValueRef) override;
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r249112 r249125  
    11601160}
    11611161
     1162void UIScriptControllerIOS::doAfterDoubleTapDelay(JSValueRef callback)
     1163{
     1164    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
     1165
     1166    NSTimeInterval maximumIntervalBetweenSuccessiveTaps = 0;
     1167    for (UIGestureRecognizer *gesture in [platformContentView() gestureRecognizers]) {
     1168        if (![gesture isKindOfClass:[UITapGestureRecognizer class]])
     1169            continue;
     1170
     1171        UITapGestureRecognizer *tapGesture = (UITapGestureRecognizer *)gesture;
     1172        if (tapGesture.numberOfTapsRequired < 2)
     1173            continue;
     1174
     1175        if (tapGesture.maximumIntervalBetweenSuccessiveTaps > maximumIntervalBetweenSuccessiveTaps)
     1176            maximumIntervalBetweenSuccessiveTaps = tapGesture.maximumIntervalBetweenSuccessiveTaps;
     1177    }
     1178
     1179    if (maximumIntervalBetweenSuccessiveTaps) {
     1180        const NSTimeInterval additionalDelayBetweenSuccessiveTaps = 0.01;
     1181        maximumIntervalBetweenSuccessiveTaps += additionalDelayBetweenSuccessiveTaps;
     1182    }
     1183
     1184    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(maximumIntervalBetweenSuccessiveTaps * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
     1185        if (m_context)
     1186            m_context->asyncTaskComplete(callbackID);
     1187    });
     1188}
     1189
    11621190}
    11631191
Note: See TracChangeset for help on using the changeset viewer.