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

Fix #2: Clarify there is one battery promise per Document #3

Merged
merged 3 commits into from Apr 20, 2016

Conversation

anssiko
Copy link
Member

@anssiko anssiko commented Apr 12, 2016

Review appreciated from @domenic @mounirlamouri et al.

@mounirlamouri
Copy link
Member

Shouldn't we include workers too?

@anssiko
Copy link
Member Author

anssiko commented Apr 12, 2016

@mounirlamouri I'd consider expose to workers a v2 feature (feel free to open a separate issue for that).

@mounirlamouri
Copy link
Member

lgtm then

@mounirlamouri
Copy link
Member

(I don't have write access so I can't merge.)

@domenic
Copy link
Contributor

domenic commented Apr 12, 2016

This isn't quite sufficient. When creating the BatteryManager object, you need to be clear what realm it's being created in.

@domenic
Copy link
Contributor

domenic commented Apr 12, 2016

For example, if I run code in window3 that does window2.navigator.getBattery.call(window1.navigator), which of the three windows' realms is the BatteryManager created in.

@anssiko
Copy link
Member Author

anssiko commented Apr 13, 2016

@mounirlamouri You have write access now (sorry, my bad).

@domenic To be consistent with the rest of the platform, with which realm you'd suggest we associated the BatteryManager with in scenarios that involve nested browsing contexts?

@domenic
Copy link
Contributor

domenic commented Apr 13, 2016

I'm not sure. @bzbarsky may have an opinion. To rephrase the question, given code in window3 that does window2.navigator.getBattery.call(window1.navigator), which returns a promise to be fulfilled with a BatteryManager: which of the three windows' Realms is the BatteryManager created in?

For that matter, which of the three realms is the Promise created in? :-/

@domenic
Copy link
Contributor

domenic commented Apr 13, 2016

Ah, I found the thread I was searching for where @bzbarsky expressed an opinion previously: w3ctag/promises-guide#46 (comment)

So, now that I remember his reasoning, window1 is correct. Un-summoning @bzbarsky.

After a meeting I have to dash to I'll get back with some proposed spec text.

@domenic
Copy link
Contributor

domenic commented Apr 13, 2016

Suggested:

  • Instead of each Document having a battery promise, make it each Navigator object. They are equivalent, but it will be easier to write the following spec text.
  • Make the following updates to the getBattery() method definition:
    • Please number the steps, instead of using bullets.
    • Replace all references to "battery promise" with "this Navigator object's battery promise".
    • Replace step 2 with "Otherwise, set this Navigator object's battery promise to a newly created Promise, created in the Realm of this Navigator object."
    • Replace step 4 with "create a new BatteryManager object in the Realm of this Navigator object, and let battery be that object."

@bzbarsky
Copy link

It's not clear to me that Document and Navigator are equivalent here. Aren't Navigator objects per-Window, not per-Document?

Apart from that, I agree that using the Navigator object's realm for the Promise and the BatteryManager seems like the right thing.

@anssiko
Copy link
Member Author

anssiko commented Apr 14, 2016

Would anyone object us merging this PR and use that for the Rec Track advancement, while we in parallel incubate @domenic's Realm patch #3 (comment) in the Editor's Draft and after baked in release a Proposed (Edited) Recommendation that integrates these further clarifications?

I believe that'd minimize the process-related back-and-forths and allow us to make forward progress on all the fronts.

@domenic
Copy link
Contributor

domenic commented Apr 14, 2016

No, this PR is not sufficient for REC.

@anssiko
Copy link
Member Author

anssiko commented Apr 14, 2016

Ok, I was not clear whether @bzbarsky was actually suggesting further changes to @domenic's patch #3 (comment). If the patch is good as is, I'll update this PR.

@domenic
Copy link
Contributor

domenic commented Apr 14, 2016

Boris is right that Navigator and Document are not equivalent. In particular, given the navigation from the original about:blank document, Navigator will stay the same, while Document will vary. And when you use document.open(), Document will stay the same, while Navigator will vary.

That said, I think using Navigator is better. In those situations, I would expect the same promise to be returned for about:blank navigation, and a new promise to be returned after document.open(). But we should ask @mounirlamouri what he thinks as an implementer since he says in Blink uses Document.

If @mounirlamouri prefers Document, then amend my above to replace "this Navigator object's battery promise" with "this Navigator object's relevant settings object's global object's newest Document object's battery promise"

- Add Realms [ECMASCRIPT] reference to Terminology
- Editorial: use a numbered list for the getBattery() steps
@anssiko
Copy link
Member Author

anssiko commented Apr 19, 2016

@domenic @mounirlamouri Updated the PR, please take a look, thanks!

@@ -149,12 +150,15 @@
<code><dfn><a href=
"https://www.w3.org/TR/html5/dom.html#document">Document</a></dfn></code>
Copy link
Contributor

Choose a reason for hiding this comment

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

Document appears to be unused in this file now

@domenic
Copy link
Contributor

domenic commented Apr 19, 2016

LGTM with nits. But definitely needs @mounirlamouri's input given that it's different than Blink's implementation.

@anssiko
Copy link
Member Author

anssiko commented Apr 20, 2016

@domenic Much thanks for the review. I fixed your nits with f7c9a02.

@mounirlamouri Please let us know if you're happy about the prose in this PR or whether to go the other way described in #3 (comment)

@mounirlamouri
Copy link
Member

lgtm. Actually, Blink has one BatteryManager per Navigator object. I misread the code. FTR, I did not implement this in Blink. I did implement most of it in Gecko though ;)

@anssiko
Copy link
Member Author

anssiko commented Apr 20, 2016

Thanks!

Ping @dontcallmedom re possible process implications.

@anssiko anssiko merged commit bdfe0f2 into gh-pages Apr 20, 2016
@dontcallmedom
Copy link
Member

thanks; it will be easier to assess the process implications once we have an updated test suite and clarity as to whether the spec change does indeed match the existing browser behavior

zqzhang pushed a commit to zqzhang/web-platform-tests that referenced this pull request May 6, 2016
…avigator object

Corresponding spec changes are at w3c/battery#3
and the original issue is at w3c/battery#2
zqzhang pushed a commit to zqzhang/web-platform-tests that referenced this pull request May 6, 2016
…avigator object

Corresponding spec changes are at w3c/battery#3
and the original issue is at w3c/battery#2
zqzhang pushed a commit to web-platform-tests/wpt that referenced this pull request May 13, 2016
…avigator object (#2962)

Corresponding spec changes are at w3c/battery#3
and the original issue is at w3c/battery#2
arronei pushed a commit to arronei/web-platform-tests that referenced this pull request Jun 14, 2016
…avigator object (web-platform-tests#2962)

Corresponding spec changes are at w3c/battery#3
and the original issue is at w3c/battery#2
ivanzr pushed a commit to ivanzr/web-platform-tests that referenced this pull request Jun 29, 2016
…avigator object (web-platform-tests#2962)

Corresponding spec changes are at w3c/battery#3
and the original issue is at w3c/battery#2
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.

None yet

5 participants