Closed Bug 1375752 Opened 7 years ago Closed 5 years ago

Visualize console.log empty string output

Categories

(DevTools :: Console, defect, P3)

54 Branch
defect

Tracking

(firefox57 wontfix, firefox72 verified)

VERIFIED FIXED
Firefox 72
Tracking Status
firefox57 --- wontfix
firefox72 --- verified

People

(Reporter: shimscharf, Assigned: nchevobbe)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170608105825

Steps to reproduce:

- open developer tools
- go to console
- type:

console.log("")


Actual results:

output:
blank line


Expected results:

""

output should be empty string within double quotations marks.
This would be consistent with output from console.log {a:""}
This could be a huge problem if the following occurs with debugging:

console.log("", true)

Actual output:
true

Expected output:
"", true
Component: Untriaged → Developer Tools: Console
Thanks for reporting shimscharf.
It's true that this is a bit confusing.
I think the idea to omit the quotes in the logged messages was to make them easier to read (`console.log("Hello", "world")` would be not that nice output as `"Hello" "world"`).
We might want to show those quotes when we have an empty string, since it would help the user to see if there's an issue with a variable for example.

The expected output would then be `"" true` (we don't insert comma between logged arguments).

What do you think of this Brian ? Is there something I miss ?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: qe-verify+
Flags: needinfo?(bgrinstead)
Priority: -- → P3
Hi,

Yes, that is correct, it should only apply to empty strings to display "" in red to match console string output.

Same as it does in console.log ({a:""}), and console.log([""])

The commas used to be there in old versions of Firebug -> sorry, just a habit of mine over the years.

Cheers,
Simon
The work is likely to happen in the Reps repository on Github : https://github.com/devtools-html/devtools-core/issues/490
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #2)
> Thanks for reporting shimscharf.
> It's true that this is a bit confusing.
> I think the idea to omit the quotes in the logged messages was to make them
> easier to read (`console.log("Hello", "world")` would be not that nice
> output as `"Hello" "world"`).
> We might want to show those quotes when we have an empty string, since it
> would help the user to see if there's an issue with a variable for example.
> 
> The expected output would then be `"" true` (we don't insert comma between
> logged arguments).
> 
> What do you think of this Brian ? Is there something I miss ?

We've discussed this further in https://github.com/devtools-html/devtools-core/issues/490 and https://github.com/devtools-html/devtools-core/pull/491#issuecomment-314853337
Flags: needinfo?(bgrinstead)
Summary: console.log empty string output → Visualize console.log empty string output
(In reply to shimscharf from comment #1)
> This could be a huge problem if the following occurs with debugging:
> 
> console.log("", true)
> 
> Actual output:
> true
> 
> Expected output:
> "", true

In this case we should at least follow the Node / Chrome convention and render:

 true

instead of:

true

It's subtle, but there is an implied space between log arguments which is something we are missing.
Product: Firefox → DevTools

It just occurred to me this morning that in the case we don't show quotes, we could render something like <empty string> to make it clear.
So here devtools/client/debugger/packages/devtools-reps/src/reps/string.js#77-83 , we could have something like:

if (!useQuotes && text == "") {
  return span({
    className: "empty-string-rep"
  }, "<empty string>")
} 

we could then style the empty-string-rep class with the comment color so it's a bit dimmed.

This only affects console api calls where one of the
argument is an empty string. Since we don't quote
string arguments for those, it was difficult to spot
an empty string there.
Jest test are added, as well as a mochitest for the
console to make sure that we don't have unwanted
side effects (for evaluation results, object with
empty string properties, ...)

Assignee: nobody → nchevobbe
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/dadafea55f5d
Render empty strings as <empty string> in console. r=yzen.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 72

Verified fixed on Windows 10, Mac 10.15 and Ubuntu 18.04 using Firefox 72.0a1 (20191128214853)

Status: RESOLVED → VERIFIED
Flags: qe-verify+

What if I don;t want to see "<empty string>" in console, just a blank row? An option to set what is display for "" would be nice.

(In reply to prostyler from comment #12)

What if I don't want to see "<empty string>" in console, just a blank row? An option to set what is display for "" would be nice.

(In reply to prostyler from comment #12)

What if I don;t want to see "<empty string>" in console, just a blank row? An option to set what is display for "" would be nice.

You can achieve this by logging a space char (console.log(" ")) or a new line (console.log("\n")).

Option for firefox, to display console.log('') | console.log(' ') | console.log('\n') as user want to, would be best. I simply cannot change the code that WAS displayed properly in firefox (also chrome/chromium and all browsers that use this engine).

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: