Document new worker event 'detach'

RESOLVED FIXED in 1.0

Status

Add-on SDK
Documentation
P2
normal
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: ochameau, Assigned: wbamberg)

Tracking

unspecified

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [cherry-pick-1.0b5])

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

7 years ago
Created attachment 526963 [details] [diff] [review]
Preliminary doc

A new `detach` event is dispatched on worker object when target document unload. (tab close, window close or document reload)

I sent a first patch that add some lines in worker.md, but I remember that there is others locations to add such documentation ?
(Reporter)

Comment 1

7 years ago
Following bug 607601, we need to document: 
1/ behavior of all Worker objects:
They are destroyed on document unload, it's obvious for page-mod, but it can be more complicated in tab.attach. (if we call attach before the tab is ready, when it loads an about:blank document before the real page)

2/ And they dispatch a new event called `detach` when they are manually or automatically destroyed.
(Assignee)

Updated

7 years ago
Assignee: nobody → wbamberg
Priority: -- → P2
Target Milestone: --- → 1.0
(Reporter)

Comment 2

7 years ago
Created attachment 528586 [details] [diff] [review]
Document `detach` event and worker.destroy

Here is a first step to provide document in interfaces.

Then we will need to add some notes in:
- content script guide to speak about 'detach' event
http://127.0.0.1:8888/dev-guide/addon-development/web-content.html
- page-mod doc to tell that workers are destroyed on tab close or the document is unloaded from the tab [to make it simple, when the location change, but in reality, it's only when document goes out from the bfcache]
http://127.0.0.1:8888/packages/addon-kit/docs/page-mod.html
Attachment #526963 - Attachment is obsolete: true
Attachment #528586 - Flags: review?
Attachment #528586 - Flags: review? → review?(wbamberg)
(Assignee)

Comment 3

7 years ago
Created attachment 529757 [details] [diff] [review]
Document worker's detach event in worker and page-mod

> Then we will need to add some notes in:
> - content script guide to speak about 'detach' event
> http://127.0.0.1:8888/dev-guide/addon-development/web-content.html

Hm. I didn't do this because we don't really talk explicitly about worker in that guide, because for the most part worker's APIs are exposed through higher-level APIs.

Apart from listening to page-mod's detach event, are there other obvious applications for detach that need to be captured here?
Attachment #528586 - Attachment is obsolete: true
Attachment #528586 - Flags: review?(wbamberg)
Attachment #529757 - Flags: review?(myk)
Attachment #529757 - Flags: feedback?(poirot.alex)
Comment on attachment 529757 [details] [diff] [review]
Document worker's detach event in worker and page-mod

r=myk, a=myk for checkin during freeze
Attachment #529757 - Flags: review?(myk) → review+
Whiteboard: [cherry-pick-wanted]
Keywords: checkin-needed
(Assignee)

Comment 5

7 years ago
Fixed by: https://github.com/mozilla/addon-sdk/commit/3f41c8285b25d3db9b5a0e109c3e5da860c41810
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
Keywords: checkin-needed
Whiteboard: [cherry-pick-wanted] → [cherry-pick-1.0b5]
(Reporter)

Comment 7

7 years ago
(In reply to comment #3)
> Hm. I didn't do this because we don't really talk explicitly about worker in
> that guide, because for the most part worker's APIs are exposed through
> higher-level APIs.
> 
> Apart from listening to page-mod's detach event, are there other obvious
> applications for detach that need to be captured here?

The only common use case I'm thinking about is `tab.attach` in order to detect location change.
(Reporter)

Comment 8

6 years ago
Comment on attachment 529757 [details] [diff] [review]
Document worker's detach event in worker and page-mod

I forgot to change the flag long time ago.
Attachment #529757 - Flags: feedback?(poirot.alex) → feedback+
You need to log in before you can comment on or make changes to this bug.