Bug 149638 - Web Inspector: Can't click on a stack trace link when it's in a console message preview
Summary: Web Inspector: Can't click on a stack trace link when it's in a console messa...
Status: RESOLVED DUPLICATE of bug 149790
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-09-29 12:57 PDT by Nikita Vasilyev
Modified: 2016-02-11 17:38 PST (History)
8 users (show)

See Also:


Attachments
[Image] Bug (249.45 KB, image/png)
2015-09-29 12:57 PDT, Nikita Vasilyev
no flags Details
[HTML] Reduction (398 bytes, text/html)
2015-09-29 12:58 PDT, Nikita Vasilyev
no flags Details
WIP (2.19 KB, patch)
2015-10-17 21:10 PDT, Nikita Vasilyev
nvasilyev: review-
nvasilyev: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2015-09-29 12:57:09 PDT
Created attachment 262093 [details]
[Image] Bug

Steps:
1. Open stacktrace-preview.html
2. Open the console

Expected:
Console stack trace should have clickable source links. Line breaks should be line breaks and not "↵".

Actual:
Can't click on the source links and line breaks are shown as "↵".

Notes:
While the error object view was improved a couple of months ago, there are still cases when we don’t display stacktraces properly. We should do what Tim originally suggested, auto detect silly error.stack format and render it as a stack trace object tree instead (https://bugs.webkit.org/show_bug.cgi?id=143853#c0). That's what Chrome does, too.
Comment 1 Radar WebKit Bug Importer 2015-09-29 12:57:29 PDT
<rdar://problem/22902212>
Comment 2 Nikita Vasilyev 2015-09-29 12:58:42 PDT
Created attachment 262095 [details]
[HTML] Reduction
Comment 3 Nikita Vasilyev 2015-10-17 21:10:08 PDT
Created attachment 263407 [details]
WIP
Comment 4 Nikita Vasilyev 2015-10-17 21:18:35 PDT
Comment on attachment 263407 [details]
WIP

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

> Source/WebInspectorUI/UserInterface/Base/Main.js:2023
> +    var linkStringRegEx = /(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\/\/|www\.)[\w$\-_+*'=\|\/\\(){}\[\]%@&#~,:;.!?]{2,}[\w$\-_+*=\|\/\\({%@&#~]/;

[ character doesn't have to escaped here but it was driving me (and WebStorm) crazy.

> Source/WebInspectorUI/UserInterface/Views/FormattedValue.css:49
> +.formatted-string, [class].formatted-string > a {

"[class]" hack is used to increase rule specificity.

> Source/WebInspectorUI/UserInterface/Views/FormattedValue.js:172
> +        span.textContent = doubleQuotedString(displayString);

This fails on console.log("blah", "a URL longer than WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH"). A long URL gets truncated first, which results in a wrong URL.

The patch needs to be more complex than this.
Comment 5 Devin Rousso 2015-10-21 19:49:50 PDT
Comment on attachment 263407 [details]
WIP

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

>> Source/WebInspectorUI/UserInterface/Views/FormattedValue.js:172
>> +        span.textContent = doubleQuotedString(displayString);
> 
> This fails on console.log("blah", "a URL longer than WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH"). A long URL gets truncated first, which results in a wrong URL.
> 
> The patch needs to be more complex than this.

I am a bit confused here.  If the only thing that is causing this to not work is the fact that the string is truncated before it is linkified, then why not just save the string before you modify it?
Comment 6 Nikita Vasilyev 2015-10-21 20:03:48 PDT
(In reply to comment #5)
> Comment on attachment 263407 [details]
> WIP
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=263407&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/FormattedValue.js:172
> >> +        span.textContent = doubleQuotedString(displayString);
> > 
> > This fails on console.log("blah", "a URL longer than WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH"). A long URL gets truncated first, which results in a wrong URL.
> > 
> > The patch needs to be more complex than this.
> 
> I am a bit confused here.  If the only thing that is causing this to not
> work is the fact that the string is truncated before it is linkified, then
> why not just save the string before you modify it?

We need to linkify first.
Then we need to truncate the text. URLs shouldn't be affected, but links' text should.

We wouldn't be able to use String#truncate any longer, since it operates on strings and after linkifying we'll have nodes (<a> and text nodes).
Comment 7 Devin Rousso 2015-10-22 00:20:33 PDT
(In reply to comment #6)
> (In reply to comment #5)
> > Comment on attachment 263407 [details]
> > WIP
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=263407&action=review
> > 
> > >> Source/WebInspectorUI/UserInterface/Views/FormattedValue.js:172
> > >> +        span.textContent = doubleQuotedString(displayString);
> > > 
> > > This fails on console.log("blah", "a URL longer than WebInspector.FormattedValue.MAX_PREVIEW_STRING_LENGTH"). A long URL gets truncated first, which results in a wrong URL.
> > > 
> > > The patch needs to be more complex than this.
> > 
> > I am a bit confused here.  If the only thing that is causing this to not
> > work is the fact that the string is truncated before it is linkified, then
> > why not just save the string before you modify it?
> 
> We need to linkify first.
> Then we need to truncate the text. URLs shouldn't be affected, but links'
> text should.
> 
> We wouldn't be able to use String#truncate any longer, since it operates on
> strings and after linkifying we'll have nodes (<a> and text nodes).

Ah I understand now.  Seems like we may need to create something like WebInspector.linkifyTruncatedStringAsFragment that will linkify and then truncate.  It seems like WebInspector.linkifyStringAsFragmentWithCustomLinkifier is only ever called inside WebInspector.linkifyStringAsFragment, so maybe just add a parameter shouldTruncate and pass in the non-truncated string.  Interesting situation :P
Comment 8 Timothy Hatcher 2015-12-09 16:09:51 PST
It would be good to finish this up.
Comment 9 Devin Rousso 2015-12-29 09:34:39 PST
Is this still an issue?  I just tried this with the reduction file and am seeing it render with links just fine.
Comment 10 Joseph Pecoraro 2016-01-04 13:01:25 PST
Yeah, this looks like it is working now. Nikita, do you remember what fixed it?
Comment 11 Nikita Vasilyev 2016-01-05 08:59:49 PST
Bug 149790 "Web Inspector: When logging strings, detect stack traces and show them as StackTraceView" solved this.
Comment 12 Timothy Hatcher 2016-02-11 17:38:05 PST

*** This bug has been marked as a duplicate of bug 149790 ***