Closed Bug 1306146 Opened 9 years ago Closed 9 years ago

Firefox handles relative sourceRoot in source maps incorrectly

Categories

(DevTools :: Debugger, defect, P2)

51 Branch
defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: aliaksei.dreamsonic, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0 Build ID: 20160922113459 Steps to reproduce: When a source map contains sourceRoot which represents a relative path, Firefox handles the sources paths incorrectly. Example requires 3 files (2 if the source map is inlined): 1) Source file (http://example.com/foo/source/script.js) 2) File generated based on the source (http://example.com/foo/bundle.js) 3) Source map (http://example.com/foo/bundle.map) Notice that the source file is located in a folder named `source` relative to the bundle. The source map looks like this: ``` {"sources":["script.js"], "sourceRoot":"source", ...} ``` Here's a plunkr: https://plnkr.co/edit/ESu37NSP6Hs3xLxl9NLt?p=preview (Launch the preview in a separate window to reproduce the results.) Actual results: Instead of listing `http://example.com/foo/source/script.js` in the sources, dev tools show `http://example.com/source/script.js` - notice that `/foo` is missing, hence the URL is not correct. (If the source map doesn't contain sourcesContent this will result in 404 when dev tools will try to load the file.) Expected results: According to the spec (https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.75yo6yoyk7x5): > If the sources are not absolute URLs after prepending of the “sourceRoot”, the sources are resolved relative to the SourceMap (like resolving script src in a html document). In this example the resulting source should be `http://example.com/foo/` + `source` + `script.js` = `http://example.com/foo/source/script.js` I've confirmed that Chrome, IE11 and Edge work correctly in this case. When sourceRoot is omitted (or empty) and the source is specified as `source/script.js` the issue is not reproducible and devtools work correctly
Component: Untriaged → Developer Tools: Debugger
OS: Unspecified → All
Hardware: Unspecified → All
Out of curiosity I've experimented with various combinations of sources and sourceRoot values. Let's say that the source map is located in `/foo/bar/baz.map` source | sourceRoot | resulting source ----------------------------------------------- script.js | (empty) | /foo/bar/script.js script.js | "." | /foo/script.js script.js | ".." | /script.js script.js | "../qux" | /qux/script.js qux/script.js | (empty) | /foo/bar/qux/script.js qux/script.js | "." | /foo/qux/script.js qux/script.js | ".." | /qux/script.js qux/script.js | "../qux | /qux/qux/script.js My guess is that there's somewhere an off-by-one error in relative path calculation routine, because the paths appear to be relative not to the folder containing the source map, but to its parent.
This is what I'm seeing in Nightly, seems to work there.
Can you try this out in Nightly? http://nightly.mozilla.org/ Thanks!
Flags: needinfo?(aliaksei.dreamsonic)
Priority: -- → P2
Bryan, yes, I've verified that it works correctly in Nightly (v53) and in Aurora/Dev Edition (v52). This issue can be closed. Thanks!
Flags: needinfo?(aliaksei.dreamsonic)
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: