Closed Bug 1555307 Opened 5 years ago Closed 2 years ago

Pretty print icon is not available

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: Honza, Unassigned)

References

(Blocks 1 open bug)

Details

STR:

  1. Load https://www.tcmeble.pl/produkty/giotto/
  2. Open DevTools & Debugger
  3. Select this file: wp-content/themes/szablon/js/scripts.min.js
  4. Try to pretty print it, there is no pretty print icon -> BUG

ER: there is pretty print icon at the bottom of the source view.

Honza

Priority: -- → P3

This seems separate from bug 1224654, as mimetype and extension are correct.

The pretty print icon is hidden due to the following check in devtools/client/debugger/src/reducers/sources.js:

(prefs.clientSourceMapsEnabled && isSourceWithMap(state, id))

The context menu on the source's tab does show the "Pretty print" item.

This is still a problem.

Blocks: dbg-72

The reason the "Pretty print" button does not appear in the Footer even though the "Pretty print source" option is not disabled in the Context Menu is because the check performed when displaying the "Pretty print" button in the Footer is more rigorous than the check performed when disabling the "Pretty print source" option in Context Menu.

In the Context Menu the "Pretty print source" option is not enabled if:

  1. source.url ends with ":formatted".

In the Footer the "Pretty print" button is not displayed if:

  1. source does not exist.
  2. source.url ends with ":formatted".
  3. source.isOriginal is set to true.
  4. The "Enable Source Maps" setting in the Debugger is checked and a sourceMapURL has been provided.

Therefore whenever a user has the "Enable Source Maps" setting checked and a sourceMapURL is provided, the pretty print button will not display. This is what is happening in the case described by this Bug. You can also find the relative url for the source map in the //# sourceMappingURL comment located at the end of the minified file that the user was trying to pretty print. This behavior is also visible if you use the STR to create the issue reported by Bug 1617531 which may be a duplicate of this bug.

A simple fix for this issue would be to match the condition used to display the "Pretty print" button to that of the "Pretty print source" option in the context menu. However, the appropriateness of that solution depends on whether or not there needs to be a more rigorous check before allowing users to pretty print a file. This is also what the conditions that are verified before displaying the "Pretty print" button in the Footer would suggest. Because I am not an expert as to when a file should or should not be printed, it is possible that @Logan Smyth, the original author of the canPrettyPrintSource() function that is run before displaying the "Pretty print" button in the Footer may be able to shine more light on this issue.

Flags: needinfo?(loganfsmyth)

The logic "hide pretty print button if the source has a source map" was introduced in https://github.com/firefox-devtools/debugger/pull/959 to address https://github.com/firefox-devtools/debugger/issues/949 .

The button is hidden because offering pretty printing resulted in broken mapping between breakpoints/call stacks and source files.
In my opinion, it would be preferable to offer an option to temporarily disable source maps for a specific file (or if possible, support pretty printing despite the pre-existing source map).

In my opinion, it would be preferable to offer an option to temporarily disable source maps for a specific file (or if possible, support pretty printing despite the pre-existing source map).

Afaik, this maps to what I proposed in https://bugzilla.mozilla.org/show_bug.cgi?id=1224654#c6 . We need a follow-up bug to fix the source-map breakage after pretty-printing.

I don't think I have a ton to add here. From what I understand, we don't want to show the button because we legitimately don't support pretty-printing original files or files that already have a sourcemap, but we still show the option in the context menu as a weird hack for people that still want to I guess give pretty-printing a shot anyway? IDK.

Flags: needinfo?(loganfsmyth)

Where is this context menu? I'm not seeing anything in Release 77 and Nightly 79.

When you right-click on a debugger source file's tab.

Severity: normal → S3

Source from comment 0 is not available anymore. I tried all the file under wp-content and they all had the icon enabled.
Since we made some work around this lately (showing the icon, but disabled, fixing the case with sourcemap file referenced but not served, …), I'm going to close this

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.