Closed Bug 1905653 Opened 1 year ago Closed 1 year ago

Escape inside template literals gets lost by prettify

Categories

(DevTools :: Debugger, defect)

defect

Tracking

(firefox129 fixed)

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: arai, Assigned: arai)

Details

Attachments

(7 files)

Attached file testcase

Steps to reproduce:

  1. Run Nightly 129.0a1 (2024-06-30) (64-bit) with clean profile on macOS
  2. Open the attached file
  3. Open DevTools Debugger and select the HTML file
  4. Click prettify button

Actual result:

The JS code is prettified like the following, where backslashes inside the template literal get lost and results in an invalid code

(the attached file contains unnecessary RegExp literal. please ignore it)

(function () {
  return `foo `bar` baz \1`;
}) ();

Expected result:

The JS code is prettified like the following:

(function () {
  return `foo \`bar\` baz \\1`;
}) ();

This comes from the template literal not being handled by PrettyFast.#writeToken

Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/b55060e097ca Part 1: Handle template literals in pretty-fast. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/b833ffa9f4bc Part 2: Bundle pretty-print-worker.js. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/8659368edf0d Part 3: Add tests for template literals in pretty print. r=devtools-reviewers,nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: