Closed Bug 2066073 Opened 21 days ago Closed 5 days ago

Convert tabgroup.js and tabsplitview.js to modules that export their class

Categories

(Firefox :: Tabbed Browser, task, P3)

task

Tracking

()

RESOLVED FIXED
157 Branch
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, which tools/@types/lib.gecko.augmentations.d.ts already declares. tab.js and tabs.js extend MozElements.MozTab and MozElements.TabsBase, defined in toolkit/content/widgets/tabbox.js and 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 bare gBrowser reads 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.

Severity: -- → S3
Priority: -- → P3

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.

Assignee: nobody → dao+bmo
Status: NEW → ASSIGNED

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.

Nothing checked the stand-in interfaces against the classes, so what only the interfaces said now has to be said in the classes.

Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/04c45753bee1 https://hg.mozilla.org/integration/autoland/rev/ea1611c010dd Rename the tab group and split view element scripts to .mjs. r=tabbrowser-reviewers,jswinarton https://github.com/mozilla-firefox/firefox/commit/60ad9d1eb17a https://hg.mozilla.org/integration/autoland/rev/dcb5eb5efca7 Turn the tab group and split view elements into modules. r=tabbrowser-reviewers,sthompson https://github.com/mozilla-firefox/firefox/commit/c3d3e434db8e https://hg.mozilla.org/integration/autoland/rev/ed39ec09aaed Type the tab group and split view elements from their classes. r=tabbrowser-reviewers,sthompson
Status: ASSIGNED → RESOLVED
Closed: 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
Attachment #9639447 - Attachment description: Bug 2066073 - Ignore the tab group and split view reindent in blame and annotate. r?RyanVM → Bug 2066073 - Ignore the tab group and split view reindent in blame and annotate. r?#firefox-desktop-core-reviewers
QA Whiteboard: [qa-triage-done-c158/b157]
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4290620514a8 https://hg.mozilla.org/integration/autoland/rev/2be2b67940f0 Ignore the tab group and split view reindent in blame and annotate. r=firefox-desktop-core-reviewers ,mossop
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: