Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ imported/w3c/web-platform-tests/html/webappapis/timers/negative-settimeout.any.w
imported/w3c/web-platform-tests/html/webappapis/user-prompts/print-during-beforeunload.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/mixed-content/gen/top.http-rp/opt-in/xhr.https.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/notifications/instance.https.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-disabled-by-feature-policy.https.sub.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-feature-policy.https.sub.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-resources.https.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/streams/readable-streams/patched-global.any.html [ DumpJSConsoleLogInStdErr ]
imported/w3c/web-platform-tests/streams/transform-streams/terminate.any.html [ DumpJSConsoleLogInStdErr ]
Expand Down Expand Up @@ -6026,13 +6028,6 @@ imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/js

webkit.org/b/245164 css3/scroll-snap/scroll-snap-drag-scrollbar-thumb-with-relayouts.html [ Failure Pass ]

# Screen Wake Lock tests that are timing out since their import.
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-disabled-by-feature-policy.https.sub.html [ Skip ]
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-enabled-by-feature-policy-attribute-redirect-on-load.https.sub.html [ Skip ]
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-enabled-by-feature-policy-attribute.https.sub.html [ Skip ]
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-enabled-by-feature-policy.https.sub.html [ Skip ]
imported/w3c/web-platform-tests/screen-wake-lock/wakelock-enabled-on-self-origin-by-feature-policy.https.sub.html [ Skip ]

# Disable ShadowRealm (while running to ensure we do not crash)
webkit.org/b/245680 http/tests/misc/iframe-shadow-realm.html [ Skip ]
inspector/shadow-realm-console.html [ Pass Failure ]
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function assert_feature_policy_supported() {
// "/feature-policy/resources/feature-policy-payment.html",
// "/feature-policy/resources/feature-policy-usb.html".
// expect_feature_available: a callback(data, feature_description) to
// verify if a feature is avaiable or unavailable as expected.
// verify if a feature is available or unavailable as expected.
// The file under the path "src" defines what "data" is sent back as a
// pistMessage. Inside the callback, some tests (e.g., EXPECT_EQ,
// postMessage. Inside the callback, some tests (e.g., EXPECT_EQ,
// EXPECT_TRUE, etc) are run accordingly to test a feature's
// availability.
// Example: expect_feature_available_default(data, feature_description).
Expand All @@ -24,8 +24,8 @@ function assert_feature_policy_supported() {
// feature (https://wicg.github.io/feature-policy/#features).
// See examples at:
// https://github.com/WICG/feature-policy/blob/master/features.md
// allow_attribute: Optional argument, only used for testing fullscreen or
// payment: either "allowfullscreen" or "allowpaymentrequest" is passed.
// allow_attribute: Optional argument, only used for testing fullscreen:
// "allowfullscreen"
function test_feature_availability(
feature_description, test, src, expect_feature_available, feature_name,
allow_attribute) {
Expand Down Expand Up @@ -354,13 +354,9 @@ function test_subframe_header_policy(
assert_feature_policy_supported()
frame.src = src + '?pipe=sub|header(Feature-Policy,' + feature + ' '
+ frame_header_policy + ';)';
return new Promise(function(resolve, reject) {
let results = [];
return new Promise(function(resolve) {
window.addEventListener('message', function handler(evt) {
results.push(evt.data);
if (results.length >= 6) {
resolve(results);
}
resolve(evt.data);
});
document.body.appendChild(frame);
}).then(function(results) {
Expand Down Expand Up @@ -453,6 +449,6 @@ function expect_reports(report_count, policy_name, description) {
if (num_received_reports >= report_count) {
t.done();
}
}), {types: ['feature-policy-violation'], buffered: true}).observe();
}), {types: ['permissions-policy-violation'], buffered: true}).observe();
}, description);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FAIL Query "gyroscope" permission promise_test: Unhandled rejection with value:
FAIL Query "magnetometer" permission promise_test: Unhandled rejection with value: object "NotSupportedError: Permissions::query does not support this API"
FAIL Query "midi" permission promise_test: Unhandled rejection with value: object "NotSupportedError: Permissions::query does not support this API"
FAIL Query "nfc" permission promise_test: Unhandled rejection with value: object "NotSupportedError: Permissions::query does not support this API"
FAIL Query "screen-wake-lock" permission promise_test: Unhandled rejection with value: object "TypeError: Type error"
PASS Query "screen-wake-lock" permission
PASS Query "camera" permission
FAIL Query "display-capture" permission promise_test: Unhandled rejection with value: object "NotSupportedError: Permissions::query does not support this API"
PASS Query "microphone" permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ window.test_driver_internal.set_permission = function(permission_params, context
testRunner.setGeolocationPermission(permission_params.state == "granted");
return Promise.resolve();
}
if (window.testRunner && permission_params.descriptor.name == "screen-wake-lock") {
testRunner.setScreenWakeLockPermission(permission_params.state == "granted");
return Promise.resolve();
}
return Promise.reject(new Error("unimplemented"));
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

FAIL idl_test setup promise_test: Unhandled rejection with value: object "Error: unimplemented"
PASS idl_test setup
PASS idl_test validation
PASS Partial interface Navigator: original interface defined
PASS Partial interface Navigator: member names are unique
Expand Down Expand Up @@ -32,12 +32,12 @@ PASS WakeLockSentinel interface: attribute released
PASS WakeLockSentinel interface: attribute type
PASS WakeLockSentinel interface: operation release()
PASS WakeLockSentinel interface: attribute onrelease
FAIL WakeLockSentinel must be primary interface of sentinel assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: sentinel"
FAIL Stringification of sentinel assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: sentinel"
FAIL WakeLockSentinel interface: sentinel must inherit property "released" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: sentinel"
FAIL WakeLockSentinel interface: sentinel must inherit property "type" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: sentinel"
FAIL WakeLockSentinel interface: sentinel must inherit property "release()" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: sentinel"
FAIL WakeLockSentinel interface: sentinel must inherit property "onrelease" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: sentinel"
PASS WakeLockSentinel must be primary interface of sentinel
PASS Stringification of sentinel
PASS WakeLockSentinel interface: sentinel must inherit property "released" with the proper type
PASS WakeLockSentinel interface: sentinel must inherit property "type" with the proper type
PASS WakeLockSentinel interface: sentinel must inherit property "release()" with the proper type
PASS WakeLockSentinel interface: sentinel must inherit property "onrelease" with the proper type
PASS Navigator interface: attribute wakeLock
PASS Navigator interface: navigator must inherit property "wakeLock" with the proper type

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.

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.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script>
"use strict";

const same_origin_src =
"/feature-policy/resources/feature-policy-screen-wakelock.html";
const cross_origin_src =
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;

promise_test(t => {
return promise_rejects_dom(t, "NotAllowedError", navigator.wakeLock.request("screen"));
Expand Down
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

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script>
"use strict";

const relative_path = "/feature-policy/resources/feature-policy-screen-wakelock.html";
const base_src = "/feature-policy/resources/redirect-on-load.html#";
const same_origin_src = base_src + relative_path;
const cross_origin_src =
base_src + "https://{{domains[www]}}:{{ports[https][0]}}" + relative_path;
base_src + get_host_info().HTTPS_REMOTE_ORIGIN + relative_path;

async_test(t => {
test_feature_availability(
Expand Down
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

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script>
"use strict";

const same_origin_src =
"/feature-policy/resources/feature-policy-screen-wakelock.html";
const cross_origin_src =
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;

async_test(t => {
test_feature_availability(
Expand Down
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.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script>
"use strict";

const same_origin_src =
"/feature-policy/resources/feature-policy-screen-wakelock.html";
const cross_origin_src =
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;

promise_test(async t => {
await test_driver.set_permission(
Expand Down
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.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/feature-policy/resources/featurepolicy.js"></script>
<script src="/common/get-host-info.sub.js"></script>

<script>
"use strict";

const same_origin_src =
"/feature-policy/resources/feature-policy-screen-wakelock.html";
const cross_origin_src =
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
get_host_info().HTTPS_REMOTE_ORIGIN + same_origin_src;

promise_test(async t => {
await test_driver.set_permission(
Expand Down
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

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

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

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

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

3 changes: 3 additions & 0 deletions LayoutTests/platform/mac-wk1/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ media/audio-session-category-at-most-recent-playback.html [ Skip ]
imported/w3c/web-platform-tests/clear-site-data [ Skip ]
http/tests/clear-site-data [ Skip ]

# The Screen Wake Lock API is not supportted in WebKit1.
imported/w3c/web-platform-tests/screen-wake-lock [ Skip ]

# Shared workers are only implemented for WebKit2.
http/tests/navigation/page-cache-shared-worker.html [ Skip ]
imported/w3c/web-platform-tests/content-security-policy/connect-src/shared-worker-connect-src-allowed.sub.html [ Skip ]
Expand Down
3 changes: 3 additions & 0 deletions LayoutTests/platform/win/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ http/tests/clear-site-data [ Skip ]
# color-filters are off by default
webkit.org/b/185076 css3/color-filters [ Skip ]

# The Screen Wake Lock API is not supportted in WebKit1.
imported/w3c/web-platform-tests/screen-wake-lock [ Skip ]

# IntersectionObserver is off by default
webkit.org/b/188613 intersection-observer [ Skip ]
webkit.org/b/188613 http/tests/intersection-observer [ Skip ]
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/Modules/permissions/PermissionName.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum class PermissionName : uint8_t {
Midi,
Nfc,
Notifications,
ScreenWakeLock,
SpeakerSelection
};

Expand All @@ -64,6 +65,7 @@ template<> struct EnumTraits<WebCore::PermissionName> {
WebCore::PermissionName::Midi,
WebCore::PermissionName::Nfc,
WebCore::PermissionName::Notifications,
WebCore::PermissionName::ScreenWakeLock,
WebCore::PermissionName::SpeakerSelection
>;
};
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/Modules/permissions/PermissionName.idl
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ enum PermissionName {
"midi",
"nfc",
"notifications",
"screen-wake-lock",
"speaker-selection"
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

namespace WebCore {

NavigatorScreenWakeLock::NavigatorScreenWakeLock(Navigator&)
NavigatorScreenWakeLock::NavigatorScreenWakeLock(Navigator& navigator)
: m_navigator(navigator)
{
}

Expand Down Expand Up @@ -61,7 +62,7 @@ WakeLock& NavigatorScreenWakeLock::wakeLock(Navigator& navigator)
WakeLock& NavigatorScreenWakeLock::wakeLock()
{
if (!m_wakeLock)
m_wakeLock = WakeLock::create();
m_wakeLock = WakeLock::create(downcast<Document>(m_navigator.scriptExecutionContext()));

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

return *m_wakeLock;
}

Expand Down
Loading