Bug 207248

Summary: [Web Inspector][WinCairo] Selecting an error message in Console causes "TypeError:​ selection.focusNode.closest is not a function."
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: Web InspectorAssignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: hi, inspector-bugzilla-changes, stephan.szabo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=198594
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Fujii Hironori 2020-02-04 20:09:29 PST
[Web Inspector][WinCairo] The error "TypeError:​ selection.focusNode.closest is not a function." happens by selecting an error message

I tested with WinCairo WK2, trunk, r255482.

1. Start MiniBrowser
2. Open Web Inspector
3. Open Console Tab
4. Enter "foo"
5. An error message "ReferenceError: Can't find variable: foo" is output
6. Press left mouse button on the string of the error message
6. Drug the mouse
7. "TypeError:​ selection.focusNode.closest is not a function." happens

These uncaught exceptions caused the problem:
TypeError:​ selection.focusNode.closest is not a function. (In 'selection.focusNode.closest("." + WI.LogContentView.ItemWrapperStyleClassName)​', 'selection.focusNode.closest' is undefined)​ (at LogContentView.js:​552:​54)​
    _mousemove @ LogContentView.js:​552:​54
    handleEvent @ LogContentView.js:​653:​28

I don't see this issue in Mac port.
Comment 1 Stephan Szabo 2020-02-04 21:02:33 PST
Hmm, Devin Rousso seems to have reported similar for mac at https://bugs.webkit.org/show_bug.cgi?id=198594
Comment 2 Fujii Hironori 2020-02-04 21:59:45 PST
Looks a same issue. Thanks. But surprisingly Mac port doesn't reproduce the issue even this Bug 198594's test case on my Mac. 🤔
Comment 3 Fujii Hironori 2020-02-06 02:20:13 PST
selection.focusNode is a Text node at the time. closest is a method of Element.
Comment 4 Fujii Hironori 2020-02-06 02:40:27 PST
The code was added by r242174 (Bug 173747).
Comment 5 Fujii Hironori 2020-02-06 02:46:43 PST
Created attachment 389941 [details]
Patch
Comment 6 Devin Rousso 2020-02-06 09:24:24 PST
Comment on attachment 389941 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:552
> +                var focusElement = selection.focusNode;

Style: we prefer using `let`
Comment 7 Fujii Hironori 2020-02-06 17:56:14 PST
Created attachment 390037 [details]
Patch for landing

Thank you for the reveiw.
Comment 8 Fujii Hironori 2020-02-06 19:48:13 PST
Committed r256006: <https://trac.webkit.org/changeset/256006>
Comment 9 Radar WebKit Bug Importer 2020-02-06 19:49:13 PST
<rdar://problem/59249046>