Closed Bug 1810885 Opened 1 year ago Closed 1 year ago

Use ChromeMap to rewrite chrome:// URIs in Storybook

Categories

(Firefox :: General, task, P3)

task

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: mstriemer, Assigned: mstriemer)

References

(Blocks 1 open bug)

Details

(Whiteboard: [recomp])

Attachments

(1 file)

In bug 1804969 a webpack plugin was added to rewrite some chrome JS URLs. It guesses at some mappings of chrome:// URIs to paths on disk, but there is actually a backend that we can use to generate the mapping for us.

Use ./mach build-backend -b ChromeMap to generate the chrome-map.json file, which we can then use to rewrite URIs rather than generating the rewrites.json file

The chrome-map.json file is lightly documented in its source [1]

The happy path for something like chrome://global/content/elements/moz-support-link.mjs appears to be:

  1. Check if there's a URI override (index 1)
  2. Find where it's bundled
    • Look up chrome://global/content in the chrome mappings (index 0)
    • "chrome://global/content/": [
        "dist/bin/chrome/toolkit/content/global"
      ],
      
  3. Find the file in that section
    • Look up dist/bin/chrome/toolkit/content/global in the file system mappings (index 2)
    • "dist/bin/chrome/toolkit/content/global/elements/moz-support-link.mjs": [
        "toolkit/content/widgets/moz-support-link/moz-support-link.mjs",
        null
      ],
      

Note that the file has some globs on it. Hopefully those aren't too bad to handle, for example the private browsing assets, chrome://browser/content/assets/focus-logo.svg is mapped by:

    "dist/bin/browser/chrome/browser/content/browser/assets/": [
      "browser/components/privatebrowsing/content/assets/*",
      null
    ],

[1] https://searchfox.org/mozilla-central/rev/5bcbe6ae54ee5b152f6cef29dc5627ec7c0e1f1e/python/mozbuild/mozbuild/codecoverage/chrome_map.py#144-153

Summary: Use ChromeMap to rewrute chrome:// URIs in Storybook → Use ChromeMap to rewrite chrome:// URIs in Storybook
Whiteboard: [fidefe-reusable-components-ms1] → [fidefe-reusable-components-ms2]
Assignee: nobody → mstriemer
Status: NEW → ASSIGNED
Pushed by mstriemer@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1ba9059ff3eb
Use ChromeMap for rewriting chrome:// URIs in Storybook r=hjones
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
Whiteboard: [fidefe-reusable-components-ms2] → [recomp]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: