Document gBrowser's progress listener infrastructure
Categories
(Firefox :: Tabbed Browser, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox156 | --- | fixed |
People
(Reporter: dao, Assigned: dao)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
browser/components/tabbrowser/docs/ covers what gBrowser is and how the async tab switcher works, but nothing covers the progress listener infrastructure. addProgressListener, addTabsProgressListener and their remove counterparts have no JSDoc either, and there is no general web progress documentation in-tree to defer to. Little of the behavior is guessable from the signatures.
Proposed, a new page under browser/components/tabbrowser/docs/ covering:
- The two listener flavors. Global listeners (
addProgressListener) only receive notifications for the selected browser; tabs listeners (addTabsProgressListener) receive them for every tab, with thebrowseras an extra leading argument. Both take plain objects — dispatch isif (aMethod in p), each call is try/caught so one throwing listener doesn't inhibit the rest, and partial implementations are normal. Global listeners run before tabs listeners. TabProgressListeneras the per-tab translator: it turns raw web progress into tab state (thebusyattribute, progress,gBrowser._isBusy) and records the tab's laststateFlags,status,messageandtotalProgress.- What a tab switch replays.
updateCurrentBrowserre-emitsonLocationChange,onSecurityChangeandonContentBlockingEvent, thenonUpdateCurrentBrowserwith the recorded values, only when the recordedstateFlagsis non-zero, plus a syntheticSTATE_START | STATE_IS_NETWORKor itsSTATE_STOPmirror depending on the new tab'sbusyattribute and_isBusy. - The sharp edges. The
STATE_START/STATE_STOPthatonUpdateCurrentBrowsersynthesizes carries noSTATE_IS_NETWORK, so consumers gated on that flag react to the separate synthetic notification instead; the recorded message is cleared atSTATE_STARTandSTATE_STOP, so a status delivered before a load'sSTATE_STARTis shown but not replayed on a tab switch; the record is written after the listeners run, so a listener reading it sees the previous value; and the initialabout:blankis suppressed via_isForInitialAboutBlank, which substitutesonUpdateCurrentBrowserforonStateChange. - How to wait for progress on a specific tab in a test.
Also add JSDoc to addProgressListener, removeProgressListener, addTabsProgressListener and removeTabsProgressListener, which feeds the eventual js:autoclass API reference.
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Updated•9 days ago
|
| Assignee | ||
Comment 1•9 days ago
|
||
The page told the <xul:tabbrowser> story four times over; it now says once that
the name survives in older code, and describes what gBrowser is today.
| Assignee | ||
Comment 2•9 days ago
|
||
The replay on a tab switch reaches global listeners only, and a listener that
implements onRefreshAttempted without returning true cancels the refresh --
neither is guessable, and both are in the page.
Comment 4•7 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/59ca3cf789cb
https://hg.mozilla.org/mozilla-central/rev/473b8a090d9b
Description
•