Bug 210511 - Web Inspector: Console: treat long strings as non-simple so they aren't truncated
Summary: Web Inspector: Console: treat long strings as non-simple so they aren't trunc...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-14 12:31 PDT by Devin Rousso
Modified: 2020-04-14 13:23 PDT (History)
4 users (show)

See Also:


Attachments
Patch (4.00 KB, patch)
2020-04-14 12:34 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2020-04-14 12:31:01 PDT
# STEPS TO REPRODUCE:
1. inspect any page
2. evaluate `console.log(true, "NaN".repeat(1000) + "Batman!");`
3. select the logged message and copy it
4. paste anywhere
 => only the first 140 characters of the string are copied, and there is no disclosure arrow to expand the message and allow the full string to be shown
Comment 1 Devin Rousso 2020-04-14 12:31:15 PDT
<rdar://problem/49570592>
Comment 2 Devin Rousso 2020-04-14 12:34:45 PDT
Created attachment 396450 [details]
Patch
Comment 3 Joseph Pecoraro 2020-04-14 12:41:27 PDT
Comment on attachment 396450 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396450&action=review

So how does this look when you log a long string?

> Source/WebInspectorUI/UserInterface/Views/FormattedValue.js:30
> +WI.FormattedValue.isSimpleString = function(string)

Nice! Could be tested.
Comment 4 Devin Rousso 2020-04-14 13:10:04 PDT
Comment on attachment 396450 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396450&action=review

> So how does this look when you log a long string?
It looks the same as it does right now in that the truncated string is shown inline, but there's now a disclosure arrow that expands the list of non-simple arguments in the same way that `console.log(true, [globalThis]);` would, putting the full string on it's own line/item.

>> Source/WebInspectorUI/UserInterface/Views/FormattedValue.js:30
>> +WI.FormattedValue.isSimpleString = function(string)
> 
> Nice! Could be tested.

I think this is simple enough that it doesn't need a test.  If we change the maximum length in the future, having to remember to update a test as well seems like an extra unnecessary step.  Plus, nothing else in this file is tested since it's really all view code.
Comment 5 EWS 2020-04-14 13:23:20 PDT
Committed r260091: <https://trac.webkit.org/changeset/260091>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396450 [details].