Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ sidebar: addonsidebar

Cancels all active alarms.

This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).

## Syntax

```js-nolint
let clearAlarms = browser.alarms.clearAll()
browser.alarms.clearAll()
```

### Parameters
Expand All @@ -22,20 +20,22 @@ None.

### Return value

A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with a boolean. This is `true` if any alarms were cleared, `false` otherwise.
A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with `undefined`.

> [!NOTE]
> Chrome always passes `true` and Safari `undefined`. The return type is subject to change and may always return `undefined` for all browsers in the future. It is best to not rely on the return type.
> Before Firefox 157, the promise was fulfilled with a boolean: `true` if any alarms were cleared and `false` otherwise. Chrome fulfills the promise with `true` and Safari with `undefined`. Don't rely on the fulfillment value. See [w3c/webextensions#1055](https://github.com/w3c/webextensions/issues/1055) for details.

## Examples

Clear all the alarms the extension has scheduled, then log that the alarms are cleared:

```js
function onClearedAll(wasCleared) {
console.log(wasCleared); // true/false
async function clearAllAlarms() {
await browser.alarms.clearAll();
console.log("All alarms cleared");
}

let clearAlarms = browser.alarms.clearAll();
clearAlarms.then(onClearedAll);
clearAllAlarms();
```

{{WebExtExamples}}
Expand Down
2 changes: 2 additions & 0 deletions files/en-us/mozilla/firefox/releases/157/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ No notable changes.

## Changes for add-on developers

- {{WebExtAPIRef("alarms.clearAll()")}} now fulfills its promise with `undefined` instead of a boolean. ([Firefox bug 2067229](https://bugzil.la/2067229))

## Experimental web features

These features are shipping in Firefox 157 but are disabled by default.
Expand Down
Loading