Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 7 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /badging/badge-error.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Badging: Unsupported values</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async (t) => {
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge(-1),
"Reject with TypeError if the value is negative"
);
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge(Number.MAX_SAFE_INTEGER + 1),
"Reject with TypeError if the value is larger than the maximum safe integer (2^53 - 1)"
);
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge(Infinity),
"Reject with TypeError if the value is positive infinity"
);
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge(-Infinity),
"Reject with TypeError if the value is negative infinity"
);
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge(NaN),
"Reject with TypeError if the value is NaN"
);
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge("Foo"),
'Reject with TypeError if the value cannot be converted to a long: string'
);
await promise_rejects_js(
t,
TypeError,
navigator.setAppBadge({}),
"Reject with TypeError if the value cannot be converted to a long: object"
);
}, "Test various invalid input cases for setAppBadge()");
</script>