Closed Bug 1681055 Opened 5 years ago Closed 5 years ago

console editor pretty-print button does not handle async function

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(firefox-esr78 unaffected, firefox84 unaffected, firefox85 verified, firefox86 verified)

VERIFIED FIXED
86 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox84 --- unaffected
firefox85 --- verified
firefox86 --- verified

People

(Reporter: nchevobbe, Assigned: nchevobbe)

Details

Attachments

(2 files)

Steps to reproduce

  1. Open the console, switch to editor mode if it wasn't in it already
  2. Paste the following snippet
async function test() {
  await new Promise(res => {})
}
  1. Click on the pretty print button in the top toolbar

Expected results

The snippet stays more or less the same

Actual results

The expression is turned into

async 
function test() {
  await new Promise(res => {})
}

which throws a SyntaxError when evaluated


This might be because the library that we use there (js_beautify), is not up-to-date/doesn't handle es6 syntax


This fix pretty-printing of async functions in console. A test case is added
to make sure we don't regress.

We used to copy the library tests and run them in xpcshell. The tests changed
a lot, and I don't think we get much value running tests that are already ran on
the project CI (we do have a few tests that checks that we get the output we want)
, so this patch remove the xpcshell test and the associated files.

The upgrade documentation is updated to remove some unecessary steps:

  • no need to rename the exported module for each file
  • no need to replace the acorn module, since what's in the file is just a subset
    of the library (~100 lines)
  • no need to update the test file, which doesn't seem to exist anymore
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P2
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/477e4951eeda [devtools] Update beautify-js to 1.13.0. r=ochameau. https://hg.mozilla.org/integration/autoland/rev/0f8c6dedfc2b [devtools] Add test case to check pretty-printing works on async function in console editor. r=ochameau.
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch

Comment on attachment 9192349 [details]
Bug 1681055 - [devtools] Update beautify-js to 1.13.0. r=ochameau.

Beta/Release Uplift Approval Request

  • User impact if declined: Pretty-printing in the DevTools console editor (which is a new feature) an expression with es6 syntax (e.g. async/await), might turn valid code into code with syntax errors.
    It would be nice to avoid shipping a kinda broken feature to release.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: 1. Open the console
  1. Switch to editor mode
  2. Type the following async function test() { await new Promise(res => {})}
  3. Click on the pretty print button ({}) in the toolbar

Expected result:

async function test() {
  await new Promise(res => {})
}

(valid expression)

  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Updating a third-party library only used in a couple places in devtools, for non-critical features, covered by an automated test (in the other patch of this bug)
  • String changes made/needed:
Attachment #9192349 - Flags: approval-mozilla-beta?
Attachment #9192350 - Flags: approval-mozilla-beta?
Flags: qe-verify+

When did this break? Can the new feature be turned off?

It was already broken when we introduced the feature, we didn't realized soon enough.
We don't have a simple pref to turn it off, but I could do a patch to do that, that would then be uplifted. Is this the preferred way for you Julien?

Comment on attachment 9192349 [details]
Bug 1681055 - [devtools] Update beautify-js to 1.13.0. r=ochameau.

It's early enough in beta that I think we can take this, but asking in case there's other issues down the road.

approved for 85.0b3

Attachment #9192349 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9192350 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

Reproduced the initial issue using old Nightly from 2020-12-07, verified that this is fixed using latest Nightly 86.0a1 and Latest Beta 85 from treeherder across platforms (Windows 10 64bit, macOS 11 and Ubuntu 18.04 64bit).

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: