Throwing an empty string displays "undefined" in the console

VERIFIED FIXED in Firefox 60

Status

defect
VERIFIED FIXED
a year ago
7 months ago

People

(Reporter: nchevobbe, Assigned: nchevobbe)

Tracking

Trunk
Firefox 60

Firefox Tracking Flags

(firefox60 verified)

Details

Attachments

(3 attachments)

(Assignee)

Description

a year ago
Steps to reproduce:
1. Open the console
2. Evaluate `throw "";`


Expected results:

There's an empty error message

Actual results:

There an "undefined" message, without the error style.
Comment hidden (mozreview-request)
FYI I'm going to be away for the remainder of the week. Feel free to redirect this if you'd like - otherwise I will get to it early next week.

Comment 5

a year ago
mozreview-review
Comment on attachment 8948917 [details]
Bug 1436110 - Fix stub generation and update existing stubs; .

https://reviewboard.mozilla.org/r/218344/#review225436
Attachment #8948917 - Flags: review?(bgrinstead) → review+

Comment 6

a year ago
mozreview-review
Comment on attachment 8948918 [details]
Bug 1436110 - Add pageError and evaluationResult tests for thrown strings; .

https://reviewboard.mozilla.org/r/218346/#review225438
Attachment #8948918 - Flags: review?(bgrinstead) → review+

Comment 7

a year ago
mozreview-review
Comment on attachment 8948916 [details]
Bug 1436110 - Fix rendering of thrown string in evaluation results; .

https://reviewboard.mozilla.org/r/218342/#review225442

The way we re-map exceptionMessage into messageText for evaluation results is kind of confusing, but at least now it's more explicit.

::: devtools/client/webconsole/new-console-output/components/message-types/EvaluationResult.js:47
(Diff revision 1)
>      parameters,
>      notes,
>    } = message;
>  
>    let messageBody;
> -  if (message.messageText) {
> +  if (typeof message.messageText !== "undefined" && message.messageText !== null) {

Is this change fixing a bug? I didn't think there'd be a case where messageText / exceptionMessage would `=== false`, so this seems unnecessary.

::: devtools/client/webconsole/new-console-output/utils/messages.js:271
(Diff revision 1)
> +  } else if (typeof exception === "string") {
> +    // Wrap thrown strings in Error objects, so `throw "foo"` outputs "Error: foo"
> +    exceptionMessage = new Error(exceptionMessage).toString();
>    }
>  
> -  const level = messageText ? MESSAGE_LEVEL.ERROR : MESSAGE_LEVEL.LOG;
> +  const level = typeof exceptionMessage !== "undefined" && exceptionMessage !== null

Ditto
Attachment #8948916 - Flags: review?(bgrinstead) → review+
(Assignee)

Comment 8

a year ago
>Is this change fixing a bug? I didn't think there'd be a case where messageText / exceptionMessage would `=== false`, so this seems unnecessary.

Yes, since `messageText` can be "", we wouldn't go into the if.

Comment 9

a year ago
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5d3f2a7dfdc9
Fix rendering of thrown string in evaluation results; r=bgrins.
https://hg.mozilla.org/integration/autoland/rev/719f138bc9d8
Fix stub generation and update existing stubs; r=bgrins.
https://hg.mozilla.org/integration/autoland/rev/9ce4a74db793
Add pageError and evaluationResult tests for thrown strings; r=bgrins.
I have reproduced this bug with Nightly 60.0a1 (2018-02-06) on Windows 10, 64 Bit!

The bug's fix is now verified with Latest Nightly!

Build ID   20180217100053
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
QA Whiteboard: [testday-20180216]
I tried to reproduce the bug using an older version of Nightly (2018-02-06) on Windows 10, Ubuntu 16.04 and macOS 10.13, but after I write ' throw ""; ' in the Browser Console the result I get is just the word "Error". And I get the same behaviour on latest Nightly 60.0a1 and beta 59.0b10 using the same platforms. 

Did I miss some of the steps or did I do something wrong?
(Assignee)

Comment 13

a year ago
Hello Oana,

This is only on the regular console, not the browser console (the browser console still uses an old version of the console)
I am sorry. I wrote the text in the wrong console. 

I retested everything using the same steps only this time I wrote 'throw ""; ' in the Web Console. I managed to reproduce the issue on the Nightly from 2018-02-06. 
I verified everything on the same platforms as comment 12 using the latest Nightly 60.0a1 and the bug is fixed. 

According to this result and the one from comment 11, I will mark this bug as verified.
Status: RESOLVED → VERIFIED
(Assignee)

Comment 15

a year ago
no worries :)

Updated

11 months ago
Product: Firefox → DevTools
Assignee: nobody → nchevobbe
You need to log in before you can comment on or make changes to this bug.