browsingData.removeLocalStorage()

Clears any local storage and session storage created by websites and extensions.

You can use the removalOptions parameter, which is a browsingData.RemovalOptions object, to:

  • clear local and session storage objects created after a given time.
  • control whether to clear localStorage and sessionStorage objects created by web pages or web pages extensions.

Syntax

js
let removing = browser.browsingData.removeLocalStorage(
  removalOptions            // RemovalOptions object
)

Parameters

removalOptions

object. A browsingData.RemovalOptions object, which can be used to clear local and session storage objects stored after a given time, and control whether to clear local and session storage objects created by web pages or web pages and extensions.

Return value

A Promise that is fulfilled with no arguments when the removal has finished. If any error occurs, the promise is rejected with an error message.

Examples

Remove all local storage:

js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removeLocalStorage({}).then(onRemoved, onError);

Browser compatibility

Note: This API is based on Chromium's chrome.browsingData API.