-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added a new example, session-state #300
Conversation
@bobsilverberg , since you reviewed the code for these APIs, I wondered if you would mind reviewing this example? |
session-state/README.md
Outdated
|
||
## What it shows | ||
|
||
This example demonstrates how you can use the [sessions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions) API to store and retrieve arbitrary state that you want to associate with a tab or window. Then if the tab/window is closed and subsequently restored, you can retrieve the state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe add some notes about how to do a restore in firefox, as mentioned on IRC so its clear the difference between that and just opening example.com again :)
session-state/background.js
Outdated
* Add a context menu item to borderify the current tab. | ||
*/ | ||
browser.menus.create({ | ||
id: "borderify", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit, but if someone had this and borderify installed this might be confusing
session-state/background.js
Outdated
} | ||
}); | ||
}); | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just remove this?
It looks like a decent example to me, @wbamberg. Thanks for creating it. |
This adds an example of using
sessions.setTabValue
andsessions.getTabValue
to store and retrieve state that the extension wants to associate with a tab. This means the extension can restore this state if the user closes and then restores the tab.I'd like feedback on whether this is a good example of how to use the API, as well as whether the code seems to be correct. I'm not very keen on the onCreated->onUpdated stuff I do here, but it seems that onCreated is too early to call insertCSS. Of course there are alternative ways we could illustrate the concept without needing insertCSS, but they bring they own complexities too. But I'd be happy to hear suggestions for simplifying the example.