Changeset 245057 in webkit


Ignore:
Timestamp:
May 8, 2019 10:15:21 AM (5 years ago)
Author:
Wenson Hsieh
Message:

TestRunnerWKWebView's menu callbacks should be cleared upon UI script completion
https://bugs.webkit.org/show_bug.cgi?id=197685

Reviewed by Alex Christensen.

Tools:

Fixes a bug in the test runner wherein didShowMenuCallback and didHideMenuCallback are not reset upon UI script
completion. See LayoutTests/ChangeLog for more details.

  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::platformClearAllCallbacks):

LayoutTests:

Adjust a couple of existing layout tests such that they don't rely on didShowMenuCallback and
didHideMenuCallback sticking around across UI scripts. Currently, these layout tests do the following:

  1. Run a UI script that registers menu callback handlers.
  2. Run a subsequent UI script that will cause the callback handlers to be fired (e.g. clicking on an element).

After making the change in the test runner to clear menu callbacks upon script completion, callbacks registered
in step (1) are now unregistered when step (2) completes. Instead, we can rewrite this test logic so that
they're driven by a single UI script.

  • editing/pasteboard/ios/dom-paste-consecutive-confirmations.html:
  • editing/pasteboard/ios/dom-paste-requires-user-gesture.html:

Instead of using internals.withUserGesture, put the test logic under a click handler (which is inside the scope
of a user gesture token), and then use requestAnimationFrame to schedule a second programmatic paste that is
outside the scope of user interaction. As opposed to setTimeout, requestAnimationFrame does not propagate the
current user gesture token.

  • editing/pasteboard/ios/resources/dom-paste-helper.js:

(return.new.Promise.):
(async._waitForOrTriggerPasteMenu):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245053 r245057  
     12019-05-08  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        TestRunnerWKWebView's menu callbacks should be cleared upon UI script completion
     4        https://bugs.webkit.org/show_bug.cgi?id=197685
     5
     6        Reviewed by Alex Christensen.
     7
     8        Adjust a couple of existing layout tests such that they don't rely on didShowMenuCallback and
     9        didHideMenuCallback sticking around across UI scripts. Currently, these layout tests do the following:
     10
     11        1. Run a UI script that registers menu callback handlers.
     12        2. Run a subsequent UI script that will cause the callback handlers to be fired (e.g. clicking on an element).
     13
     14        After making the change in the test runner to clear menu callbacks upon script completion, callbacks registered
     15        in step (1) are now unregistered when step (2) completes. Instead, we can rewrite this test logic so that
     16        they're driven by a single UI script.
     17
     18        * editing/pasteboard/ios/dom-paste-consecutive-confirmations.html:
     19        * editing/pasteboard/ios/dom-paste-requires-user-gesture.html:
     20
     21        Instead of using internals.withUserGesture, put the test logic under a click handler (which is inside the scope
     22        of a user gesture token), and then use requestAnimationFrame to schedule a second programmatic paste that is
     23        outside the scope of user interaction. As opposed to setTimeout, requestAnimationFrame does not propagate the
     24        current user gesture token.
     25
     26        * editing/pasteboard/ios/resources/dom-paste-helper.js:
     27        (return.new.Promise.):
     28        (async._waitForOrTriggerPasteMenu):
     29
    1302019-05-08  Rob Buis  <rbuis@igalia.com>
    231
  • trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html

    r242551 r245057  
    5050                doneCount = 0;
    5151                function incrementProgress() {
    52                     if (++doneCount === 4)
     52                    if (++doneCount === 5)
    5353                        uiController.uiScriptComplete();
    5454                }
    5555
    5656                uiController.didHideMenuCallback = incrementProgress;
    57                 uiController.didShowMenuCallback = () => {
     57                uiController.didShowMenuCallback = tapPasteMenuAction;
     58
     59                function tapPasteMenuAction() {
    5860                    const rect = uiController.rectForMenuAction("Paste");
    5961                    uiController.singleTapAtPoint(rect.left + rect.width / 2, rect.top + rect.height / 2, incrementProgress);
    60                 };
     62                }
     63
     64                uiController.singleTapAtPoint(160, 50, incrementProgress);
    6165            })()`, resolve);
    6266    });
     
    8185        return;
    8286
    83     waitForAndTapPasteMenuTwice().then(finishJSTest);
    8487    await UIHelper.activateAt(160, 125);
    85     await UIHelper.activateAt(160, 50);
     88    await waitForAndTapPasteMenuTwice();
     89    finishJSTest();
    8690});
    8791</script>
  • trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html

    r242551 r245057  
    4444description("Verifies that no callout is shown when the page programmatically triggers paste outside the scope of user interaction. This test requires WebKitTestRunner.");
    4545
     46function checkDone() {
     47    if (!window.doneCount)
     48        doneCount = 0;
     49
     50    if (++doneCount == 2)
     51        finishJSTest();
     52}
     53
     54editor.addEventListener("click", event => {
     55    editor.focus();
     56    shouldBe("document.execCommand('Paste')", "true");
     57    requestAnimationFrame(() => {
     58        shouldBe("document.execCommand('Paste')", "false")
     59        shouldBeEqualToString("editor.textContent", "Click here to copy");
     60        checkDone();
     61    });
     62});
     63
    4664addEventListener("load", async () => {
    47     UIHelper.activateAt(160, 125).then(() => {
    48         editor.focus();
    49         waitForPasteMenu().then(finishJSTest);
    50 
    51         UIHelper.ensurePresentationUpdate().then(() => {
    52             internals.withUserGesture(() => shouldBe("document.execCommand('Paste')", "true"));
    53             shouldBe("document.execCommand('Paste')", "false");
    54             shouldBeEqualToString("editor.textContent", "Click here to copy");
    55         });
    56     });
     65    await UIHelper.activateAt(160, 125);
     66    await triggerPasteMenuAfterTapAt(160, 50);
     67    checkDone();
    5768});
    5869</script>
  • trunk/LayoutTests/editing/pasteboard/ios/resources/dom-paste-helper.js

    r241322 r245057  
    1111
    1212                uiController.didHideMenuCallback = checkDone;
    13                 uiController.didShowMenuCallback = () => {
     13
     14                function tapPasteMenuAction() {
    1415                    if (${proceedWithPaste}) {
    1516                        const rect = uiController.rectForMenuAction("Paste");
     
    1920                        checkDone();
    2021                    }
    21                 };
     22                }
     23
     24                if (uiController.isShowingMenu)
     25                    tapPasteMenuAction();
     26                else
     27                    uiController.didShowMenuCallback = tapPasteMenuAction;
    2228
    2329                if (${shouldTap})
  • trunk/Tools/ChangeLog

    r245045 r245057  
     12019-05-08  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        TestRunnerWKWebView's menu callbacks should be cleared upon UI script completion
     4        https://bugs.webkit.org/show_bug.cgi?id=197685
     5
     6        Reviewed by Alex Christensen.
     7
     8        Fixes a bug in the test runner wherein didShowMenuCallback and didHideMenuCallback are not reset upon UI script
     9        completion. See LayoutTests/ChangeLog for more details.
     10
     11        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     12        (WTR::UIScriptController::platformClearAllCallbacks):
     13
    1142019-05-07  Oriol Brufau  <obrufau@igalia.com>
    215
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r244955 r245057  
    994994void UIScriptController::platformClearAllCallbacks()
    995995{
    996     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
    997    
    998     webView.didStartFormControlInteractionCallback = nil;
    999     webView.didEndFormControlInteractionCallback = nil;
    1000     webView.didShowForcePressPreviewCallback = nil;
    1001     webView.didDismissForcePressPreviewCallback = nil;
    1002     webView.didEndZoomingCallback = nil;
    1003     webView.willBeginZoomingCallback = nil;
    1004     webView.didHideKeyboardCallback = nil;
    1005     webView.didShowKeyboardCallback = nil;
    1006     webView.willPresentPopoverCallback = nil;
    1007     webView.didDismissPopoverCallback = nil;
    1008     webView.didEndScrollingCallback = nil;
    1009     webView.rotationDidEndCallback = nil;
     996    [TestController::singleton().mainWebView()->platformView() resetInteractionCallbacks];
    1010997}
    1011998
Note: See TracChangeset for help on using the changeset viewer.