Closed Bug 2070849 Opened 2 months ago Closed 1 month ago

Convert tabs.js to a module and type the tab strip from its class

Categories

(Firefox :: Tabbed Browser, task)

task

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: dao, Assigned: dao)

References

(Blocks 1 open bug)

Details

Attachments

(5 external files, 1 obsolete file)

browser/components/tabbrowser/content/tabs.js is loaded as a subscript, so TypeScript cannot see MozTabbrowserTabs. Nothing stands in for the tab strip either, so every tabContainer access in Tabbrowser.sys.mjs goes unchecked.

Make it a .mjs that exports its class and defines the element, imported with { global: "current" } where the subscript was loaded, the way Bug 2066073 did for tabgroup.js and tabsplitview.js. Then declare MozElements.TabsBase in tools/@types/lib.gecko.augmentations.d.ts - an undeclared base makes every inherited member vanish - and point types/elements.ts at the real class.

The .mjs extension turns on no-shadow with builtinGlobals, so three locals shadowing window.name, window.parent and window.closed are renamed here.

The subscript loader does not read the extension, so the file still loads as before. Dropping "use strict", which eslint rejects in a .mjs, leaves it sloppy until the next commit makes it a real module; nothing outside the class body depends on strictness.

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

The browser-window eslint environment harvests its globals from the scripts browser-main.js loads with loadSubScript, and hands the set back to those same scripts. Once the next commit imports this one as a module instead, it is neither harvested nor handed anything, so the globals it uses have to be named here.

Dropping the indentation-preserving block re-indents the whole file, so git diff -w is the actual change: the export, and the import that replaces the subscript load.

The three cannot be separated. export is top-level only, so it needs the block gone; and once the block is gone the file's own top-level names collide with the browser-window globals harvested from browser-main.js's loadSubScript line, which only the import removes.

Attachment #9640620 - Attachment is obsolete: true
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e3ff7020e148 https://hg.mozilla.org/integration/autoland/rev/0dff829f609e Rename the tab strip element script to .mjs. r=tabbrowser-reviewers,jsudiaman,frontend-codestyle-reviewers
Keywords: leave-open
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/df8487d6e12e https://hg.mozilla.org/integration/autoland/rev/fb806040e208 Ignore the tab strip module conversion in blame and annotate. r=firefox-desktop-core-reviewers ,mossop

A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)

QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: