-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[WK2] Add initial implementation the Screen Wake Lock API behind an experimental flag #4733
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
Merged
webkit-commit-queue
merged 1 commit into
WebKit:main
from
cdumez:screen_wake_lock_implementation
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...orted/w3c/web-platform-tests/feature-policy/resources/feature-policy-screen-wakelock.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <script src="/resources/testdriver.js"></script> | ||
| <script src="/resources/testdriver-vendor.js"></script> | ||
| <script> | ||
| "use strict"; | ||
|
|
||
| Promise.resolve().then(async () => { | ||
| try { | ||
| await test_driver.set_permission( | ||
| { name: 'screen-wake-lock' }, 'granted', false); | ||
|
|
||
| const wakeLock = await navigator.wakeLock.request("screen"); | ||
| await wakeLock.release(); | ||
| window.parent.postMessage({ enabled: true }, "*"); | ||
| } catch (e) { | ||
| window.parent.postMessage({ enabled: false }, "*"); | ||
| } | ||
| }); | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...3c/web-platform-tests/screen-wake-lock/wakelock-active-document.https.window-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
|
|
||
| FAIL navigator.wakeLock.request() aborts if the document is not active. promise_rejects_dom: Inactive document, so must throw NotAllowedError function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException NotAllowedError: property "code" is equal to 9, expected 0 | ||
| FAIL navigator.wakeLock.request() aborts if the document is active, but not fully active. promise_rejects_dom: Active, but not fully active, so must throw NotAllowedError function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException NotAllowedError: property "code" is equal to 9, expected 0 | ||
| PASS navigator.wakeLock.request() aborts if the document is not active. | ||
| PASS navigator.wakeLock.request() aborts if the document is active, but not fully active. | ||
|
|
9 changes: 3 additions & 6 deletions
9
...latform-tests/screen-wake-lock/wakelock-disabled-by-feature-policy.https.sub-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,6 @@ | ||
| Blocked access to external URL https://www.localhost:9443/feature-policy/resources/feature-policy-screen-wakelock.html | ||
|
|
||
|
|
||
| Harness Error (TIMEOUT), message = null | ||
|
|
||
| FAIL Feature-Policy header {"screen-wake-lock" : []} disallows the top-level document. promise_rejects_dom: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException NotAllowedError: property "code" is equal to 9, expected 0 | ||
| TIMEOUT Feature-Policy header {"screen-wake-lock" : []} disallows same-origin iframes. Test timed out | ||
| TIMEOUT Feature-Policy header {"screen-wake-lock" : []} disallows cross-origin iframes. Test timed out | ||
| PASS Feature-Policy header {"screen-wake-lock" : []} disallows the top-level document. | ||
| FAIL Feature-Policy header {"screen-wake-lock" : []} disallows same-origin iframes. assert_false: navigator.wakeLock.request("screen") expected false got true | ||
| PASS Feature-Policy header {"screen-wake-lock" : []} disallows cross-origin iframes. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
...lock/wakelock-enabled-by-feature-policy-attribute-redirect-on-load.https.sub-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,5 @@ | ||
| Blocked access to external URL https://www.localhost:9443/feature-policy/resources/feature-policy-screen-wakelock.html | ||
|
|
||
|
|
||
| Harness Error (TIMEOUT), message = null | ||
|
|
||
| TIMEOUT Feature-Policy allow="screen-wake-lock" allows same-origin relocation Test timed out | ||
| TIMEOUT Feature-Policy allow="screen-wake-lock" disallows cross-origin relocation Test timed out | ||
| PASS Feature-Policy allow="screen-wake-lock" allows same-origin relocation | ||
| FAIL Feature-Policy allow="screen-wake-lock" disallows cross-origin relocation assert_false: navigator.wakeLock.request("screen") expected false got true | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
...ests/screen-wake-lock/wakelock-enabled-by-feature-policy-attribute.https.sub-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| Blocked access to external URL https://www.localhost:9443/feature-policy/resources/feature-policy-screen-wakelock.html | ||
|
|
||
|
|
||
| Harness Error (TIMEOUT), message = null | ||
|
|
||
| TIMEOUT Feature policy "screen-wake-lock" can be enabled in same-origin iframe using allow="screen-wake-lock" attribute Test timed out | ||
| TIMEOUT Feature policy "screen-wake-lock" can be enabled in cross-origin iframe using allow="screen-wake-lock" attribute Test timed out | ||
| PASS Feature policy "screen-wake-lock" can be enabled in same-origin iframe using allow="screen-wake-lock" attribute | ||
| PASS Feature policy "screen-wake-lock" can be enabled in cross-origin iframe using allow="screen-wake-lock" attribute | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
...platform-tests/screen-wake-lock/wakelock-enabled-by-feature-policy.https.sub-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,5 @@ | ||
| Blocked access to external URL https://www.localhost:9443/feature-policy/resources/feature-policy-screen-wakelock.html | ||
|
|
||
|
|
||
| Harness Error (TIMEOUT), message = null | ||
|
|
||
| FAIL Feature-Policy header {"screen-wake-lock" : ["*"]} allows the top-level document. promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| TIMEOUT Feature-Policy header {"screen-wake-lock" : ["*"]} allows same-origin iframes. Test timed out | ||
| TIMEOUT Feature-Policy header {"screen-wake-lock" : ["*"]} allows cross-origin iframes. Test timed out | ||
| PASS Feature-Policy header {"screen-wake-lock" : ["*"]} allows the top-level document. | ||
| PASS Feature-Policy header {"screen-wake-lock" : ["*"]} allows same-origin iframes. | ||
| PASS Feature-Policy header {"screen-wake-lock" : ["*"]} allows cross-origin iframes. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
...screen-wake-lock/wakelock-enabled-on-self-origin-by-feature-policy.https.sub-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,5 @@ | ||
| Blocked access to external URL https://www.localhost:9443/feature-policy/resources/feature-policy-screen-wakelock.html | ||
|
|
||
|
|
||
| Harness Error (TIMEOUT), message = null | ||
|
|
||
| FAIL Feature-Policy header screen-wake-lock "self" allows the top-level document. promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| TIMEOUT Feature-Policy header screen-wake-lock "self" allows same-origin iframes. Test timed out | ||
| TIMEOUT Feature-Policy header screen-wake-lock "self" disallows cross-origin iframes. Test timed out | ||
| PASS Feature-Policy header screen-wake-lock "self" allows the top-level document. | ||
| PASS Feature-Policy header screen-wake-lock "self" allows same-origin iframes. | ||
| PASS Feature-Policy header screen-wake-lock "self" disallows cross-origin iframes. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ts/imported/w3c/web-platform-tests/screen-wake-lock/wakelock-onrelease.https-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
|
|
||
| FAIL Test onreleased event's basic properties promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| FAIL Ensure onreleased is called before WakeLockSentinel.release() resolves promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| PASS Test onreleased event's basic properties | ||
| PASS Ensure onreleased is called before WakeLockSentinel.release() resolves | ||
|
|
2 changes: 1 addition & 1 deletion
2
...sts/imported/w3c/web-platform-tests/screen-wake-lock/wakelock-released.https-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
|
|
||
| FAIL The released attribute inside an event handler promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| PASS The released attribute inside an event handler | ||
|
|
2 changes: 1 addition & 1 deletion
2
...ported/w3c/web-platform-tests/screen-wake-lock/wakelock-request-denied.https-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
|
|
||
| FAIL Denied requests should abort with NotAllowedError promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| PASS Denied requests should abort with NotAllowedError | ||
|
|
2 changes: 1 addition & 1 deletion
2
.../imported/w3c/web-platform-tests/screen-wake-lock/wakelock-type.https.window-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
|
|
||
| FAIL 'type' parameter in WakeLock.request() defaults to 'screen' promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| PASS 'type' parameter in WakeLock.request() defaults to 'screen' | ||
| PASS 'TypeError' is thrown when set an invalid wake lock type | ||
|
|
2 changes: 1 addition & 1 deletion
2
...d/w3c/web-platform-tests/screen-wake-lock/wakelockpermissiondescriptor.https-expected.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
|
|
||
| FAIL PermissionDescriptor with name='screen-wake-lock' works promise_test: Unhandled rejection with value: object "Error: unimplemented" | ||
| PASS PermissionDescriptor with name='screen-wake-lock' works | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,5 +39,6 @@ enum PermissionName { | |
| "midi", | ||
| "nfc", | ||
| "notifications", | ||
| "screen-wake-lock", | ||
| "speaker-selection" | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need to downcast this here? It's just passed to the ContextDestructionObserver constructor.
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 am purposefully using tight typing (Document instead of ScriptExecutionContext) to make it clear that WakeLock is only exposed to Window contexts and not workers.
I am not trying to future proof it to make it work with workers because I don't know that there is such plan. In particular, the spec doesn't currently expose this to workers. Also, if somebody were to add support for workers, there would likely be a lot more work involved than just changing the type here.