-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathbadge-success.https.html
More file actions
62 lines (57 loc) · 1.9 KB
/
badge-success.https.html
File metadata and controls
62 lines (57 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<title>Badging: Supported values</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// Testing valid input cases
promise_test(async () => {
const numberTestCases = [
{ value: undefined, desc: "undefined" },
{ value: null, desc: "null (coerced to 0)" },
{ value: 1, desc: "integer value of 1" },
{ value: 10.6, desc: "non-whole number" },
{ value: Number.MAX_SAFE_INTEGER, desc: "maximum allowed value" },
{ value: 0, desc: "zero" },
];
for (const { value, desc } of numberTestCases) {
const result = await navigator.setAppBadge(value);
assert_equals(
result,
undefined,
`Resolves successfully when passed ${desc} as input`
);
}
}, "Resolves successfully for number input cases");
promise_test(async () => {
const stringTestCases = [
{ value: "3", desc: "numeric string '3' (coerced to 3)" },
{
value: " 300.000 ",
desc: "numeric string ' 300.000 ' (coerced to 300)",
},
{ value: "", desc: "empty string (coerced to 0)" },
];
for (const { value, desc } of stringTestCases) {
const result = await navigator.setAppBadge(value);
assert_equals(
result,
undefined,
`Resolves successfully when passed ${desc} as input`
);
}
}, "Resolves successfully for string input cases");
promise_test(async () => {
const resultFalse = await navigator.setAppBadge(false);
assert_equals(
resultFalse,
undefined,
"Resolves successfully when passed false as input (coerced to 0)"
);
const resultTrue = await navigator.setAppBadge(true);
assert_equals(
resultTrue,
undefined,
"Resolves successfully when passed true as input (coerced to 1)"
);
}, "Resolves successfully for boolean input cases");
</script>