Closed Bug 1300399 Opened 8 years ago Closed 8 years ago

[tracking] Implement the sessions API

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Manuel.Spam, Assigned: bsilverberg)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, meta, Whiteboard: [design-decision-approved][sessions]triaged)

Attachments

(1 obsolete file)

Maybe it is a bit too early to request new features that aren't covered by the Google Chrome API.

I was searching for a nice, simple, "Restore Tab" button Addon but only found unmaintained Addons which won't survive the "XPCOM to WebExtensions" switchover. But: I also didn't find the right API to do such an Addon myself...

Firefox has an function builtin to restore last closed tabs. This is easily available for XPCOM/XUL based Addons.

It would be nice to have access to this from WebExtensions. Maybe this would be even a good time to expose some more infos. Maybe a list of last closed tabs or at least a boolean to know that there are tabs to restore (to gray out the button).
Summary: Please add simple "tabs.UndoLastClosedTab" feature → Add API to restore closed tabs
Whiteboard: [design-decision-needed][tabs]
Its possible to the onRemoved event and keep track of them. But agreed, if the data is already there, it would be nice to expose it and save that work.
(In reply to Andy McKay [:andym] from comment #1)
> Its possible to the onRemoved event and keep track of them. But agreed, if
> the data is already there, it would be nice to expose it and save that work.

That's not the same thing. The undo closed tab feature restores full session store data, including session history, form data, and so forth. It also removes the restored tabs from the recently closed list.
Rightio. I would recommend moving this straight to [design-decision-approved], unless you have a concern?
Nope, it's just a matter of designing the API. Or it might suffice to just implement https://developer.chrome.com/extensions/sessions
Whiteboard: [design-decision-needed][tabs] → [design-decision-approved][tabs]
I think a better bet is to implement the sessions API. Changing this bug to that.
Summary: Add API to restore closed tabs → Implement the sessions API
Whiteboard: [design-decision-approved][tabs] → [design-decision-approved][sessions]
Priority: -- → P3
Whiteboard: [design-decision-approved][sessions] → [design-decision-approved][sessions]triaged
Assignee: nobody → bob.silverberg
Status: NEW → ASSIGNED
Component: WebExtensions: Untriaged → WebExtensions: General
Comment on attachment 8797758 [details]
Bug 1300399 - Implement the sessions API

This isn't totally ready for review yet. There are a couple of things I need to check.
Attachment #8797758 - Flags: review?(aswan)
Summary: Implement the sessions API → [tracking] Implement the sessions API
Depends on: 1308058
Depends on: 1308059
Depends on: 1308060
Comment on attachment 8797758 [details]
Bug 1300399 - Implement the sessions API

Removing the patch as it will be attached to one of the dependencies.
Attachment #8797758 - Attachment is obsolete: true
Depends on: 1308061
No longer depends on: 1308059
Depends on: 1320306
All dependencies have landed. Marking this as fixed!
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Keywords: dev-doc-needed
I've written some docs for these: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions.

Please let me know if they're OK.
Flags: needinfo?(bob.silverberg)
Thanks Will, it looks good. There were a couple of cosmetic changes that I just took care of myself. The only other thing has to do with the onChanged event.  The doc currently states "Fired when a tab or window is closed." [1], which is true, but it's not the only time that the event is fired. It's actually fired any time the list of closed windows and tabs changes, which could include a tab/window being evicted from the list because the number stored exceeds the maximum. I don't think this is something we necessarily needs to be explicit about in the documentation, but I wanted to explain it and give you an opportunity to decide whether to update the docs or not. 

[1] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions/onChanged
Flags: needinfo?(bob.silverberg)
(In reply to Bob Silverberg [:bsilverberg] from comment #13)
> Thanks Will, it looks good. There were a couple of cosmetic changes that I
> just took care of myself.

Thanks for the review, and also for fixing my typos :).

> The only other thing has to do with the onChanged
> event.  The doc currently states "Fired when a tab or window is closed."
> [1], which is true, but it's not the only time that the event is fired. It's
> actually fired any time the list of closed windows and tabs changes, which
> could include a tab/window being evicted from the list because the number
> stored exceeds the maximum.

I think this is worth mentioning for sure, so I did. The Chrome docs just say it's fired when sessions are changed, which didn't seem very helpful, but closing tabs/windows was the only example I could think of.

Is "the maximum" the same as MAX_SESSION_RESULTS [1]?

Also, if that's the case, then... presumably this would only happen if a tab/window had been closed? Because that's the only way we would hit the maximum? If so, does onChanged fire twice in this scenario, or just once? If once, doesn't it come down to the same thing?

[1] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions/MAX_SESSION_RESULTS?
(In reply to Will Bamberg [:wbamberg] from comment #14)
> (In reply to Bob Silverberg [:bsilverberg] from comment #13)
> 
> > The only other thing has to do with the onChanged
> > event.  The doc currently states "Fired when a tab or window is closed."
> > [1], which is true, but it's not the only time that the event is fired. It's
> > actually fired any time the list of closed windows and tabs changes, which
> > could include a tab/window being evicted from the list because the number
> > stored exceeds the maximum.
> 
> I think this is worth mentioning for sure, so I did. The Chrome docs just
> say it's fired when sessions are changed, which didn't seem very helpful,
> but closing tabs/windows was the only example I could think of.
> 
> Is "the maximum" the same as MAX_SESSION_RESULTS [1]?
>

No, it is not. MAX_SESSION_RESULTS is just used by the API to limit the number of sessions to return from getRecentlyClosed. The maximum I'm referring to here is a Firefox pref, for example `browser.sessionstore.max_windows_undo`.

> Also, if that's the case, then... presumably this would only happen if a
> tab/window had been closed? Because that's the only way we would hit the
> maximum? If so, does onChanged fire twice in this scenario, or just once? If
> once, doesn't it come down to the same thing?
>

In that case yes, the list would only change as a result of a window being closed, and only one notification would fire, so it does amount to the same thing, which is why I felt it might not be worth documenting. There is another case, in which closed sessions may be removed because of their age, but this is an edge case that I don't think we need to document. I think simply saying it fires when the list of closed windows and/or tabs changes is enough.
> I think
> simply saying it fires when the list of closed windows and/or tabs changes
> is enough.

OK, I've done this.
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: