Open Bug 1451274 Opened 6 years ago Updated 1 year ago

Sourcemaps on CSS aren't recognised


(DevTools :: General, defect, P2)

61 Branch


(Not tracked)


(Reporter: m+mozilla, Unassigned)


(Blocks 1 open bug)


User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0
Build ID: 20180403220040

Steps to reproduce:

I've got a css with sourcemaps like this:

::-moz-selection {
  background-color: var(--color--action);
  color: #ffffff;

::selection {
  background-color: var(--color--action);
  color: #ffffff;

/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9rdWQvUHJvamVjdHMvX2NvbnRleHRlL2xvaXMtd2ViYXBwL3NyYy9zdHlsZXMvc2VsZWN0aW9uLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFLHVDQUF1QztFQUN2QyxlQUFlO0NBQ2hCOztBQUVEO0VBQ0UsdUNBQXVDO0VBQ3ZDLGVBQWU7Q0FDaEIiLCJmaWxlIjoic2VsZWN0aW9uLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIjo6LW1vei1zZWxlY3Rpb24ge1xuICBiYWNrZ3JvdW5kLWNvbG9yOiB2YXIoLS1jb2xvci0tYWN0aW9uKTtcbiAgY29sb3I6ICNmZmZmZmY7XG59XG5cbjo6c2VsZWN0aW9uIHtcbiAgYmFja2dyb3VuZC1jb2xvcjogdmFyKC0tY29sb3ItLWFjdGlvbik7XG4gIGNvbG9yOiAjZmZmZmZmO1xufVxuIl0sInNvdXJjZVJvb3QiOiIifQ== */

Actual results:

The result is a warning: Source map error: Error: sourceMapURL could not be parsed

Expected results:

I think it's because sourcemaps should be written like `//# sourceMappingURL=` as said there

However, you can't do this kind of comment in CSS. So `/*# sourceMappingURL=` should be accepted too(?).
Component: Untriaged → Developer Tools
Blocks: source-maps
That form of comment definitely works.  You can try a simple example here:

Instead I think the problem comes from the URL itself.  In particular I think the error
is thrown here:

source-map uses a phony URL parser that does:

var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  var match = aUrl.match(urlRegexp);

Sure enough, this doesn't work for the data: URL here.

I think the best fix would be to change source-map to use URL directly.
This should be possible now that it requires newer versions of node.
Upstream bug is here:

Though once that is fixed it will need a new release, then a new devtools-core release,
then landing in M-C.
Priority: -- → P2
Product: Firefox → DevTools
Hi! This issue is affecting our own webdevs, as well as the wider community. Is there a rough timeframe for when someone might be able to take a look at this?
Ever confirmed: true
Thanks Ed, is in our OKRs for Q4. Looks like we also got community on it now as well.
That's great - thank you :-)
See Also: → 1543896

:tromey Seems to have been fixed by 1607639

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.