[webkit-reviews] review granted: [Bug 214444] Propagating user gesture through Fetch API : [Attachment 405131] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jul 24 03:21:55 PDT 2020


youenn fablet <youennf at gmail.com> has granted Jiewen Tan
<jiewen_tan at apple.com>'s request for review:
Bug 214444: Propagating user gesture through Fetch API
https://bugs.webkit.org/show_bug.cgi?id=214444

Attachment 405131: Patch

https://bugs.webkit.org/attachment.cgi?id=405131&action=review




--- Comment #9 from youenn fablet <youennf at gmail.com> ---
Comment on attachment 405131
  --> https://bugs.webkit.org/attachment.cgi?id=405131
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405131&action=review

> Source/WebCore/bindings/js/JSDOMWindowBase.cpp:218
> +    // Propogating media only user gesture for Fetch API's promise chain.

s/Propogating/Propagating

> Source/WebCore/bindings/js/JSDOMWindowBase.cpp:221
> +    bool isPropagatedToNextMicrotask = userGestureToken &&
userGestureToken->isPropagatedFromFetch();

We could do the following:
if (userGestureToken && !userGestureToken->isPropagatedFromFetch())
   userGestureToken = nullptr;
That way, no need to capture isPropagatedToNextMicrotask in the lambda.

> Source/WebCore/bindings/js/JSDOMWindowBase.cpp:228
> +	   UserGestureIndicator gestureIndicator(userGestureToken,
UserGestureToken::GestureScope::MediaOnly,
UserGestureToken::IsPropagatedFromFetch::Yes);

We could potentially WTFMove(userGestureToken).
Can we add a scope getter to UserGestureToken and replace
UserGestureToken::GestureScope::MediaOnly by userGesture->scope()?

> Source/WebCore/dom/UserGestureIndicator.cpp:58
> +void
UserGestureToken::setMaximumIntervalForUserGestureForwardingForFetchForTesting(
Seconds&& value)

s/Seconds&&/Seconds

> Source/WebCore/dom/UserGestureIndicator.cpp:60
> +    maxIntervalForUserGestureForwardingForFetch = WTFMove(value);

No need to move.

> Source/WebCore/dom/UserGestureIndicator.h:91
> +    // Expand the following methods if more progogation sources are added
later.

s/progogation/propagation/

> Source/WebCore/dom/UserGestureIndicator.h:95
> +    bool isPropagatedFromFetch() const { return m_isPropagatedFromFetch ==
IsPropagatedFromFetch::Yes; }

I would rename IsPropagatedFromFetch to ShouldPersistInNextMicrotask, ditto for
setter/getter/member.

> Source/WebCore/testing/Internals.cpp:5677
> +   
UserGestureToken::setMaximumIntervalForUserGestureForwardingForFetchForTesting(
Seconds(interval));

We probably need to set the value back to the regular value in
Internals::Internals so that the next test reusing the process will have the
default expected value.

>
LayoutTests/http/tests/media/user-gesture-preserved-across-xmlhttprequest.html:
50
> +	       fetch(request, { method: 'GET', cache: "no-cache"
}).then(response => {

Can we just do
fetch((`/xmlhttprequest/resources/download-header-with-delay.php?delay=${delay}
`, ( method...})?
This should be equivalent but it seems good to exercise this.


More information about the webkit-reviews mailing list