-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
WakeLockRequest is independent rather than WakeLock #8416
WakeLockRequest is independent rather than WakeLock #8416
Conversation
edited by wpt-pr-bot
- Test wake lock state is global
- Test two wake lock returns same object
- Fixed wakelock-object-is-independent.https.html does not reflect the spec intent #8411
Build PASSEDStarted: 2017-11-28 01:42:32 View more information about this build on: |
- Test wake lock state is global - Test two wake lock returns same object - Fix web-platform-tests#8411
|
||
<body> | ||
<script id="iframe" type="text/plain"> | ||
let iframeWakeLock, iframeRequest; |
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... this is super racy... we can live with it... but not my favorite.
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 a bit concerned about wakelock-state-is-global.https.html
, tbh... the design of using a global is quite racy. I could be convinced to live with it, but can you maybe come up with a better way of keeping state than relying on globals?
assert_true(isActive1, "the iframe wake lock state is actived when iframe wake lock is acquired"); | ||
assert_true(wakeLock.active, "the wake lock state is actived when iframe wake lock is acquired"); | ||
|
||
|
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.
nit: remove this line.
If you can't come up with anything better for wakelock-state-is-global.https.html, that's ok... let me know. |
@marcoscaceres, thanks for your review, I'm afraid I have no much better idea, @andrey-logvinov, do you have any good opinion? |
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 guess we have enough flow control in the test that should prevent race conditions. Hopefully this won't come back to bite us.
@marcoscaceres, thanks, I hope so. :) |
Ok, merging to move forward, but @andrey-logvinov, please do take a look and file any bugs you might find (or if you can think of another way of testing this). |
to reflect tests change in web-platform-tests/wpt#8416
@@ -0,0 +1,13 @@ | |||
<!DOCTYPE html> | |||
<meta charset="utf-8"> | |||
<title>navigator.getWakeLock() for the same Document always return same WakeLock promise</title> |
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.
It is not required to always return the same promise - it is only required that if a returned promise is ever resolved, all returned promises must be resolved with the same value. Also it must not happen that one promise is resolved and another for the same Document is rejected, or vice versa. Also rejections must be consistent, e.g. if one promise is rejected with SecurityException, the other must be rejected also with SecurityException, but it is not required for two exceptions to be the same 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.
it is only required that if a returned promise is ever resolved, all returned promises must be resolved with the same value.
About this checkpoint, isn't the test satisfied? For sure, the desc is a bit misunderstanding.
Also rejections must be consistent, e.g. if one promise is rejected with SecurityException, the other must be rejected also with SecurityException, but it is not required for two exceptions to be the same object.
But how to prove that the rejection is caused by other rejected promise in same Document? Since the rejected condition is global, they should be rejected beyond doubt.
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.
Sorry for late response.
If I understand it correctly the test asserts that the same promise object is returned, which necessarily implies that the resolution is also the same. But the spec does not require to return exactly the same promise. This is not very relevant from the script point of view but it might complicate an implementation e.g. if it is technically easier to return different promise objects resolved with the same value than exactly the promise object. For now I think the test is adequate.
As for the rejection I agree that it is effectively untestable because it requires an anticipated scenario where the rejection might not be consistent but there is no such scenario as rejection conditions are constant in time for the same Document.
to reflect tests change in web-platform-tests/wpt#8416