haikuwebkit/LayoutTests/fast/animation/request-animation-frame-pro...

54 lines
1.5 KiB
HTML
Raw Permalink Normal View History

Propagate user gestures through `requestAnimationFrame` just like `setTimeout` https://bugs.webkit.org/show_bug.cgi?id=223775 <rdar://problem/75860868> Reviewed by Geoffrey Garen. Source/WebCore: `setTimeout` and `requestAnimationFrame` are used somewhat interchangeably on the web. There should be similar features/affordances for both so that if a developer decides to use a display-linked animation "loop" instead of a strictly time-based delay (or even a "loop") they're able to do similar things in the callback/handler. Test: fast/animation/request-animation-frame-propagate-user-gesture.html * dom/ScriptedAnimationController.h: * dom/ScriptedAnimationController.cpp: (WebCore::ScriptedAnimationController::resume): (WebCore::ScriptedAnimationController::registerCallback): (WebCore::ScriptedAnimationController::cancelCallback): (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks): Create a private struct for holding more data in the list of callbacks than just the callback itself. For now, the only other data saved is a `RefPtr<UserGestureToken>`. * testing/Internals.idl: * testing/Internals.h: * testing/Internals.cpp: (WebCore::Internals::withoutUserGesture): Added. Add a way for tests to guaranteed run arbitrary code without a user gesture. LayoutTests: * editing/pasteboard/dom-paste/dom-paste-requires-user-gesture.html: * fast/animation/request-animation-frame-propagate-user-gesture.html: Added. * fast/animation/request-animation-frame-propagate-user-gesture-expected.txt: Added. Canonical link: https://commits.webkit.org/235886@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-29 22:55:49 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests that user gestures are propagated through requestAnimationFrame");
jsTestIsAsync = true;
shouldBeFalse("internals.isProcessingUserGesture()");
debug("");
debug("Calling requestAnimationFrame without a user gesture...");
requestAnimationFrame(() => {
shouldBeFalse("internals.isProcessingUserGesture()");
debug("");
debug("Triggering a user gesture...");
internals.withUserGesture(() => {
debug("Calling requestAnimationFrame with a user gesture...");
requestAnimationFrame(() => {
shouldBeTrue("internals.isProcessingUserGesture()");
debug("");
debug("Calling requestAnimationFrame inside the callback of a prior requestAnimationFrame...");
requestAnimationFrame(() => {
shouldBeTrue("internals.isProcessingUserGesture()");
debug("");
debug("Overriding the user gesture...");
internals.withoutUserGesture(() => {
debug("Calling requestAnimationFrame without a user gesture...");
requestAnimationFrame(() => {
shouldBeFalse("internals.isProcessingUserGesture()");
debug("");
finishJSTest();
});
});
});
});
});
});
</script>
</body>
</html>