console editor pretty-print button does not handle async function
Categories
(DevTools :: Console, defect, P2)
Tracking
(firefox-esr78 unaffected, firefox84 unaffected, firefox85 verified, firefox86 verified)
Tracking | Status | |
---|---|---|
firefox-esr78 | --- | unaffected |
firefox84 | --- | unaffected |
firefox85 | --- | verified |
firefox86 | --- | verified |
People
(Reporter: nchevobbe, Assigned: nchevobbe)
Details
Attachments
(2 files)
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
Steps to reproduce
- Open the console, switch to editor mode if it wasn't in it already
- Paste the following snippet
async function test() {
await new Promise(res => {})
}
- 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
Assignee | ||
Comment 1•5 years ago
|
||
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
Updated•5 years ago
|
Assignee | ||
Comment 2•5 years ago
|
||
Depends on D99320
Updated•5 years ago
|
Comment 4•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/477e4951eeda
https://hg.mozilla.org/mozilla-central/rev/0f8c6dedfc2b
Assignee | ||
Comment 5•5 years ago
|
||
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
- Switch to editor mode
- Type the following
async function test() { await new Promise(res => {})}
- 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:
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 6•5 years ago
|
||
When did this break? Can the new feature be turned off?
Assignee | ||
Comment 7•5 years ago
|
||
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 8•5 years ago
|
||
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
Updated•5 years ago
|
Updated•5 years ago
|
Comment 9•5 years ago
|
||
bugherder uplift |
Updated•5 years ago
|
Comment 10•5 years ago
|
||
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).
Description
•