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

Add a navigator interface for user activation state. #8254

Merged
merged 6 commits into from
Sep 14, 2022

Conversation

mustaqahmed
Copy link
Contributor

@mustaqahmed mustaqahmed commented Sep 2, 2022

Fixes: #4008

(See WHATWG Working Mode: Changes for more details.)


/index.html ( diff )
/interaction.html ( diff )

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Thanks for this! I pushed a few minor fixes for style things; please pull them before doing any work.

Unfortunately it turns out the normative prose for the getters here is not great and needs some work. The biggest problem is that this class is exposed to Worker and AudioWorklet, but I have no idea how it could work there.

If we restrict this only to Window (maybe that is OK, since it's only accessible in this PR via window.navigator?) then we can improve the getter definitions as follows. You need to define that each Navigator object (or, perhaps simpler, each Window object) has a corresponding UserActivation object; then, the userActivation getter steps can be defined to return that. For an example, see https://html.spec.whatwg.org/#associated-navigator .

Then, we need to define the hasBeenActive and isActive getter steps in a way that connects up to the actual normative prose for sticky and transient activation. I believe this would be done using something like:

The hasBeenActive getter steps are to return true if this's relevant global object has sticky activation; otherwise false.

with the understanding that this only ever works for the Window context, and would need to be redone in a Worker or AudioWorklet context.

@mustaqahmed mustaqahmed requested a review from domenic September 8, 2022 15:49
@mustaqahmed
Copy link
Contributor Author

Unfortunately it turns out the normative prose for the getters here is not great and needs some work. The biggest problem is that this class is exposed to Worker and AudioWorklet, but I have no idea how it could work there.

That's a good point: because Workers and Worklets are not exposed to users, there is no way these could be activated. Removed them from the Exposed interfaces.

If we restrict this only to Window (maybe that is OK, since it's only accessible in this PR via window.navigator?) then we can improve the getter definitions as follows. You need to define that each Navigator object (or, perhaps simpler, each Window object) has a corresponding UserActivation object; then, the userActivation getter steps can be defined to return that. For an example, see https://html.spec.whatwg.org/#associated-navigator .

Please check my latest patch.

Alternatively, we can move the first IDL definition here to Sec 6.4.1 where we defined "user-activation-states", but it seems more logical to me that the exposed pieces are separated from the (unexposed) data model in the browser. Thoughts?

Then, we need to define the hasBeenActive and isActive getter steps in a way that connects up to the actual normative prose for sticky and transient activation. I believe this would be done using something like:

The hasBeenActive getter steps are to return true if this's relevant global object has sticky activation; otherwise false.

with the understanding that this only ever works for the Window context, and would need to be redone in a Worker or AudioWorklet context.

Done.

@mustaqahmed mustaqahmed mentioned this pull request Sep 8, 2022
source Show resolved Hide resolved
source Show resolved Hide resolved
@mustaqahmed
Copy link
Contributor Author

Please take a look again.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Can you file bugs on Gecko and WebKit and update the original post with them?

@domenic domenic merged commit 823a14b into whatwg:main Sep 14, 2022
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 15, 2022
The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
@mustaqahmed
Copy link
Contributor Author

LGTM, thanks! Can you file bugs on Gecko and WebKit and update the original post with them?

Done.

aarongable pushed a commit to chromium/chromium that referenced this pull request Sep 16, 2022
The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900591
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048227}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 16, 2022
The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900591
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048227}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 16, 2022
The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900591
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048227}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 24, 2022
…as non-tentative., a=testonly

Automatic update from web-platform-tests
Mark user-activation-query related WPTs as non-tentative.

The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900591
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048227}

--

wpt-commits: 87986b1b4f79e991b7867278e5a1bf23423a652a
wpt-pr: 35920
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Sep 27, 2022
…as non-tentative., a=testonly

Automatic update from web-platform-tests
Mark user-activation-query related WPTs as non-tentative.

The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900591
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048227}

--

wpt-commits: 87986b1b4f79e991b7867278e5a1bf23423a652a
wpt-pr: 35920
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
The query API has been added recently to the HTML spec:
whatwg/html#8254

Change-Id: I66e96b7a49a548f02acdaf2c4efb717fc27dcdc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900591
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048227}
NOKEYCHECK=True
GitOrigin-RevId: b49d885c2dba31b48c97484206ef9218c4fd0e08
mnutt pushed a commit to movableink/webkit that referenced this pull request Dec 6, 2022
https://bugs.webkit.org/show_bug.cgi?id=245240

Reviewed by Youenn Fablet and Geoffrey Garen.

Implementation of the UserActivation interface:
https://html.spec.whatwg.org/#the-useractivation-interface

Which was added to HTML via:
whatwg/html#8254

The API provides web content a view into DOMWindow::hasTransientActivation()
and DOMWindow::hasStickyActivation(). This change excludes anything
related "MessageEvent", which has not yet been agreed to by the WHATWG.

The tests have been modified to work on WebKit infrastructure without
changing the intent of the original tests. In particular:

* `domains[www1]` and so on, so those are changed to `hosts[alt][]`
* Domains are differentiated by using different ports.
* Some of the tests are missing `await`.
* Some tests would run before the body was ready.

A PR has been sent to WPT to address these issues:
web-platform-tests/wpt#36881

The tests are update to 1b73dcd.

Some test coming form WTP are non-standard. In particular, tests that
rely on `window.open()` and `.requestFullscreen()` are not spec'ed
to consume user activation. This is a known issue and will be addressed
as a followup in the specs and potentially as changes in WebKit.

* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-keyboard-enter.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-keyboard-escape.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-mouse-left.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-mouse-right.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/activation-trigger-pointerevent.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/chained-setTimeout-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/chained-setTimeout.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/chained-setTimeout.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/chained-setTimeout.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-crossorigin.sub-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-crossorigin.sub.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-crossorigin.sub.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-crossorigin.sub.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-sameorigin-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-sameorigin.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-sameorigin.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/consumption-sameorigin.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/detached-iframe-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/detached-iframe.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/message-event-init.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/message-event-init.tentative.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-crossorigin.sub-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-crossorigin.sub.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-crossorigin.sub.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-crossorigin.sub.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-sameorigin-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-sameorigin.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-sameorigin.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/navigation-state-reset-sameorigin.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/no-activation-thru-escape-key-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/no-activation-thru-escape-key.html:
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-crossorigin.sub-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-crossorigin.sub.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-crossorigin.sub.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-crossorigin.sub.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-sameorigin-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-sameorigin.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-sameorigin.tentative.html.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/propagation-sameorigin.tentative-expected.txt: Removed.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/user-activation-interface-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/user-activation/user-activation-interface.html: Added.
* LayoutTests/platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/platform/ios-wk2/TestExpectations:
* LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/user-activation/chained-setTimeout.tentative-expected.txt: Removed.
* LayoutTests/platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/user-activation/no-activation-thru-escape-key-expected.txt:
* LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt:
* Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/html/NavigatorUserActivation.cpp: Added.
(WebCore::NavigatorUserActivation::NavigatorUserActivation):
(WebCore::NavigatorUserActivation::userActivation):
(WebCore::NavigatorUserActivation::from):
(WebCore::NavigatorUserActivation::supplementName):
* Source/WebCore/html/NavigatorUserActivation.h: Added.
* Source/WebCore/html/URLSearchParams.h:
* Source/WebCore/html/UserActivation.cpp: Added.
(WebCore::UserActivation::create):
(WebCore::UserActivation::UserActivation):
(WebCore::UserActivation::navigator):
(WebCore::UserActivation::window const):
(WebCore::UserActivation::hasBeenActive const):
(WebCore::UserActivation::isActive const):
* Source/WebCore/html/UserActivation.h: Added.
* Source/WebCore/html/UserActivation.idl: Added.
* Source/WebCore/page/DOMWindow.cpp:
(WebCore::DOMWindow::hasStickyActivation const):
* Source/WebCore/page/DOMWindow.h:
* Source/WebCore/page/Navigator+UserActivation.idl: Added.

Canonical link: https://commits.webkit.org/256572@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to query UserActivation state
2 participants