forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Badging API Web Platform Tests.
The [Badging API](https://wicg.github.io/badging/) is a new API allowing the setting of application/document badges. This change converts the Badging API web tests into Web Platform Tests. This change adds a no-op MockBadgeService to the content_shell. This is necessary because the RenderProcessHostImpl will terminate the render process if unknown Mojo messages are received. Bug: 1051684 Change-Id: I61e29b8f197a754fea489ebb2d0dcd41484f6cf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088297 Reviewed-by: Scott Violet <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Matt Giuca <[email protected]> Commit-Queue: Chris Mumford <[email protected]> Cr-Commit-Position: refs/heads/master@{#754676}
- Loading branch information
1 parent
79a262e
commit 051ca83
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<title>Badging: Unsupported values</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge(-1)); | ||
}, "Negative value not allowed"); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge( | ||
Number.MAX_SAFE_INTEGER + 1)); | ||
}, "Value too large (2^53)"); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge(Infinity)); | ||
}, "Positive infinity"); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge(-Infinity)); | ||
}, "Negative infinity"); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge(NaN)); | ||
}, "NaN"); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge("Foo")); | ||
}, 'Cannot convert to long: "Foo"'); | ||
|
||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, navigator.setAppBadge({})); | ||
}, "Cannot convert to long: object"); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<title>Badging: Supported values</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(); | ||
assert_equals(result, undefined); | ||
}, "No parameter should show a flag with no numeric value."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(undefined); | ||
assert_equals(result, undefined); | ||
}, "undefined should show a flag with no numeric value."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(1); | ||
assert_equals(result, undefined); | ||
}, "An integer value of 3 should show the badge vale 3."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(10.6); | ||
assert_equals(result, undefined); | ||
}, "Non-whole number should round down to nearest integer (10)."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(Number.MAX_SAFE_INTEGER); | ||
assert_equals(result, undefined); | ||
}, "Maximum allowed value (2^53 - 1) should display saturated value: '99+'."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(0); | ||
assert_equals(result, undefined); | ||
}, "Set to zero should clear the badge."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.clearAppBadge(); | ||
assert_equals(result, undefined); | ||
}, "Should clear the badge."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(null); | ||
assert_equals(result, undefined); | ||
}, "Setting to null should clear the badge."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(false); | ||
assert_equals(result, undefined); | ||
}, "Setting to false should clear the badge."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge(true); | ||
assert_equals(result, undefined); | ||
}, "Setting to true should display a value of 1."); | ||
|
||
promise_test(async t => { | ||
const result = await navigator.setAppBadge("3"); | ||
assert_equals(result, undefined); | ||
}, "Setting to the string '3' should display a value of 3."); | ||
|
||
</script> |