Web Inspector: Start moving toward better multi-target support
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Nov 2018 19:23:42 +0000 (19:23 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Nov 2018 19:23:42 +0000 (19:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191345

Reviewed by Devin Rousso.

This change continues the move toward better multi-target support
by explicitly using explicit target agents in more places, and
converting generalized feature checks into target agnostic versions
that use the new InspectorBackend.domains, which does not vary based
on the connected targets / debuggable type.

I also audited uses of RuntimeAgent, ConsoleAgent, and DebuggerAgent
for better multi-target support since these agents should already
have complete multi-target support.

* UserInterface/Protocol/Target.js:
(WI.Target.prototype.initialize):
Move explicitly to target.Agent feature checks with a known target.

* UserInterface/Controllers/DebuggerManager.js:
(WI.DebuggerManager.prototype.initializeTarget):
(WI.DebuggerManager.prototype._pauseForInternalScriptsDidChange):
Move explicitly to target.DebuggerAgent for feature checks with a known target.

* UserInterface/Controllers/NetworkManager.js:
(WI.NetworkManager.prototype.initializeTarget):
Move explicitly to target.NetworkAgent for feature checks with a known target.

* UserInterface/Controllers/RuntimeManager.js:
(WI.RuntimeManager.prototype.initializeTarget):
(WI.RuntimeManager.prototype.saveResult):
* UserInterface/Protocol/RemoteObject.js:
(WI.RemoteObject.prototype.updatePreview):
(WI.RemoteObject.prototype.getDisplayablePropertyDescriptors):
(WI.RemoteObject.prototype.deprecatedGetDisplayableProperties):
* UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype._createTypeTokenAnnotator):
(WI.SourceCodeTextEditor.prototype._createBasicBlockAnnotator):
Move explicitly to target.RuntimeAgent for feature checks with a known target.

* UserInterface/Models/CSSCompletions.js:
(WI.CSSCompletions.initializeCSSCompletions):
Move explicitly to target.CSSAgent for feature checks with a known target.

* UserInterface/Views/ContextMenuUtilities.js:
Use the DebuggerAgent from the target associated with the DOMNode's
remote object instead of assuming the main target.

* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createGeneralSettingsView):
Update the ConsoleAgent setting on all targets that support it.

* UserInterface/Views/BreakpointActionView.js:
(WI.BreakpointActionView):
All backends support BreakpointActionType, the assertion can go away.

* UserInterface/Views/LogContentView.js:
(WI.LogContentView.prototype.get navigationItems):
* UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView.prototype.get navigationItems):
Include additional `window.FooAgent` checks for these since they will need
to be revisited in the future.

* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass.prototype.get domains):
(InspectorBackendClass.prototype.activateDomain):
Expose InspectorBackend.domains.<Domain> for feature checking.

* UserInterface/Controllers/BreakpointPopoverController.js:
(WI.BreakpointPopoverController.prototype._createPopoverContent):
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager):
(WI.CSSManager.prototype._mainResourceDidChange):
* UserInterface/Controllers/TimelineManager.js:
(WI.TimelineManager.prototype._attemptAutoCapturingForFrame):
(WI.TimelineManager.prototype._updateAutoCaptureInstruments):
(WI.TimelineManager):
* UserInterface/Models/Canvas.js:
(WI.Canvas.prototype.startRecording):
(WI.Canvas.prototype.recordingFinished):
* UserInterface/Models/ScriptSyntaxTree.js:
(WI.ScriptSyntaxTree.functionReturnDivot):
* UserInterface/Protocol/DebuggerObserver.js:
(WI.DebuggerObserver):
* UserInterface/Protocol/NetworkObserver.js:
(WI.NetworkObserver.prototype.requestWillBeSent):
* UserInterface/Views/DebuggerSidebarPanel.js:
(WI.DebuggerSidebarPanel):
(WI.DebuggerSidebarPanel.prototype._handleCreateBreakpointClicked):
* UserInterface/Views/NetworkTimelineView.js:
(WI.NetworkTimelineView):
* UserInterface/Views/ResourceDetailsSidebarPanel.js:
(WI.ResourceDetailsSidebarPanel.prototype._refreshRequestAndResponse):
* UserInterface/Views/WebSocketContentView.js:
(WI.WebSocketContentView):
(WI.NetworkManager.prototype.webSocketWillSendHandshakeRequest):
(WI.DebuggerManager.prototype.debuggerDidResume):
Feature check in a target agnostic way.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238048 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js
Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js
Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js
Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js
Source/WebInspectorUI/UserInterface/Models/Canvas.js
Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js
Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js
Source/WebInspectorUI/UserInterface/Protocol/NetworkObserver.js
Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js
Source/WebInspectorUI/UserInterface/Protocol/Target.js
Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js
Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js
Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/LogContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
Source/WebInspectorUI/UserInterface/Views/WebSocketContentView.js

index 171dcf1..15afa54 100644 (file)
@@ -1,3 +1,104 @@
+2018-11-08  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Start moving toward better multi-target support
+        https://bugs.webkit.org/show_bug.cgi?id=191345
+
+        Reviewed by Devin Rousso.
+
+        This change continues the move toward better multi-target support
+        by explicitly using explicit target agents in more places, and
+        converting generalized feature checks into target agnostic versions
+        that use the new InspectorBackend.domains, which does not vary based
+        on the connected targets / debuggable type.
+
+        I also audited uses of RuntimeAgent, ConsoleAgent, and DebuggerAgent
+        for better multi-target support since these agents should already
+        have complete multi-target support.
+
+        * UserInterface/Protocol/Target.js:
+        (WI.Target.prototype.initialize):
+        Move explicitly to target.Agent feature checks with a known target.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WI.DebuggerManager.prototype.initializeTarget):
+        (WI.DebuggerManager.prototype._pauseForInternalScriptsDidChange):
+        Move explicitly to target.DebuggerAgent for feature checks with a known target.
+
+        * UserInterface/Controllers/NetworkManager.js:
+        (WI.NetworkManager.prototype.initializeTarget):
+        Move explicitly to target.NetworkAgent for feature checks with a known target.
+
+        * UserInterface/Controllers/RuntimeManager.js:
+        (WI.RuntimeManager.prototype.initializeTarget):
+        (WI.RuntimeManager.prototype.saveResult):
+        * UserInterface/Protocol/RemoteObject.js:
+        (WI.RemoteObject.prototype.updatePreview):
+        (WI.RemoteObject.prototype.getDisplayablePropertyDescriptors):
+        (WI.RemoteObject.prototype.deprecatedGetDisplayableProperties):
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WI.SourceCodeTextEditor.prototype._createTypeTokenAnnotator):
+        (WI.SourceCodeTextEditor.prototype._createBasicBlockAnnotator):
+        Move explicitly to target.RuntimeAgent for feature checks with a known target.
+
+        * UserInterface/Models/CSSCompletions.js:
+        (WI.CSSCompletions.initializeCSSCompletions):
+        Move explicitly to target.CSSAgent for feature checks with a known target.
+
+        * UserInterface/Views/ContextMenuUtilities.js:
+        Use the DebuggerAgent from the target associated with the DOMNode's
+        remote object instead of assuming the main target.
+
+        * UserInterface/Views/SettingsTabContentView.js:
+        (WI.SettingsTabContentView.prototype._createGeneralSettingsView):
+        Update the ConsoleAgent setting on all targets that support it.
+
+        * UserInterface/Views/BreakpointActionView.js:
+        (WI.BreakpointActionView):
+        All backends support BreakpointActionType, the assertion can go away.
+
+        * UserInterface/Views/LogContentView.js:
+        (WI.LogContentView.prototype.get navigationItems):
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WI.DOMTreeContentView.prototype.get navigationItems):
+        Include additional `window.FooAgent` checks for these since they will need
+        to be revisited in the future.
+
+        * UserInterface/Protocol/InspectorBackend.js:
+        (InspectorBackendClass.prototype.get domains):
+        (InspectorBackendClass.prototype.activateDomain):
+        Expose InspectorBackend.domains.<Domain> for feature checking.
+
+        * UserInterface/Controllers/BreakpointPopoverController.js:
+        (WI.BreakpointPopoverController.prototype._createPopoverContent):
+        * UserInterface/Controllers/CSSManager.js:
+        (WI.CSSManager):
+        (WI.CSSManager.prototype._mainResourceDidChange):
+        * UserInterface/Controllers/TimelineManager.js:
+        (WI.TimelineManager.prototype._attemptAutoCapturingForFrame):
+        (WI.TimelineManager.prototype._updateAutoCaptureInstruments):
+        (WI.TimelineManager):
+        * UserInterface/Models/Canvas.js:
+        (WI.Canvas.prototype.startRecording):
+        (WI.Canvas.prototype.recordingFinished):
+        * UserInterface/Models/ScriptSyntaxTree.js:
+        (WI.ScriptSyntaxTree.functionReturnDivot):
+        * UserInterface/Protocol/DebuggerObserver.js:
+        (WI.DebuggerObserver):
+        * UserInterface/Protocol/NetworkObserver.js:
+        (WI.NetworkObserver.prototype.requestWillBeSent):
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WI.DebuggerSidebarPanel):
+        (WI.DebuggerSidebarPanel.prototype._handleCreateBreakpointClicked):
+        * UserInterface/Views/NetworkTimelineView.js:
+        (WI.NetworkTimelineView):
+        * UserInterface/Views/ResourceDetailsSidebarPanel.js:
+        (WI.ResourceDetailsSidebarPanel.prototype._refreshRequestAndResponse):
+        * UserInterface/Views/WebSocketContentView.js:
+        (WI.WebSocketContentView):
+        (WI.NetworkManager.prototype.webSocketWillSendHandshakeRequest):
+        (WI.DebuggerManager.prototype.debuggerDidResume):
+        Feature check in a target agnostic way.
+
 2018-11-08  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: ResourceQueryController should early return when query is longer than search string
index a86585e..eae67aa 100644 (file)
@@ -173,7 +173,7 @@ WI.BreakpointPopoverController = class BreakpointPopoverController extends WI.Ob
         // COMPATIBILITY (iOS 9): Legacy backends don't support breakpoint ignore count. Since support
         // can't be tested directly, check for CSS.getSupportedSystemFontFamilyNames.
         // FIXME: Use explicit version checking once https://webkit.org/b/148680 is fixed.
-        if (CSSAgent.getSupportedSystemFontFamilyNames) {
+        if (InspectorBackend.domains.CSS.getSupportedSystemFontFamilyNames) {
             let ignoreCountRow = table.appendChild(document.createElement("tr"));
             let ignoreCountHeader = ignoreCountRow.appendChild(document.createElement("th"));
             let ignoreCountLabel = ignoreCountHeader.appendChild(document.createElement("label"));
index b28b442..489067b 100644 (file)
@@ -48,7 +48,7 @@ WI.CSSManager = class CSSManager extends WI.Object
 
         // COMPATIBILITY (iOS 9): Legacy backends did not send stylesheet
         // added/removed events and must be fetched manually.
-        this._fetchedInitialStyleSheets = window.CSSAgent && window.CSSAgent.hasEvent("styleSheetAdded");
+        this._fetchedInitialStyleSheets = InspectorBackend.domains.CSS.hasEvent("styleSheetAdded");
     }
 
     // Target
@@ -363,7 +363,7 @@ WI.CSSManager = class CSSManager extends WI.Object
 
         // Clear our maps when the main frame navigates.
 
-        this._fetchedInitialStyleSheets = window.CSSAgent && window.CSSAgent.hasEvent("styleSheetAdded");
+        this._fetchedInitialStyleSheets = InspectorBackend.domains.CSS.hasEvent("styleSheetAdded");
         this._styleSheetIdentifierMap.clear();
         this._styleSheetFrameURLMap.clear();
         this._nodeStylesMap = {};
index a5c3faf..e994556 100644 (file)
@@ -118,15 +118,15 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         target.DebuggerAgent.setPauseOnExceptions(this._breakOnExceptionsState);
 
         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
-        if (DebuggerAgent.setPauseOnAssertions)
+        if (target.DebuggerAgent.setPauseOnAssertions)
             target.DebuggerAgent.setPauseOnAssertions(this._assertionFailuresBreakpointEnabledSetting.value);
 
         // COMPATIBILITY (iOS 10): Debugger.setAsyncStackTraceDepth did not exist yet.
-        if (DebuggerAgent.setAsyncStackTraceDepth)
+        if (target.DebuggerAgent.setAsyncStackTraceDepth)
             target.DebuggerAgent.setAsyncStackTraceDepth(this._asyncStackTraceDepthSetting.value);
 
         // COMPATIBILITY (iOS 12): DebuggerAgent.setPauseForInternalScripts did not exist yet.
-        if (DebuggerAgent.setPauseForInternalScripts)
+        if (target.DebuggerAgent.setPauseForInternalScripts)
             target.DebuggerAgent.setPauseForInternalScripts(WI.settings.pauseForInternalScripts.value);
 
         if (this.paused)
@@ -689,7 +689,7 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         // 50ms, and treat it as a real resume if we haven't paused in that time frame.
         // This delay ensures the user interface does not flash between brief steps
         // or successive breakpoints.
-        if (!DebuggerAgent.setPauseOnAssertions) {
+        if (!target.DebuggerAgent.setPauseOnAssertions) {
             this._delayedResumeTimeout = setTimeout(this._didResumeInternal.bind(this, target), 50);
             return;
         }
@@ -1156,11 +1156,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
     _pauseForInternalScriptsDidChange(event)
     {
-        // COMPATIBILITY (iOS 12): DebuggerAgent.setPauseForInternalScripts did not exist yet.
-        console.assert(DebuggerAgent.setPauseForInternalScripts);
-
-        for (let target of WI.targets)
-            target.DebuggerAgent.setPauseForInternalScripts(WI.settings.pauseForInternalScripts.value);
+        for (let target of WI.targets) {
+            if (target.DebuggerAgent.setPauseForInternalScripts)
+                target.DebuggerAgent.setPauseForInternalScripts(WI.settings.pauseForInternalScripts.value);
+        }
     }
 
     _mainResourceDidChange(event)
index d6ceea9..94d89c7 100644 (file)
@@ -62,10 +62,8 @@ WI.NetworkManager = class NetworkManager extends WI.Object
             target.NetworkAgent.enable();
 
             // COMPATIBILITY (iOS 10.3): Network.setDisableResourceCaching did not exist.
-            if (NetworkAgent.setResourceCachingDisabled) {
-                if (WI.settings.resourceCachingDisabled && WI.settings.resourceCachingDisabled.value)
-                    target.NetworkAgent.setResourceCachingDisabled(true);
-            }
+            if (target.NetworkAgent.setResourceCachingDisabled)
+                target.NetworkAgent.setResourceCachingDisabled(WI.settings.resourceCachingDisabled.value);
         }
 
         if (target.type === WI.Target.Type.Worker)
@@ -296,7 +294,7 @@ WI.NetworkManager = class NetworkManager extends WI.Object
             return;
 
         // COMPATIBILITY(iOS 10.3): `walltime` did not exist in 10.3 and earlier.
-        if (!NetworkAgent.hasEventParameter("webSocketWillSendHandshakeRequest", "walltime")) {
+        if (!InspectorBackend.domains.Network.hasEventParameter("webSocketWillSendHandshakeRequest", "walltime")) {
             request = arguments[2];
             walltime = NaN;
         }
index 59df15d..47c6558 100644 (file)
@@ -41,11 +41,11 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object
         target.RuntimeAgent.enable();
 
         // COMPATIBILITY (iOS 8): Runtime.enableTypeProfiler did not exist.
-        if (WI.settings.showJavaScriptTypeInformation && WI.settings.showJavaScriptTypeInformation.value && RuntimeAgent.enableTypeProfiler)
+        if (target.RuntimeAgent.enableTypeProfiler && WI.settings.showJavaScriptTypeInformation.value)
             target.RuntimeAgent.enableTypeProfiler();
 
         // COMPATIBILITY (iOS 10): Runtime.enableControlFlowProfiler did not exist
-        if (WI.settings.enableControlFlowProfiler && WI.settings.enableControlFlowProfiler.value && RuntimeAgent.enableControlFlowProfiler)
+        if (target.RuntimeAgent.enableControlFlowProfiler && WI.settings.enableControlFlowProfiler.value)
             target.RuntimeAgent.enableControlFlowProfiler();
     }
 
@@ -131,8 +131,11 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object
     {
         console.assert(remoteObject instanceof WI.RemoteObject);
 
+        let target = this._activeExecutionContext.target;
+        let executionContextId = this._activeExecutionContext.id;
+
         // COMPATIBILITY (iOS 8): Runtime.saveResult did not exist.
-        if (!RuntimeAgent.saveResult) {
+        if (!target.RuntimeAgent.saveResult) {
             callback(undefined);
             return;
         }
@@ -142,9 +145,6 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object
             callback(savedResultIndex);
         }
 
-        let target = this._activeExecutionContext.target;
-        let executionContextId = this._activeExecutionContext.id;
-
         if (remoteObject.objectId)
             target.RuntimeAgent.saveResult(remoteObject.asCallArgument(), mycallback);
         else
index 9eae45b..328cd3e 100644 (file)
@@ -723,6 +723,8 @@ WI.TimelineManager = class TimelineManager extends WI.Object
 
         // COMPATIBILITY (iOS 9): Timeline.setAutoCaptureEnabled did not exist.
         // Perform auto capture in the frontend.
+        if (!window.TimelineAgent)
+            return false;
         if (!TimelineAgent.setAutoCaptureEnabled)
             return this._legacyAttemptStartAutoCapturingForFrame(frame);
 
@@ -1062,34 +1064,35 @@ WI.TimelineManager = class TimelineManager extends WI.Object
 
     _updateAutoCaptureInstruments(targets)
     {
-        if (!TimelineAgent.setInstruments)
-            return;
-
-        let instrumentSet = new Set;
         let enabledTimelineTypes = this._enabledTimelineTypesSetting.value;
 
-        for (let timelineType of enabledTimelineTypes) {
-            switch (timelineType) {
-            case WI.TimelineRecord.Type.Script:
-                instrumentSet.add(TimelineAgent.Instrument.ScriptProfiler);
-                break;
-            case WI.TimelineRecord.Type.HeapAllocations:
-                instrumentSet.add(TimelineAgent.Instrument.Heap);
-                break;
-            case WI.TimelineRecord.Type.Network:
-            case WI.TimelineRecord.Type.RenderingFrame:
-            case WI.TimelineRecord.Type.Layout:
-                instrumentSet.add(TimelineAgent.Instrument.Timeline);
-                break;
-            case WI.TimelineRecord.Type.Memory:
-                instrumentSet.add(TimelineAgent.Instrument.Memory);
-                break;
+        for (let target of targets) {
+            if (!target.TimelineAgent)
+                continue;
+            if (!target.TimelineAgent.setInstruments)
+                continue;
+
+            let instrumentSet = new Set;
+            for (let timelineType of enabledTimelineTypes) {
+                switch (timelineType) {
+                case WI.TimelineRecord.Type.Script:
+                    instrumentSet.add(target.TimelineAgent.Instrument.ScriptProfiler);
+                    break;
+                case WI.TimelineRecord.Type.HeapAllocations:
+                    instrumentSet.add(target.TimelineAgent.Instrument.Heap);
+                    break;
+                case WI.TimelineRecord.Type.Network:
+                case WI.TimelineRecord.Type.RenderingFrame:
+                case WI.TimelineRecord.Type.Layout:
+                    instrumentSet.add(target.TimelineAgent.Instrument.Timeline);
+                    break;
+                case WI.TimelineRecord.Type.Memory:
+                    instrumentSet.add(target.TimelineAgent.Instrument.Memory);
+                    break;
+                }
             }
-        }
 
-        for (let target of targets) {
-            if (target.TimelineAgent)
-                target.TimelineAgent.setInstruments([...instrumentSet]);
+            target.TimelineAgent.setInstruments(Array.from(instrumentSet));
         }
     }
 };
index 05fb4fd..09d6104 100644 (file)
@@ -167,7 +167,7 @@ WI.CSSCompletions = class CSSCompletions
         target.CSSAgent.getSupportedCSSProperties(propertyNamesCallback);
 
         // COMPATIBILITY (iOS 9): CSS.getSupportedSystemFontFamilyNames did not exist.
-        if (CSSAgent.getSupportedSystemFontFamilyNames)
+        if (target.CSSAgent.getSupportedSystemFontFamilyNames)
             target.CSSAgent.getSupportedSystemFontFamilyNames(fontFamilyNamesCallback);
     }
 
index 56c261c..fefc112 100644 (file)
@@ -279,7 +279,7 @@ WI.Canvas = class Canvas extends WI.Object
             this._recordingState = WI.Canvas.RecordingState.ActiveFrontend;
 
             // COMPATIBILITY (iOS 12.1): Canvas.event.recordingStarted did not exist yet
-            if (CanvasAgent.hasEvent("recordingStarted"))
+            if (InspectorBackend.domains.Canvas.hasEvent("recordingStarted"))
                 return;
 
             this._recordingFrames = [];
@@ -289,7 +289,7 @@ WI.Canvas = class Canvas extends WI.Object
         };
 
         // COMPATIBILITY (iOS 12.1): `frameCount` did not exist yet.
-        if (CanvasAgent.startRecording.supports("singleFrame")) {
+        if (InspectorBackend.domains.Canvas.startRecording.supports("singleFrame")) {
             CanvasAgent.startRecording(this._identifier, singleFrame, handleStartRecording);
             return;
         }
@@ -376,7 +376,7 @@ WI.Canvas = class Canvas extends WI.Object
         let initiatedByUser = this._recordingState === WI.Canvas.RecordingState.ActiveFrontend;
 
         // COMPATIBILITY (iOS 12.1): Canvas.event.recordingStarted did not exist yet
-        if (!initiatedByUser && !CanvasAgent.hasEvent("recordingStarted"))
+        if (!initiatedByUser && !InspectorBackend.domains.Canvas.hasEvent("recordingStarted"))
             initiatedByUser = !!this.recordingActive;
 
         let recording = recordingPayload ? WI.Recording.fromPayload(recordingPayload, this._recordingFrames) : null;
index 8b77c3a..a31eec5 100644 (file)
@@ -174,9 +174,8 @@ WI.ScriptSyntaxTree = class ScriptSyntaxTree
 
         // COMPATIBILITY (iOS 9): Legacy Backends view the return type as being the opening "{" of the function body.
         // After iOS 9, this is to move to the start of the function statement/expression. See below:
-        // FIXME: Need a better way to determine backend versions. Using DOM.pseudoElement because that was added after iOS 9.
-        // FIXME: This wouldn't work for debugging an iOS 9 or earlier JSContext target.
-        if (window.DOMAgent && !DOMAgent.hasEvent("pseudoElementAdded"))
+        // Using DOM.pseudoElement because that was added after iOS 9.
+        if (!InspectorBackend.domains.DOM.hasEvent("pseudoElementAdded"))
             return node.body.range[0];
 
         // "f" in "function". "s" in "set". "g" in "get". First letter in any method name for classes and object literals.
@@ -186,7 +185,7 @@ WI.ScriptSyntaxTree = class ScriptSyntaxTree
 
     updateTypes(nodesToUpdate, callback)
     {
-        console.assert(RuntimeAgent.getRuntimeTypesForVariablesAtOffsets);
+        console.assert(this._script.target.RuntimeAgent.getRuntimeTypesForVariablesAtOffsets);
         console.assert(Array.isArray(nodesToUpdate) && this._parsedSuccessfully);
 
         if (!this._parsedSuccessfully)
index 6002738..3f5bc8b 100644 (file)
@@ -27,7 +27,7 @@ WI.DebuggerObserver = class DebuggerObserver
 {
     constructor()
     {
-        this._legacyScriptParsed = DebuggerAgent.hasEventParameter("scriptParsed", "hasSourceURL");
+        this._legacyScriptParsed = InspectorBackend.domains.Debugger.hasEventParameter("scriptParsed", "hasSourceURL");
     }
 
     // Events defined by the "Debugger" domain.
index 79ca8ed..49ec9b7 100644 (file)
@@ -58,6 +58,13 @@ InspectorBackendClass = class InspectorBackendClass
 
     // Public
 
+    // This should be used for feature checking if something exists in the protocol
+    // regardless of whether or not the domain is active for a specific target.
+    get domains()
+    {
+        return this._agents;
+    }
+
     // It's still possible to set this flag on InspectorBackend to just
     // dump protocol traffic as it happens. For more complex uses of
     // protocol data, install a subclass of WI.ProtocolTracer.
@@ -165,6 +172,10 @@ InspectorBackendClass = class InspectorBackendClass
         for (let debuggableType of supportedDebuggableTypes)
             this._supportedDomainsForDebuggableType.get(debuggableType).push(domainName);
 
+        // FIXME: For proper multi-target support we should eliminate all uses of
+        // `window.FooAgent` and `unprefixed FooAgent` in favor of either:
+        //   - Per-target: `target.FooAgent`
+        //   - Global feature check: `InspectorBackend.domains.Foo`
         if (!activationDebuggableTypes || activationDebuggableTypes.includes(InspectorFrontendHost.debuggableType())) {
             let agent = this._agents[domainName];
             agent.activate();
index a3c8696..e927888 100644 (file)
@@ -30,7 +30,7 @@ WI.NetworkObserver = class NetworkObserver
     requestWillBeSent(requestId, frameId, loaderId, documentURL, request, timestamp, walltime, initiator, redirectResponse, type, targetId)
     {
         // COMPATIBILITY(iOS 11.0): `walltime` did not exist in 11.0 and earlier.
-        if (!NetworkAgent.hasEventParameter("requestWillBeSent", "walltime")) {
+        if (!InspectorBackend.domains.Network.hasEventParameter("requestWillBeSent", "walltime")) {
             walltime = undefined;
             initiator = arguments[6];
             redirectResponse = arguments[7];
index 1c8dac7..160cc7e 100644 (file)
@@ -245,7 +245,7 @@ WI.RemoteObject = class RemoteObject
             return;
         }
 
-        if (!RuntimeAgent.getPreview) {
+        if (!this._target.RuntimeAgent.getPreview) {
             this._failedToLoadPreview = true;
             callback(null);
             return;
@@ -282,7 +282,7 @@ WI.RemoteObject = class RemoteObject
 
         // COMPATIBILITY (iOS 8): RuntimeAgent.getDisplayableProperties did not exist.
         // Here we do our best to reimplement it by getting all properties and reducing them down.
-        if (!RuntimeAgent.getDisplayableProperties) {
+        if (!this._target.RuntimeAgent.getDisplayableProperties) {
             this._target.RuntimeAgent.getProperties(this._objectId, function(error, allProperties) {
                 var ownOrGetterPropertiesList = [];
                 if (allProperties) {
@@ -329,7 +329,7 @@ WI.RemoteObject = class RemoteObject
 
         // COMPATIBILITY (iOS 8): RuntimeAgent.getProperties did not support ownerAndGetterProperties.
         // Here we do our best to reimplement it by getting all properties and reducing them down.
-        if (!RuntimeAgent.getDisplayableProperties) {
+        if (!this._target.RuntimeAgent.getDisplayableProperties) {
             this._target.RuntimeAgent.getProperties(this._objectId, function(error, allProperties) {
                 var ownOrGetterPropertiesList = [];
                 if (allProperties) {
index bd9e968..3382c63 100644 (file)
@@ -72,7 +72,7 @@ WI.Target = class Target extends WI.Object
         // Non-manager specific initialization.
         // COMPATIBILITY (iOS 8): Page.setShowPaintRects did not exist.
         if (this.PageAgent) {
-            if (PageAgent.setShowPaintRects && WI.settings.showPaintRects.value)
+            if (this.PageAgent.setShowPaintRects && WI.settings.showPaintRects.value)
                 this.PageAgent.setShowPaintRects(true);
         }
 
@@ -92,7 +92,7 @@ WI.Target = class Target extends WI.Object
             // This allows an automatically paused backend to resume execution, but we want to ensure
             // our breakpoints were already sent to that backend.
             // COMPATIBILITY (iOS 8): Inspector.initialized did not exist yet.
-            if (this.InspectorAgent && InspectorAgent.initialized)
+            if (this.InspectorAgent && this.InspectorAgent.initialized)
                 this.InspectorAgent.initialized();
         });
     }
index 93aa08a..86e260a 100644 (file)
@@ -31,7 +31,6 @@ WI.BreakpointActionView = class BreakpointActionView extends WI.Object
 
         console.assert(action);
         console.assert(delegate);
-        console.assert(DebuggerAgent.BreakpointActionType);
 
         this._action = action;
         this._delegate = delegate;
index 0500f51..d366a76 100644 (file)
@@ -168,16 +168,14 @@ WI.appendContextMenuItemsForDOMNode = function(contextMenu, domNode, options = {
                 });
             }
 
-            function didGetProperty(error, result, wasThrown) {
-                if (error || result.type !== "function")
-                    return;
-
-                DebuggerAgent.getFunctionDetails(result.objectId, didGetFunctionDetails);
-                result.release();
-            }
-
             WI.RemoteObject.resolveNode(domNode).then((remoteObject) => {
-                remoteObject.getProperty("constructor", didGetProperty);
+                remoteObject.getProperty("constructor", (error, result, wasThrown) => {
+                    if (error)
+                        return;
+                    if (result.type === "function")
+                        remoteObject.target.DebuggerAgent.getFunctionDetails(result.objectId, didGetFunctionDetails);
+                    result.release();
+                });
                 remoteObject.release();
             });
         });
index 15292f2..2dd9194 100644 (file)
@@ -101,7 +101,7 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView
         let items = [this._showPrintStylesButtonNavigationItem, this._showsShadowDOMButtonNavigationItem];
 
         // COMPATIBILITY (iOS 11.3)
-        if (PageAgent.setShowRulers)
+        if (window.PageAgent && PageAgent.setShowRulers)
             items.unshift(this._showRulersButtonNavigationItem);
 
         if (!WI.settings.experimentalEnableLayersTab.value)
index 4380dcf..fdbe8b8 100644 (file)
@@ -212,7 +212,7 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba
         WI.debuggerManager.addBreakpoint(WI.debuggerManager.uncaughtExceptionsBreakpoint);
 
         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
-        if (DebuggerAgent.setPauseOnAssertions && WI.settings.showAssertionFailuresBreakpoint.value)
+        if (InspectorBackend.domains.Debugger.setPauseOnAssertions && WI.settings.showAssertionFailuresBreakpoint.value)
             WI.debuggerManager.addBreakpoint(WI.debuggerManager.assertionFailuresBreakpoint);
 
         if (WI.networkManager.mainFrame)
@@ -1377,7 +1377,7 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba
         let contextMenu = WI.ContextMenu.createFromEvent(event.data.nativeEvent);
 
         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
-        if (DebuggerAgent.setPauseOnAssertions) {
+        if (InspectorBackend.domains.Debugger.setPauseOnAssertions) {
             let assertionFailuresBreakpointShown = WI.settings.showAssertionFailuresBreakpoint.value;
 
             contextMenu.appendCheckboxItem(WI.UIString("Assertion Failures"), () => {
index 1372ff1..6480818 100644 (file)
@@ -128,7 +128,7 @@ WI.LogContentView = class LogContentView extends WI.ContentView
         if (this._hasNonDefaultLogChannelMessage && this._messageSourceBar)
             navigationItems.push(this._messageSourceBar, new WI.DividerNavigationItem);
 
-        if (HeapAgent.gc)
+        if (window.HeapAgent && HeapAgent.gc)
             navigationItems.push(this._garbageCollectNavigationItem);
 
         navigationItems.push(this._clearLogNavigationItem);
index 2bce76e..f65a495 100644 (file)
@@ -114,7 +114,7 @@ WI.NetworkTimelineView = class NetworkTimelineView extends WI.TimelineView
         columns.graph.sortable = false;
 
         // COMPATIBILITY(iOS 10.3): Network load metrics were not previously available.
-        if (!NetworkAgent.hasEventParameter("loadingFinished", "metrics")) {
+        if (!InspectorBackend.domains.Network.hasEventParameter("loadingFinished", "metrics")) {
             delete columns.protocol;
             delete columns.priority;
             delete columns.remoteAddress;
index c7fdd8a..d6aecf4 100644 (file)
@@ -356,7 +356,7 @@ WI.ResourceDetailsSidebarPanel = class ResourceDetailsSidebarPanel extends WI.De
         this._requestMethodRow.value = this._resource.requestMethod || emDash;
 
         // COMPATIBILITY(iOS 10.3): Network load metrics were not previously available.
-        if (window.NetworkAgent && NetworkAgent.hasEventParameter("loadingFinished", "metrics")) {
+        if (InspectorBackend.domains.Network.hasEventParameter("loadingFinished", "metrics")) {
             let protocolDisplayName = WI.Resource.displayNameForProtocol(this._resource.protocol);
             this._protocolRow.value = protocolDisplayName || emDash;
             this._protocolRow.tooltip = protocolDisplayName ? this._resource.protocol : "";
index 54b2a9e..287cd76 100644 (file)
@@ -225,7 +225,10 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
             for (let channel of channels) {
                 let logEditor = generalSettingsView.addGroupWithCustomSetting(editorLabels[channel.source], WI.SettingEditor.Type.Select, {values: logLevels});
                 logEditor.value = channel.level;
-                logEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => { ConsoleAgent.setLoggingChannelLevel(channel.source, logEditor.value); });
+                logEditor.addEventListener(WI.SettingEditor.Event.ValueDidChange, () => {
+                    for (let target of WI.targets)
+                        target.ConsoleAgent.setLoggingChannelLevel(channel.source, logEditor.value);
+                });
             }
         }
 
index 87dec9a..f36dd06 100644 (file)
@@ -2154,7 +2154,7 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
     _createTypeTokenAnnotator()
     {
         // COMPATIBILITY (iOS 8): Runtime.getRuntimeTypesForVariablesAtOffsets did not exist yet.
-        if (!RuntimeAgent.getRuntimeTypesForVariablesAtOffsets)
+        if (!this.target.RuntimeAgent.getRuntimeTypesForVariablesAtOffsets)
             return;
 
         var script = this._getAssociatedScript();
@@ -2167,7 +2167,7 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
     _createBasicBlockAnnotator()
     {
         // COMPATIBILITY (iOS 8): Runtime.getBasicBlocks did not exist yet.
-        if (!RuntimeAgent.getBasicBlocks)
+        if (!this.target.RuntimeAgent.getBasicBlocks)
             return;
 
         var script = this._getAssociatedScript();
index 9dec168..3bf0d64 100644 (file)
@@ -36,7 +36,7 @@ WI.WebSocketContentView = class WebSocketContentView extends WI.ContentView
         this._lastRenderedReadyState = null;
 
         // COMPATIBILITY (iOS 10.3): `walltime` did not exist in 10.3 and earlier.
-        this._showTimeColumn = NetworkAgent.hasEventParameter("webSocketWillSendHandshakeRequest", "walltime");
+        this._showTimeColumn = InspectorBackend.domains.Network.hasEventParameter("webSocketWillSendHandshakeRequest", "walltime");
 
         this.element.classList.add("web-socket", "resource");