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
29 lines
970 B
HTML
29 lines
970 B
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>
|
|
'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 = 'Permissions-Policy header "battery=*"';
|
|
|
|
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, 'battery');
|
|
}, `${header} allows same-origin iframes.`);
|
|
|
|
async_test(t => {
|
|
test_feature_availability('navigator.getBattery()', t, cross_origin_src,
|
|
expect_feature_available_default, 'battery');
|
|
}, `${header} allows cross-origin iframes.`);
|
|
</script>
|
|
</body>
|