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 static requestPermission method on Window #167

Merged
merged 2 commits into from
Apr 1, 2019

Conversation

kenchris
Copy link
Contributor

@kenchris kenchris commented Mar 28, 2019

Fixes #156

This also corrects an error in the obtain permission algorithm


Preview | Diff

index.html Outdated
<a>query a permission</a> with |permissionDesc|.
</li>
<li>
If |permission| is "<a>denied</a>",
return <code>false</code>.
Let |status:PermissionStatus| be the result awaiting
Copy link
Member

Choose a reason for hiding this comment

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

"awaiting |resultPromise| to settle" -> "waiting for |resultPromise| to settle"

index.html Outdated
</li>
<li>
Let |status:PermissionStatus| be the result awaiting
|resultPromise| to settle.
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

index.html Outdated
<ol>
<li>
Let |resultPromise| be the result of running
<a>query a permission</a> with |permissionDesc|.
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using the "query a permission" algorithm and restating a lot of the same logic from above can we reuse the "obtain permission" algorithm?

Copy link
Contributor Author

@kenchris kenchris Mar 29, 2019

Choose a reason for hiding this comment

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

Sure, I have done that now

@kenchris
Copy link
Contributor Author

@marcoscaceres

index.html Outdated
<a>query a permission</a> with |permissionDesc|.
</li>
<li>
If |permission| is "<a>denied</a>",
return <code>false</code>.
Let |status:PermissionStatus| be the result waiting for
Copy link
Member

Choose a reason for hiding this comment

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

"the result of"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

index.html Outdated
and abort these steps.
</li>
<li>
Let |signal| be the |options|’ dictionary member
Copy link
Member

Choose a reason for hiding this comment

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

Stray backtick?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

@kenchris kenchris dismissed reillyeon’s stale review April 1, 2019 10:47

Fixed Reilly's comments

@kenchris kenchris merged commit d201817 into w3c:gh-pages Apr 1, 2019
@marcoscaceres
Copy link
Member

I was in the middle of a review! :( Can I please please pleast ask that you don't merge stuff before you have multiple browser vendors review the spec AND you have tests for each PR.

</li>
<li>
If |permission| is "<a>granted</a>",
return <code>true</code>.
If |resultPromise| rejects, return "<a>denied</a>".
Copy link
Member

Choose a reason for hiding this comment

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

This is misleading, because the IDL conversion might have caused the rejection in the permission spec (i.e., it's not denied - it's some other exception). However, I think it might be impossible for it to reject, because the algorithm is always providing a well-formed PermissionDescriptor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You could argue that even if you supply something invalid, then that couldn't be granted. Of course logging that would probably be useful.

Should I add a comment about us always providing a well-formed PermissionDescriptor?

Copy link
Member

Choose a reason for hiding this comment

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

Should I add a comment about us always providing a well-formed PermissionDescriptor?

If we are sure we always send in a valid object, then we can be confident it won't ever reject based on what's in the permissions spec. If that's the case, then we don't need to handle rejections.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still, does that deserve a NOTE?

@@ -221,7 +221,8 @@ <h2>
</ol>
<p>
To <dfn>obtain permission</dfn> for <a>wake lock type</a>
|type|, run these steps <a>in parallel</a>:
|type|, run these steps <a>in parallel</a>. This async algorithm
returns either "<a>granted</a>" or "<a>denied</a>".
</p>
<ol class="algorithm">
<li>
Copy link
Member

Choose a reason for hiding this comment

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

Below this line, there is a PermissionDescriptor being created inside a pre... that's not correct. You need:

Let |permissionDesc:PermissionDescriptor| be the following be a newly created PermissionDescriptor.
Set |permissionDesc|.name to "wake-lock",
Set |permissionDesc|.type to | type|.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This followed the approach used in Web USB. I can change of course, but @reillyeon input might be useful

Copy link
Member

Choose a reason for hiding this comment

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

Because we got here from requestPermission(), we are already in WebIDL land inside the algorithm (so technically in the C++ implementation)... so you can literally just create: PermissionDescriptor permissionDesc; and then assign it the name (as above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe you could file an issue for Web USB?

Copy link
Contributor Author

@kenchris kenchris Apr 1, 2019

Choose a reason for hiding this comment

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

Done - used your suggestions

attribute of |status|.
</li>
<li>
If |state| is "<a>prompt</a>", run the following steps:
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't feel right for this spec to override the results of the permission grant of the permission spec. Why not let it prompt?

Something is either wrong in this spec or in the Permissions spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Permission spec allows you to query, and to prompt separately. These are separate algorithms.

I based this on existing spec text, but Web USB does similar (though it uses "ask") as well as device motion uses "default" the same way "prompt" is used here (as that spec doesn't depend on permission api)

index.html Show resolved Hide resolved
@kenchris
Copy link
Contributor Author

kenchris commented Apr 1, 2019

Oh sorry @marcoscaceres - I am trying to balance things moving forward and major time-zone differences.

You can still review and I can create additional PRs to fix what you find.

We have a separate person responsible for testing - but I will need to follow up with them

@marcoscaceres
Copy link
Member

It happens :)

I am trying to balance things moving forward

Ok, but don't rush ahead if you only have one implementer and no tests. That's just going to put us back where we were before.

I'll send a PR template that we've used successfully in Payments.

major time-zone differences.

heh, hi from SF where it's 4:23am! 💃

@kenchris
Copy link
Contributor Author

kenchris commented Apr 1, 2019

Ok, but don't rush ahead if you only have one implementer and no tests. That's just going to put us back where we were before.

Sure, the current status is that the spec had so many issues that it needed major changes, so there is really no implementation of the current spec as this point, though the plan is to have that as soon as possible, including tests

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