diff --git a/files/en-us/mozilla/add-ons/webextensions/api/alarms/clearall/index.md b/files/en-us/mozilla/add-ons/webextensions/api/alarms/clearall/index.md index a77db448dd0ae71..0226bff846f6e93 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/alarms/clearall/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/alarms/clearall/index.md @@ -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 @@ -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}} diff --git a/files/en-us/mozilla/firefox/releases/157/index.md b/files/en-us/mozilla/firefox/releases/157/index.md index 417bf2732748db2..eec576356756f9f 100644 --- a/files/en-us/mozilla/firefox/releases/157/index.md +++ b/files/en-us/mozilla/firefox/releases/157/index.md @@ -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.