Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume user activation in element.requestFullscreen() #153

Merged
merged 1 commit into from
May 3, 2023

Conversation

@foolip foolip changed the title Consume user gesture in element.requestFullscreen() Consume user activation in element.requestFullscreen() May 28, 2019
@mustaqahmed
Copy link

Thanks, this looks good from user activation perspective.

@LanWei22
Copy link

web-platform-tests/wpt#16758 has been merged into wpt repository.
Three new tests about this behavior are now in https://w3c-test.org/fullscreen/api/
element-request-fullscreen-twice-manual.tentative.html
element-request-fullscreen-two-elements-manual.tentative.html
element-request-fullscreen-two-iframes-manual.tentative.html

fullscreen.bs Outdated
@@ -270,6 +270,9 @@ when invoked, must run these steps:
<li><p>This algorithm is <a>allowed to request fullscreen</a>.
</ul>

<li><p>If <var>error</var> is false, then <a>consume user activation</a> for

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This should now point to the newly added definition of consumption. Not sure why the PR preview doesn't show a link.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the preview is correctly pointing to the HTML spec link now.

Base automatically changed from master to main January 15, 2021 07:53
Copy link

@mustaqahmed mustaqahmed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to approve this PR, but apparently I don't have permission to do that! @domenic?

fullscreen.bs Outdated Show resolved Hide resolved
@domenic
Copy link
Member

domenic commented Nov 1, 2022

@foolip, can we help move this along? I'm happy to rebase it and also take care of any changes after #208.

This would probably solve the issue @marcoscaceres raises in web-platform-tests/wpt#36727 of giving a cross-browser way of consuming user activation.

@marcoscaceres
Copy link
Member

I guess it depends on what features/API calls follow a call to .requestFullScreen()... I see there is mention of Pointerlock in the bug and Screen Orientation Lock is another.

I'm simultaneously hoping we can prevent the Screen Orientation API (which depends on FS API) from arbitrarily changing the screen orientation without a user gesture.

If you have an Android device handy, try this out in Chrome:
https://marcoscaceres.github.io/playground/annoying.html

(if you can't try it out, it loops rapidly changing the screen orientation making it difficult of users to access the browsers UI - you need to either turn off the screen or quickly swipe from the bottom to stop it).

I personally don't think the above behavior should be acceptable for any API to do on the Web. So, I was hoping we wouldn't consume the user activation in FS API, but rather have the Screen Orientation API consume the user activation.

Alternatively, we could have it consume the user activation if #186 was in place, all in one go. The advantage being that it wouldn't breaking any sites that are depending on FS API to not consuming the user activation.

For pointerlock, maybe a solution like #186 could also work. You request them all at once, and exiting fulls screen releases all the locks.

@EdgarChen
Copy link
Member

Currently, Gecko also consume the user activation as we had received a bug of trapping the user in fullscreen mode, which invites DOS and spoofing possibilities. And for pointer lock, we allow it without a vaild user activation if document is in fullscreen mode.

@marcoscaceres
Copy link
Member

Discussing with my WebKit colleagues... but if both Gecko and Chromium consume it, we may follow suit. Let me get back to you.

And for pointer lock, we allow it without a vaild user activation if document is in fullscreen mode.

That is contrary to what is in the Pointer Lock spec, right? Why don't we just link the actions together via a mechanism like in #186?

(also, we should really rewrite the pointer lock spec to integrate properly with the Full Screen API)

fullscreen.bs Outdated Show resolved Hide resolved
@mustaqahmed
Copy link

mustaqahmed commented Nov 2, 2022

Currently, Gecko also consume the user activation as we had received a bug of trapping the user in fullscreen mode, which invites DOS and spoofing possibilities.

Chrome originally proposed this consumption behavior to prevent a spoof, see https://crbug.com/852645.

And for pointer lock, we allow it without a vaild user activation if document is in fullscreen mode.

That is contrary to what is in the Pointer Lock spec, right? Why don't we just link the actions together via a mechanism like in #186?

IIRC Chrome added a similar hack to support some compat argument, can't recall any details! Yes, #186 would be nice.

(Edited to fix the bug link)

@EdgarChen
Copy link
Member

#186 sounds reasonable to me.

@marcoscaceres
Copy link
Member

@EdgarChen, if we go with something like #207 (new dictionary member), would you be willing to remove the pointerLock workaround in Firefox? That way, we can just have a consistent model across three specs.

Similar question for Chrome folks. I'm willing to spec that up if everyone is supportive.

@EdgarChen
Copy link
Member

@EdgarChen, if we go with something like #207 (new dictionary member), would you be willing to remove the pointerLock workaround in Firefox?

To clarify this a bit more: This is not a workaround added for consuming user activation, we behave the same all the way back to Firefox 22 at least (before the current user activation model in spec is proposed). I am worried that removing this would cause compatibility problem. :(

@marcoscaceres
Copy link
Member

marcoscaceres commented Nov 11, 2022

@foolip, could you kindly please update the PR to use the "new" PR template? (I don't have the ability to edit the top comment)

Also, will you be updating any affected tests?

fullscreen.bs Outdated Show resolved Hide resolved
@marcoscaceres
Copy link
Member

Filed WebKit bug:
https://bugs.webkit.org/show_bug.cgi?id=247920

Thanks for the details about the tests, @foolip. If those can get updated and changed to non-tentative, that would be great.

foolip added a commit to foolip/wpt that referenced this pull request Nov 15, 2022
This makes a bunch of other tests redundant, as they're also calling
requestFullscreen() twice, and should all fail in exactly the same way.

element-request-fullscreen-same-manual.html is also converted to ensure
that a second call in a new click does work, to ensure the failure isn't
because the element is the same as the fullscreen element.

Follows whatwg/fullscreen#153.
@upsuper
Copy link
Member

upsuper commented Nov 15, 2022

I have a feeling that there is nothing wrong to allow requestFullscreen without user activation when the document is already in fullscreen, or is entering fullscreen (by a previous call). Though to be honest I'm not sure whether it is useful to allow that either.

foolip added a commit to foolip/wpt that referenced this pull request Nov 15, 2022
This makes a bunch of other tests redundant, as they're also calling
requestFullscreen() twice, and should all fail in exactly the same way.

element-request-fullscreen-same-manual.html is also converted to ensure
that a second call in a new click does work, to ensure the failure isn't
because the element is the same as the fullscreen element.

Follows whatwg/fullscreen#153.
@foolip foolip added the impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation label Nov 15, 2022
@foolip
Copy link
Member Author

foolip commented Nov 15, 2022

@upsuper I think you're right about that, since the page script already has full control over what's being presented and could replace all the contents of the current fullscreen element. However, that'd be a change from the currently implemented behavior, and I'd prefer to handle that separately from this. Can you file an issue if you think we should change that?

@foolip
Copy link
Member Author

foolip commented Nov 15, 2022

@marcoscaceres test PR is up and the whole PR template is filled in now.

@marcoscaceres
Copy link
Member

Thanks @foolip! Everything looks great.

fullscreen.bs Outdated Show resolved Hide resolved
webkit-commit-queue pushed a commit to nt1m/WebKit that referenced this pull request Dec 8, 2022
https://bugs.webkit.org/show_bug.cgi?id=247920
rdar://102355401

Reviewed by Youenn Fablet.

Matches Chrome & Firefox implementations, we should reset the activation timestamps when requesting fullscreen.
This disallows double non-user initiated requestFullscreen calls.

Spec PR: whatwg/fullscreen#153

WPT upstream revision: web-platform-tests/wpt@897b406

* LayoutTests/imported/w3c/web-platform-tests/fullscreen/api/element-request-fullscreen-consume-user-activation-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/fullscreen/api/element-request-fullscreen-consume-user-activation.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/fullscreen/api/element-request-fullscreen-same-element-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/fullscreen/api/element-request-fullscreen-same-element.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/fullscreen/api/w3c-import.log:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fullscreen/api/element-request-fullscreen-same-element-expected.txt: Added.
* Source/WebCore/dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::requestFullscreenForElement):

Canonical link: https://commits.webkit.org/257554@main
@marcoscaceres
Copy link
Member

This is now also implemented in WebKit.

@foolip, anything left to get this merged?

@foolip foolip dismissed domenic’s stale review May 3, 2023 07:23

Suggestion applied.

@foolip
Copy link
Member Author

foolip commented May 3, 2023

@marcoscaceres sorry I totally dropped the ball here. I've updated the PR and all I need now is review from someone with write access. Paging @annevk, as @domenic seems to be OOO today.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine. The step immediately preceding this could do with some love at some point. The booleans are still hurting me.

@foolip
Copy link
Member Author

foolip commented May 3, 2023

Thanks @annevk! Let me try inverting the preceding steps and see if you like that.

@foolip foolip merged commit b3bab96 into main May 3, 2023
@foolip foolip deleted the consume-user-activation branch May 3, 2023 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation
Development

Successfully merging this pull request may close these issues.

Consume user gestures in requestFullscreen
8 participants