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

Reject with DomException or never reject #118

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

bvandersloot-mozilla
Copy link
Collaborator

@bvandersloot-mozilla bvandersloot-mozilla commented Sep 27, 2022

I am both rejecting with a "{{NotAllowedError}}" {{DomException}} in all contexts where we reject undefined and no longer rejecting where we don't want to leak user choice timing. (#60 and #37)


Preview | Diff

@bvandersloot-mozilla bvandersloot-mozilla changed the title Reject with DomException or never reject #60 and #37. Reject with DomException or never reject Sep 27, 2022
Copy link
Member

@johannhof johannhof left a comment

Choose a reason for hiding this comment

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

I don't think you can just leave the promise dangling like that, that will generate both memory leaks as well as developer experience problems for legitimate implementations.

I could imagine resolving #60 either through a fixed 2 min delay as in FedCM or simply an advisory in Privacy considerations that the UA should add jitter to its response that makes it harder to distinguish human users.

Let's do it in a separate PR, though.

@@ -202,19 +202,19 @@ When invoked on {{Document}} |doc|, the <dfn export method for=Document><code>re

1. Let |p| be [=a new promise=].
1. If |doc| is not [=Document/fully active=], then [=reject=] |p| with an "{{InvalidStateError}}" {{DOMException}} and return |p|.
1. If this algorithm was invoked when |doc|'s {{Window}} object did not have [=transient activation=], [=reject=] and return |p|.
1. If this algorithm was invoked when |doc|'s {{Window}} object did not have [=transient activation=], [=reject=] |p| with a "{{NotAllowedError}}" {{DomException}} and return |p|.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Casing is DOMException.

Any reason not use a generic TypeError? (That's JavaScript's catch-all error, despite "type" in the name.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will fix the casing if we settle on DOMExceptions.

I prefer it because it matches the type from line 204, so the promise will always reject with the same type. I also prefer more specific error types where possible and "the request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission" sounds like a good fit over the generic error.

Copy link
Member

Choose a reason for hiding this comment

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

Not using TypeError seems fine to me, FWIW. I'll add that I'm hoping to revisit error types for common failures across specs and may come to a different recommendation later. I agree that intuitively NotAllowedError seems best for activation so I'm fine with merging this.

@bvandersloot-mozilla
Copy link
Collaborator Author

@johannhof
I re-added the rejection of p where the permission is denied. I'll work on another patch to manage #60

Copy link
Collaborator

@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.

Thanks, this looks great modulo nit.

storage-access.bs Outdated Show resolved Hide resolved
Co-authored-by: Anne van Kesteren <[email protected]>
Copy link
Member

@johannhof johannhof left a comment

Choose a reason for hiding this comment

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

Thank you, Ben!

@johannhof johannhof merged commit 66a794d into privacycg:main Sep 29, 2022
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 10, 2022
This is reflected in the latest version of the spec, merged by privacycg/storage-access#118 .

Differential Revision: https://phabricator.services.mozilla.com/D158692

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1779575
gecko-commit: 4a2fa09ac7c8c56b8430418e56001b777be5b454
gecko-reviewers: anti-tracking-reviewers, smaug, timhuang
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Oct 10, 2022
… r=anti-tracking-reviewers,smaug,timhuang

This is reflected in the latest version of the spec, merged by privacycg/storage-access#118 .

Differential Revision: https://phabricator.services.mozilla.com/D158692
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 11, 2022
This is reflected in the latest version of the spec, merged by privacycg/storage-access#118 .

Differential Revision: https://phabricator.services.mozilla.com/D158692

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1779575
gecko-commit: 4a2fa09ac7c8c56b8430418e56001b777be5b454
gecko-reviewers: anti-tracking-reviewers, smaug, timhuang
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Oct 13, 2022
… r=anti-tracking-reviewers,smaug,timhuang

This is reflected in the latest version of the spec, merged by privacycg/storage-access#118 .

Differential Revision: https://phabricator.services.mozilla.com/D158692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants