[go: up one dir, main page]

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

WakeLockRequest is independent rather than WakeLock #8416

Merged
merged 3 commits into from
Dec 1, 2017

Conversation

Honry
Copy link
Contributor
@Honry Honry commented Nov 24, 2017

@ghost
Copy link
ghost commented Nov 24, 2017

Build PASSED

Started: 2017-11-28 01:42:32
Finished: 2017-11-28 01:46:39

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;
Copy link
Contributor

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.

Copy link
Contributor
@marcoscaceres marcoscaceres left a 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");


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove this line.

@marcoscaceres
Copy link
Contributor

If you can't come up with anything better for wakelock-state-is-global.https.html, that's ok... let me know.

@Honry
Copy link
Contributor Author
Honry commented Nov 28, 2017

@marcoscaceres, thanks for your review, I'm afraid I have no much better idea, @andrey-logvinov, do you have any good opinion?

Copy link
Contributor
@marcoscaceres marcoscaceres left a 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.

@Honry
Copy link
Contributor Author
Honry commented Dec 1, 2017

@marcoscaceres, thanks, I hope so. :)

@marcoscaceres
Copy link
Contributor

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

@marcoscaceres marcoscaceres merged commit 0b5de1b into web-platform-tests:master Dec 1, 2017
Honry added a commit to Honry/wake-lock that referenced this pull request Dec 1, 2017
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>navigator.getWakeLock() for the same Document always return same WakeLock promise</title>
Copy link
@andrey-logvinov andrey-logvinov Dec 1, 2017

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.

Copy link
Contributor Author

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.

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.

marcoscaceres pushed a commit to w3c/screen-wake-lock that referenced this pull request Dec 4, 2017
@Honry Honry deleted the wakelock-test-4 branch March 4, 2019 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants