Files
sousa-gecko/testing/web-platform/tests/battery-status/battery-default-permissions-policy.https.sub.html
T
Orko Garai bb28c6fd18 Bug 1989400 [wpt PR 54927] - battery-status: Avoid false positives, a=testonly
Automatic update from web-platform-tests
battery-status: Avoid false positives (#54927)

Some Battery Status API tests that validate that the API is disallowed
by permissions policies are passing in Firefox and Safari even though
the feature is not implemented there.

So assert navigator.battery is implemented first before checking that it
is blocked by the policy or otherwise.

Also, fix a bug in battery-allowed-by-permissions-policy.https.sub.html
which didn't pass the 'battery' feature name when calling
`test_feature_availability()`.

Signed-off-by: Orko Garai <orko@igalia.com>
--

wpt-commits: 29b7de53fcdc6ef0093ab722336d5ca94c9473a8
wpt-pr: 54927
2025-09-24 11:05:29 +00:00

31 lines
1.0 KiB
HTML

<!DOCTYPE html>
<body>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/permissions-policy/resources/permissions-policy.js></script>
<script src="resources/battery-status-helpers.js"></script>
<script>
'use strict';
const same_origin_src = '/permissions-policy/resources/permissions-policy-battery.html';
const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
same_origin_src;
const header = 'Default "battery" permissions policy';
promise_test(
async () => await navigator.getBattery(),
`${header} allows the top-level document.`);
async_test(t => {
test_feature_availability('navigator.getBattery()', t, same_origin_src,
expect_feature_available_default);
}, `${header} allows same-origin iframes.`);
async_test(t => {
assert_implements_battery();
test_feature_availability('navigator.getBattery()', t, cross_origin_src,
expect_feature_unavailable_default);
}, `${header} disallows cross-origin iframes.`);
</script>
</body>