Bug 1620425 [wpt PR 22105] - Added Badging API Web Platform Tests., a=testonly
authorChris Mumford <cmumford@chromium.org>
Tue, 31 Mar 2020 12:24:09 +0000
changeset 521797 5e1a2750b1ba169cbd968bcec9193f644dafaffe
parent 521796 3b42fbbeae0ecc994138ea8b66849042fedbc950
child 521798 ea8ba3f9cf95b9514d6ab02b66b1b3ade6dd1d53
push id37275
push usershindli@mozilla.com
push dateFri, 03 Apr 2020 01:02:14 +0000
treeherdermozilla-central@cc22d5fa870b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1620425, 22105, 1051684, 2088297, 754676
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1620425 [wpt PR 22105] - Added Badging API Web Platform Tests., a=testonly Automatic update from web-platform-tests 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 <sky@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Matt Giuca <mgiuca@chromium.org> Commit-Queue: Chris Mumford <cmumford@google.com> Cr-Commit-Position: refs/heads/master@{#754676} -- wpt-commits: 051ca830ad86d533cb17ad35fe654a7d04d86fb3 wpt-pr: 22105
testing/web-platform/tests/badging/badge-error.https.html
testing/web-platform/tests/badging/badge-success.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/badging/badge-error.https.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/badging/badge-success.https.html
@@ -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>