Skip to content

Commit

Permalink
storage.session quota enforcement (#35629)
Browse files Browse the repository at this point in the history
* storage.session quota enforcement release note

* Added bug ref

* 134 release bug link

Co-authored-by: Rob Wu <[email protected]>

* Additional features from the bug fix

* Updates from feedback

* Clarification

* Apply suggestions from review

Co-authored-by: Rob Wu <[email protected]>

* getBytesInUse support details update

---------

Co-authored-by: Rob Wu <[email protected]>
  • Loading branch information
rebloor and Rob--W authored Oct 1, 2024
1 parent f75b2c8 commit dd98fd4
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ The amount of data that an extension can store in the session storage area is li

When the browser stops, all session storage is cleared. When the extension is uninstalled, its associated session storage is cleared.

## Properties

- {{WebExtAPIRef("storage.session.QUOTA_BYTES")}}
- : The maximum amount of data (in bytes) that can be stored in session storage.

## Methods

The `session` object implements the methods defined on the {{WebExtAPIRef("storage.StorageArea")}} type:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: storage.session.QUOTA_BYTES
slug: Mozilla/Add-ons/WebExtensions/API/storage/session/QUOTA_BYTES
page-type: webextension-api-property
browser-compat: webextensions.api.storage.session.QUOTA_BYTES
---

{{AddonSidebar}}

The maximum amount of data (in bytes) that can be stored in session storage. Use {{WebExtAPIRef("storage.StorageArea.getBytesInUse()", "storage.session.getBytesInUse()")}} to determine the amount of stored data.

Its value is `10485760`.

{{WebExtExamples("h2")}}

## Browser compatibility

{{Compat}}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/Java
let clearing = browser.storage.<storageType>.clear()
```

`<storageType>` is one of the writable storage types — {{WebExtAPIRef("storage.local")}}, {{WebExtAPIRef("storage.session")}}, or {{WebExtAPIRef("storage.sync")}}
Where `<storageType>` is one of the writable storage types — {{WebExtAPIRef("storage.local")}}, {{WebExtAPIRef("storage.session")}}, or {{WebExtAPIRef("storage.sync")}}

### Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let results = browser.storage.<storageType>.get(
)
```

`<storageType>` will be one of the writable storage types — {{WebExtAPIRef("storage.sync", "sync")}}, {{WebExtAPIRef("storage.local", "local")}}, or {{WebExtAPIRef("storage.managed", "managed")}}.
Where `<storageType>` is one of the storage types — {{WebExtAPIRef("storage.sync", "sync")}}, {{WebExtAPIRef("storage.local", "local")}}, {{WebExtAPIRef("storage.session", "session")}}, or {{WebExtAPIRef("storage.managed", "managed")}}.

### Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ browser-compat: webextensions.api.storage.StorageArea.getBytesInUse

{{AddonSidebar}}

Gets the amount of storage space, in bytes, used one or more items being stored in the storage area.
Gets the amount of storage space, in bytes, used by one or more items stored in the storage area.

This function only exists in browser.storage.sync
It does not exist in browser.storage.local
See <https://bugzil.la/1385832>
> [!NOTE]
> In Firefox this method:
>
> - is supported in {{WebExtAPIRef("storage.sync")}}.
> - is supported in {{WebExtAPIRef("storage.session")}} from Firefox 131.
> - isn't supported in {{WebExtAPIRef("storage.local")}}, see [Firefox bug 1385832](https://bugzil.la/1385832).
> - isn't provided in {{WebExtAPIRef("storage.managed")}}.
This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
This is an asynchronous method that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).

## Syntax

Expand All @@ -23,16 +27,18 @@ let gettingSpace = browser.storage.<storageType>.getBytesInUse(
)
```

`<storageType>` can only be {{WebExtAPIRef("storage.sync")}}, not {{WebExtAPIRef("storage.local")}} because of [this bug](https://bugzil.la/1385832).
Where `<storageType>` is one of the storage types — {{WebExtAPIRef("storage.sync", "sync")}}, {{WebExtAPIRef("storage.local", "local")}}, {{WebExtAPIRef("storage.session", "session")}}, or {{WebExtAPIRef("storage.managed", "managed")}}.

In Firefox, `<storageType>` can't be {{WebExtAPIRef("storage.local")}}, because of [bug 1385832](https://bugzil.la/1385832).

### Parameters

- `keys`
- : A key (string) or keys (an array of strings) to identify the item(s) whose storage space you want to retrieve. If an empty array is passed in, 0 will be returned. If you pass `null` or `undefined` here, the function will return the space used by the entire storage area.
- : A key (string) or keys (an array of strings) to identify the items whose storage space you want to retrieve. If an empty array is passed in, 0 is returned. If you pass `null` or `undefined`, the function returns the space used by the entire storage area.

### Return value

A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that will be fulfilled with an integer, `bytesUsed`, representing the storage space used by the objects that were specified in `keys`. If the operation failed, the promise will be rejected with an error message.
A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that is fulfilled with an integer, `bytesUsed`, representing the storage space used by the objects specified in `keys`. If the operation fails, the promise is rejected with an error message.

## Browser compatibility

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let removingItem = browser.storage.<storageType>.remove(
)
```

`<storageType>` is one of the writable storage types — {{WebExtAPIRef("storage.local")}}, {{WebExtAPIRef("storage.session")}}, or {{WebExtAPIRef("storage.sync")}}.
Where `<storageType>` is one of the writable storage types — {{WebExtAPIRef("storage.local")}}, {{WebExtAPIRef("storage.session")}}, or {{WebExtAPIRef("storage.sync")}}.

### Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let settingItem = browser.storage.<storageType>.set(
)
```

`<storageType>` is one of the writable storage types — {{WebExtAPIRef("storage.local")}}, {{WebExtAPIRef("storage.session")}}, or {{WebExtAPIRef("storage.sync")}}.
Where `<storageType>` is one of the writable storage types — {{WebExtAPIRef("storage.local")}}, {{WebExtAPIRef("storage.session")}}, or {{WebExtAPIRef("storage.sync")}}.

### Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ await browser.storage.<storageType>.setAccessLevel(
)
```

`<storageType>` can be the {{WebExtAPIRef("storage.session")}} storage type.
Where `<storageType>` is the {{WebExtAPIRef("storage.session")}} storage type.

### Parameters

Expand Down
6 changes: 4 additions & 2 deletions files/en-us/mozilla/firefox/releases/131/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ This article provides information about the changes in Firefox 131 that affect d

## Changes for add-on developers

- {{WebExtAPIRef("tabs.onUpdated")}} is now triggered when `openerTabId` is changed through `tabs.update()`. ([Firefox bug 1409262](https://bugzil.la/1409262)).
- {{WebExtAPIRef("tabs.update")}} now accepts `openerTabId` set to `-1` to clear `openerTabId`. ([Firefox bug 1409262](https://bugzil.la/1409262)).
- The 10 MB quota for data stored by the {{WebExtAPIRef("storage.session")}} API is now enforced in Firefox Nightly 131. Previously, Firefox didn't implement this quota. This enforcement rolls out to release versions of Firefox from version 134 ([Firefox bug 1915688](https://bugzil.la/1915688)). This enables extensions that rely on the previous behavior to correct any issues. ([Firefox bug 1908925](https://bugzil.la/1908925))
- {{WebExtAPIRef("storage.session")}} now supports the {{WebExtAPIRef("storage.StorageArea.getBytesInUse()")}} API and the {{WebExtAPIRef("storage.session.QUOTA_BYTES")}} property. ([Firefox bug 1908925](https://bugzil.la/1908925))
- {{WebExtAPIRef("tabs.onUpdated")}} is now triggered when `openerTabId` is changed through `tabs.update()` ([Firefox bug 1409262](https://bugzil.la/1409262)).
- {{WebExtAPIRef("tabs.update")}} now accepts `openerTabId` set to `-1` to clear `openerTabId` ([Firefox bug 1409262](https://bugzil.la/1409262)).

## Experimental web features

Expand Down

0 comments on commit dd98fd4

Please sign in to comment.