Skip to content

Commit 7fa3d03

Browse files
authored
Fix Messaging test that fails in Firefox (#2883)
1 parent 541dae2 commit 7fa3d03

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/messaging/src/controllers/sw-controller.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -277,6 +277,11 @@ describe('SwController', () => {
277277
});
278278

279279
it('warns if there are more action buttons than the browser limit', async () => {
280+
// This doesn't exist on Firefox:
281+
// https://developer.mozilla.org/en-US/docs/Web/API/notification/maxActions
282+
if (!Notification.maxActions) {
283+
return;
284+
}
280285
stub(Notification, 'maxActions').value(1);
281286

282287
const warnStub = stub(console, 'warn');

packages/messaging/src/controllers/sw-controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -339,6 +339,8 @@ function showNotification(details: NotificationDetails): Promise<void> {
339339
const title = details.title ?? '';
340340

341341
const { actions } = details;
342+
// Note: Firefox does not support the maxActions property.
343+
// https://developer.mozilla.org/en-US/docs/Web/API/notification/maxActions
342344
const { maxActions } = Notification;
343345
if (actions && maxActions && actions.length > maxActions) {
344346
console.warn(

0 commit comments

Comments
 (0)