-
Notifications
You must be signed in to change notification settings - Fork 51
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
Integrate "request permission to use" with user activation #401
base: main
Are you sure you want to change the base?
Conversation
Allows "request permission to use" to accept an optional promise. The promise gets rejected if the page doesn't have transient activation. Also, when the promise is passed, the algorithm now consumes the user activation. If passed, the promise is resolved with the user's choice.
Expected use would be something like:
|
I kinda like this, because it works for legacy APIs (e.g. Geolocation) and for new APIs. |
The expected usage there is wrong. You cannot react to a promise while in parallel. You'd have to queue a task. Also, I think Notifications is currently a permission-thingie for which no user activation is required in one implementation (Chromium), but maybe that should be considered a bug. |
<li>If |global| does not have [=transient activation=], [=queue a global task=] on | ||
the [=user interaction task source=] given |global| to [=reject=] |promise| with a | ||
"{{NotAllowedError}}" {{DOMException}} and abort these steps. | ||
</li> | ||
<li>Otherwise, [=consume user activation=] of |global|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this really works if "requesting permission to use" is called while in parallel as the transient activation check really has to happen in the main thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, true...
As a shorthand, <a>requesting permission to use</a> a {{DOMString}} |name|, is the same | ||
as <a>requesting permission to use</a> a {{PermissionDescriptor}} with its | ||
As a shorthand, <a>requesting permission to use</a> a {{DOMString}} |name| and |promise|, | ||
is the same as <a>requesting permission to use</a> a {{PermissionDescriptor}} with its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example of using this shorthand? Looking at https://notifications.spec.whatwg.org/#dom-notification-requestpermission... is it something like requesting permission to use "notifications" with |promise|?
If so, s/and/with/?
(And probably {{PermissionDescriptor/name}} member set to |name| with |promise|
below?)
"export">request permission to use</dfn> a |descriptor:PermissionDescriptor|, with | ||
optionally a |promise:Promise|: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make call sites easy to read, and I don't think "request permission to use |descriptor| with |promise|" explains to readers what the promise is going to mean. Readers shouldn't need to click through in order to read the call site, which means the call site needs to mention [=transient activation=]. I think something like
"export">request permission to use</dfn> a |descriptor:PermissionDescriptor|, with | |
optionally a |promise:Promise|: | |
"export">request permission to use</dfn> a |descriptor:PermissionDescriptor|, optionally | |
with [=transient activation=] consumed through a |promise:Promise|: |
would be somewhat better, although "consumed through" is still obscure, and you might come up with better ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you should define a named parameter: https://infra.spec.whatwg.org/#algorithm-params. (It's not clear to me how a caller would invoke the suggestion. Transient activation is also a property of a Window object.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... I wonder then if we should define an entirely new algorithm that returns a promise (is not passed one), then see how many specs we can migrate over.
That would allow geolocation (and maybe other specs) to keep working, but provide the right infra for this.
Allows "request permission to use" to accept an optional promise.
The promise gets rejected if the page doesn't have transient activation. Also, when the promise is passed, the algorithm now consumes the user activation. If passed, the promise is resolved with the user's choice.
closes #194
Preview | Diff