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

Expose getBattery to ServiceWorker #4

Open
stefhak opened this issue May 19, 2016 · 8 comments
Open

Expose getBattery to ServiceWorker #4

stefhak opened this issue May 19, 2016 · 8 comments
Labels

Comments

@stefhak
Copy link

stefhak commented May 19, 2016

Sorry to be late to the party, but experimenting a bit with this feature on Chrome and Firefox I conclude that it is not available to ServiceWorkers. I think it could be useful there (e.g. the SW script checking if resources on the server have been updated, and download only if there is plenty of battery or the charger is connected).
Has this been discussed?

@anssiko
Copy link
Member

anssiko commented May 19, 2016

Yes. It was identified as a good candidate for future work (think v2), see: https://www.w3.org/2009/dap/wiki/FutureWork

@anssiko anssiko added the v2 label May 19, 2016
@stefhak
Copy link
Author

stefhak commented May 19, 2016

Thanks @anssiko.

@stefhak
Copy link
Author

stefhak commented May 19, 2016

However, the only change would be adding something like
[Exposed=(Window, Worker)] , right? Feels like a small thing to add to v1 (and even if worker exposure is not part of v1 [Exposed=Window] should be added(?).

@anssiko
Copy link
Member

anssiko commented May 19, 2016

The spec change is trivial, but the involved process is not.

The spec is now at PR. To add this new feature, we'd need to go back to WD, then CR and then again to PR and demonstrate interoperability i.e. wait for the existing implementations to update themselves and update the test suite as well.

@stefhak
Copy link
Author

stefhak commented May 19, 2016

I understand (I was just trying to push a bit :-) perhaps I should push on implementers instead).

@anssiko
Copy link
Member

anssiko commented May 19, 2016

I'll keep this issue open to collect feedback from implementers. If there's interest to expose this API to workers, I'll start work on v2.

One known issue in exposing to workers is of user consent. As of now, this API does not require user consent in any of the known implementations, but it could be that some future implementations might want to gate this behind a user prompt or some such. The getBattery() promise is there to provide an extension point for that.

@stefhak
Copy link
Author

stefhak commented May 19, 2016

Sounds good!

As for user consent: the path we've lately taken for gUM is to use the Permission API. This could be an opportunity (the page could ask for persisted permission to use getBattery which should carry over to a worker of the same origin; the worker script could check if it has permission and skip calling getBattery if not).

@anssiko
Copy link
Member

anssiko commented May 19, 2016

That's an interesting idea. Has that been field tested with any API? Related, for permission delegation to embedded web content (in an <iframe>), there's a rought idea: https://noncombatant.github.io/permission-delegation-api/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants