Convert tabgroup.js and tabsplitview.js to modules that export their class
Categories
(Firefox :: Tabbed Browser, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox157 | --- | fixed |
People
(Reporter: dao, Assigned: dao)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
browser/components/tabbrowser/content/tabgroup.js and tabsplitview.js wrap their class in a block in a file loaded through Services.scriptloader.loadSubScript, so nothing can import the class. TypeScript cannot see MozTabbrowserTabGroup or MozTabSplitViewWrapper at all, which is why bug 2065814 describes them with hand-written interfaces. Nothing checks an interface against the class it describes, so it can drift, or simply be wrong, with no signal.
Convert both to modules that export their class and register it the way toolkit/content/widgets/browser-custom-element.mjs is registered from toolkit/content/customElements.js:
customElements.setElementCreationCallback("tab-group", () =>
ChromeUtils.importESModule(url, { global: "current" })
);
Each interface then becomes a one-line reference to the real class.
These two are the cheap pair among the four element scripts:
- They extend
MozXULElement, whichtools/@types/lib.gecko.augmentations.d.tsalready declares.tab.jsandtabs.jsextendMozElements.MozTabandMozElements.TabsBase, defined intoolkit/content/widgets/tabbox.jsand declared nowhere; an undeclared base makes every inherited DOM member vanish, so those two need their bases declared first and are out of scope here. - Nothing outside their own file names either class.
global: "current"puts the module in the window's global, so the baregBrowserreads keep resolving unchanged. Ambient declarations for the window globals are only needed to check these files, which is a separate question and not part of this.
One interaction to handle: bug 2065813 declares pinned, splitview and group as never set on these two interfaces, which is what lets Tabbrowser.sys.mjs read them off a tab-or-group union. Pointing an alias at the real class drops those declarations, so the aliases have to become an intersection of the class with them or fifteen union reads come back.
Updated•20 days ago
|
| Assignee | ||
Comment 1•10 days ago
|
||
A pure move, ahead of the commit that makes them modules, so the rename stays visible to blame. The subscript loader does not read the extension, and dropping "use strict" only anticipates eslint parsing the file as a module.
Updated•10 days ago
|
| Assignee | ||
Comment 2•10 days ago
|
||
Dropping the block the subscript loader needed reindents both files, so git diff -w is the change and nothing in it is more than mechanical. global: "current" puts each module in the window's global, so the bare gBrowser and SessionStore references keep resolving.
| Assignee | ||
Comment 3•10 days ago
|
||
Nothing checked the stand-in interfaces against the classes, so what only the interfaces said now has to be said in the classes.
| Assignee | ||
Comment 5•5 days ago
|
||
Comment 6•5 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/ea1611c010dd
https://hg.mozilla.org/mozilla-central/rev/dcb5eb5efca7
https://hg.mozilla.org/mozilla-central/rev/ed39ec09aaed
Updated•3 days ago
|
Updated•7 hours ago
|
Description
•