Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overview of Persistent States of Various APIs #424

Closed
hanguokai opened this issue Jul 17, 2023 · 5 comments
Closed

Overview of Persistent States of Various APIs #424

hanguokai opened this issue Jul 17, 2023 · 5 comments
Labels
discussion Needs further discussion documentation Improvements or additions to documentation inconsistency Inconsistent behavior across browsers spec clarification Needs clarification when specified

Comments

@hanguokai
Copy link
Member

hanguokai commented Jul 17, 2023

There are many extension APIs that can affect some kind of state, and the persistence of these states is often discussed in various issues in WECG, some with clear definitions and some without. Here is a summary of these states and their persistence.

The purpose of this issue is to make a summary.

Let's make a few simple definitions:

  • A: session only: memory state, they are cleared when meet below situations
  • B: across browser sessions persistent: quit and restart the browser, upgrade the browser
  • C: extension upgrade persistent: including reload the extension
  • D: extension disable and re-enable persistent
API Chrome
action.set* (e.g. setBadgeText) A
alarms B + C + D (except a bug) for now
contextMenus B + D
commands B + C + D (can't set by api)
downloads.setUiOptions() A
declarativeNetRequest static rules B + D
declarativeNetRequest.updateDynamicRules() B + C + D
declarativeNetRequest.updateSessionRules() A
power.requestKeepAwake() A
storage.session A
storage.local B + C + D
static content scripts B + D
scripting.registerContentScripts() B + D: if persistAcrossSessions is true
A: if persistAcrossSessions is false
proxy.settings.set() ?
sidePanel.setPanelBehavior() B + C + D

* This table may not be exhaustive, nor may it be adequately tested. Additions and corrections are welcome, especially for other browsers!

If you want to keep a state persistent across B, C or D, but the default behavior doesn't meet your needs, you need to maintain the state by yourself with runtime.onStartup(), runtime.onInstalled() and runtime.onEnabled()

@hanguokai hanguokai added documentation Improvements or additions to documentation inconsistency Inconsistent behavior across browsers spec clarification Needs clarification when specified discussion Needs further discussion labels Jul 17, 2023
@erosman
Copy link

erosman commented Jul 18, 2023

It is worth noting that some WebExtension APIs access and alter the browser settings. These APIs are simply interfaces to set browser settings and therefore have a more persistent nature than other WebExtension APIs.

I think for better clarity, it is worth separating the aforementioned from the others. For example:

@bershanskiy
Copy link
Member

This is a good table to have. This table is missing a few APIs like permissions

@xeenon
Copy link
Collaborator

xeenon commented Jul 20, 2023

While storage.session data is not persistent, storage.session.setAccessLevel() is persistent in Chrome.

@hanguokai
Copy link
Member Author

We discuss this issue at today's meeting. Next step, I'll submit a document (PR) and hand it over to the community for maintenance.

At present, this kind of problem depends on browsers' implementation. The purpose of this document is to provide a high-level perspective on all such issues. The goal is to expect similar issues to be designed and implemented in a consistent manner on the platform, as well as consistent behavior among different browsers.

hanguokai added a commit to hanguokai/webextensions that referenced this issue Aug 3, 2023
@hanguokai
Copy link
Member Author

Close this issue. Now you can see this doc as a file in this repo. Welcome to update it via PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Needs further discussion documentation Improvements or additions to documentation inconsistency Inconsistent behavior across browsers spec clarification Needs clarification when specified
Projects
None yet
Development

No branches or pull requests

6 participants
@xeenon @hanguokai @dotproto @erosman @bershanskiy and others