Bug 205148

Summary: Web Inspector: REGRESSION(r251227): Uncaught Exception: undefined is not an object (evaluating 'target.DOMAgent.setInspectModeEnabled')
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, hi, inspector-bugzilla-changes, joepeck, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on: 200384    
Bug Blocks:    
Attachments:
Description Flags
Patch none

Description Devin Rousso 2019-12-11 17:58:23 PST
Uncaught Exception in Web Inspector.

Steps to Reproduce:
1. inspect any page
2. Develop > Start Element Selection (⇧⌘C)
 => element selection doesn't turn on
3. open Web Inspector through some other method
 => uncaught exception shown
4. Develop > Start Element Selection (⇧⌘C)
 => element selection turns on as expected

I think this is a regression from r251227 because the connection to the actual `WebCore::Page` target hasn't been established yet, meaning that the `WI.mainTarget` is actually the `WI.MultiplexingBackendTarget`.

Uncaught Exceptions:
-----------------------
 - undefined is not an object (evaluating 'target.DOMAgent.setInspectModeEnabled') (at DOMManager.js:589:24)
    inspectModeEnabled @ DOMManager.js:589:24
    setElementSelectionEnabled @ InspectorFrontendAPI.js:74:22
    dispatch @ InspectorFrontendAPI.js:174:54
    loadCompleted @ InspectorFrontendAPI.js:182:42
    ? @ Main.js:533:43
    promiseReactionJob @ [native code]
-----------------------

Notes:
Inspected URL:        (unknown)
Loading completed:    true
Frontend User Agent:  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko)
Comment 1 Devin Rousso 2019-12-11 18:04:42 PST
Created attachment 385469 [details]
Patch
Comment 2 Joseph Pecoraro 2019-12-11 18:08:25 PST
Comment on attachment 385469 [details]
Patch

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

r=me

> Source/WebInspectorUI/ChangeLog:22
> +        * UserInterface/Base/Main.js:
> +        Drive-by: remove duplicate function `WI._toggleInspectMode` as it already exists.

!! How did a linter not catch this?
Comment 3 Devin Rousso 2019-12-11 23:40:47 PST
Comment on attachment 385469 [details]
Patch

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

>> Source/WebInspectorUI/ChangeLog:22
>> +        Drive-by: remove duplicate function `WI._toggleInspectMode` as it already exists.
> 
> !! How did a linter not catch this?

As we discussed in person, it’s not a function on a class or a variable in a scope, so it’s not as easily statically analyzable :(
Comment 4 WebKit Commit Bot 2019-12-12 00:24:31 PST
Comment on attachment 385469 [details]
Patch

Clearing flags on attachment: 385469

Committed r253421: <https://trac.webkit.org/changeset/253421>
Comment 5 WebKit Commit Bot 2019-12-12 00:24:33 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2019-12-12 00:25:21 PST
<rdar://problem/57869541>