Follow-up review comment to r237652.
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Controllers / DebuggerManager.js
index 5ccfac8..a5c3faf 100644 (file)
@@ -29,8 +29,6 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
     {
         super();
 
-        DebuggerAgent.enable();
-
         WI.notifications.addEventListener(WI.Notification.DebugUIEnabledDidChange, this._debugUIEnabledDidChange, this);
 
         WI.Breakpoint.addEventListener(WI.Breakpoint.Event.DisplayLocationDidChange, this._breakpointDisplayLocationDidChange, this);
@@ -38,20 +36,22 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         WI.Breakpoint.addEventListener(WI.Breakpoint.Event.ConditionDidChange, this._breakpointEditablePropertyDidChange, this);
         WI.Breakpoint.addEventListener(WI.Breakpoint.Event.IgnoreCountDidChange, this._breakpointEditablePropertyDidChange, this);
         WI.Breakpoint.addEventListener(WI.Breakpoint.Event.AutoContinueDidChange, this._breakpointEditablePropertyDidChange, this);
-        WI.Breakpoint.addEventListener(WI.Breakpoint.Event.ActionsDidChange, this._breakpointEditablePropertyDidChange, this);
+        WI.Breakpoint.addEventListener(WI.Breakpoint.Event.ActionsDidChange, this._handleBreakpointActionsDidChange, this);
 
         WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._timelineCapturingWillStart, this);
         WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._timelineCapturingStopped, this);
 
         WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, this._targetRemoved, this);
 
+        WI.settings.pauseForInternalScripts.addEventListener(WI.Setting.Event.Changed, this._pauseForInternalScriptsDidChange, this);
+
         WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
 
         this._breakpointsSetting = new WI.Setting("breakpoints", []);
         this._breakpointsEnabledSetting = new WI.Setting("breakpoints-enabled", true);
         this._allExceptionsBreakpointEnabledSetting = new WI.Setting("break-on-all-exceptions", false);
-        this._allUncaughtExceptionsBreakpointEnabledSetting = new WI.Setting("break-on-all-uncaught-exceptions", false);
-        this._assertionsBreakpointEnabledSetting = new WI.Setting("break-on-assertions", false);
+        this._uncaughtExceptionsBreakpointEnabledSetting = new WI.Setting("break-on-uncaught-exceptions", false);
+        this._assertionFailuresBreakpointEnabledSetting = new WI.Setting("break-on-assertion-failures", false);
         this._asyncStackTraceDepthSetting = new WI.Setting("async-stack-trace-depth", 200);
 
         let specialBreakpointLocation = new WI.SourceCodeLocation(null, Infinity, Infinity);
@@ -59,10 +59,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         this._allExceptionsBreakpoint = new WI.Breakpoint(specialBreakpointLocation, !this._allExceptionsBreakpointEnabledSetting.value);
         this._allExceptionsBreakpoint.resolved = true;
 
-        this._allUncaughtExceptionsBreakpoint = new WI.Breakpoint(specialBreakpointLocation, !this._allUncaughtExceptionsBreakpointEnabledSetting.value);
+        this._uncaughtExceptionsBreakpoint = new WI.Breakpoint(specialBreakpointLocation, !this._uncaughtExceptionsBreakpointEnabledSetting.value);
 
-        this._assertionsBreakpoint = new WI.Breakpoint(specialBreakpointLocation, !this._assertionsBreakpointEnabledSetting.value);
-        this._assertionsBreakpoint.resolved = true;
+        this._assertionFailuresBreakpoint = new WI.Breakpoint(specialBreakpointLocation, !this._assertionFailuresBreakpointEnabledSetting.value);
+        this._assertionFailuresBreakpoint.resolved = true;
 
         this._breakpoints = [];
         this._breakpointContentIdentifierMap = new Map;
@@ -78,7 +78,13 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         this._internalWebKitScripts = [];
         this._targetDebuggerDataMap = new Map;
-        this._targetDebuggerDataMap.set(WI.mainTarget, new WI.DebuggerData(WI.mainTarget));
+
+        // Used to detect deleted probe actions.
+        this._knownProbeIdentifiersForBreakpoint = new Map;
+
+        // Main lookup tables for probes and probe sets.
+        this._probesByIdentifier = new Map;
+        this._probeSetsByBreakpoint = new Map;
 
         // Restore the correct breakpoints enabled setting if Web Inspector had
         // previously been left in a state where breakpoints were temporarily disabled.
@@ -88,29 +94,54 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
             this._temporarilyDisabledBreakpointsRestoreSetting.value = null;
         }
 
-        DebuggerAgent.setBreakpointsActive(this._breakpointsEnabledSetting.value);
-        DebuggerAgent.setPauseOnExceptions(this._breakOnExceptionsState);
+        this._ignoreBreakpointDisplayLocationDidChangeEvent = false;
+
+        // Ensure that all managers learn about restored breakpoints,
+        // regardless of their initialization order.
+        setTimeout(() => {
+            this._restoringBreakpoints = true;
+            for (let cookie of this._breakpointsSetting.value)
+                this.addBreakpoint(new WI.Breakpoint(cookie));
+            this._restoringBreakpoints = false;
+        });
+    }
+
+    // Target
+
+    initializeTarget(target)
+    {
+        let targetData = this.dataForTarget(target);
+
+        // Initialize global state.
+        target.DebuggerAgent.enable();
+        target.DebuggerAgent.setBreakpointsActive(this._breakpointsEnabledSetting.value);
+        target.DebuggerAgent.setPauseOnExceptions(this._breakOnExceptionsState);
 
         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
         if (DebuggerAgent.setPauseOnAssertions)
-            DebuggerAgent.setPauseOnAssertions(this._assertionsBreakpointEnabledSetting.value);
+            target.DebuggerAgent.setPauseOnAssertions(this._assertionFailuresBreakpointEnabledSetting.value);
 
         // COMPATIBILITY (iOS 10): Debugger.setAsyncStackTraceDepth did not exist yet.
         if (DebuggerAgent.setAsyncStackTraceDepth)
-            DebuggerAgent.setAsyncStackTraceDepth(this._asyncStackTraceDepthSetting.value);
+            target.DebuggerAgent.setAsyncStackTraceDepth(this._asyncStackTraceDepthSetting.value);
 
-        this._ignoreBreakpointDisplayLocationDidChangeEvent = false;
+        // COMPATIBILITY (iOS 12): DebuggerAgent.setPauseForInternalScripts did not exist yet.
+        if (DebuggerAgent.setPauseForInternalScripts)
+            target.DebuggerAgent.setPauseForInternalScripts(WI.settings.pauseForInternalScripts.value);
 
-        function restoreBreakpointsSoon() {
-            this._restoringBreakpoints = true;
-            for (let cookie of this._breakpointsSetting.value)
-                this.addBreakpoint(new WI.Breakpoint(cookie));
-            this._restoringBreakpoints = false;
-        }
+        if (this.paused)
+            targetData.pauseIfNeeded();
 
-        // Ensure that all managers learn about restored breakpoints,
-        // regardless of their initialization order.
-        setTimeout(restoreBreakpointsSoon.bind(this), 0);
+        // Initialize breakpoints.
+        this._restoringBreakpoints = true;
+        for (let breakpoint of this._breakpoints) {
+            if (breakpoint.disabled)
+                continue;
+            if (!breakpoint.contentIdentifier)
+                continue;
+            this._setBreakpoint(breakpoint, target);
+        }
+        this._restoringBreakpoints = false;
     }
 
     // Public
@@ -151,25 +182,10 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         return targetData;
     }
 
-    get allExceptionsBreakpoint()
-    {
-        return this._allExceptionsBreakpoint;
-    }
-
-    get allUncaughtExceptionsBreakpoint()
-    {
-        return this._allUncaughtExceptionsBreakpoint;
-    }
-
-    get assertionsBreakpoint()
-    {
-        return this._assertionsBreakpoint;
-    }
-
-    get breakpoints()
-    {
-        return this._breakpoints;
-    }
+    get allExceptionsBreakpoint() { return this._allExceptionsBreakpoint; }
+    get uncaughtExceptionsBreakpoint() { return this._uncaughtExceptionsBreakpoint; }
+    get assertionFailuresBreakpoint() { return this._assertionFailuresBreakpoint; }
+    get breakpoints() { return this._breakpoints; }
 
     breakpointForIdentifier(id)
     {
@@ -219,13 +235,18 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
     isBreakpointRemovable(breakpoint)
     {
         return breakpoint !== this._allExceptionsBreakpoint
-            && breakpoint !== this._allUncaughtExceptionsBreakpoint
-            && breakpoint !== this._assertionsBreakpoint;
+            && breakpoint !== this._uncaughtExceptionsBreakpoint;
+    }
+
+    isBreakpointSpecial(breakpoint)
+    {
+        return !this.isBreakpointRemovable(breakpoint)
+            || breakpoint === this._assertionFailuresBreakpoint;
     }
 
     isBreakpointEditable(breakpoint)
     {
-        return this.isBreakpointRemovable(breakpoint);
+        return !this.isBreakpointSpecial(breakpoint);
     }
 
     get breakpointsEnabled()
@@ -312,6 +333,16 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
             target.DebuggerAgent.setAsyncStackTraceDepth(this._asyncStackTraceDepthSetting.value);
     }
 
+    get probeSets()
+    {
+        return [...this._probeSetsByBreakpoint.values()];
+    }
+
+    probeForIdentifier(identifier)
+    {
+        return this._probesByIdentifier.get(identifier);
+    }
+
     pause()
     {
         if (this.paused)
@@ -429,6 +460,11 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!breakpoint)
             return;
 
+        if (this.isBreakpointSpecial(breakpoint)) {
+            this.dispatchEventToListeners(WI.DebuggerManager.Event.BreakpointAdded, {breakpoint});
+            return;
+        }
+
         if (breakpoint.contentIdentifier) {
             let contentIdentifierBreakpoints = this._breakpointContentIdentifierMap.get(breakpoint.contentIdentifier);
             if (!contentIdentifierBreakpoints) {
@@ -459,6 +495,8 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         this._saveBreakpoints();
 
+        this._addProbesForBreakpoint(breakpoint);
+
         this.dispatchEventToListeners(WI.DebuggerManager.Event.BreakpointAdded, {breakpoint});
     }
 
@@ -472,6 +510,12 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (!this.isBreakpointRemovable(breakpoint))
             return;
 
+        if (this.isBreakpointSpecial(breakpoint)) {
+            breakpoint.disabled = true;
+            this.dispatchEventToListeners(WI.DebuggerManager.Event.BreakpointRemoved, {breakpoint});
+            return;
+        }
+
         this._breakpoints.remove(breakpoint);
 
         if (breakpoint.identifier)
@@ -501,6 +545,8 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         this._saveBreakpoints();
 
+        this._removeProbesForBreakpoint(breakpoint);
+
         this.dispatchEventToListeners(WI.DebuggerManager.Event.BreakpointRemoved, {breakpoint});
     }
 
@@ -509,33 +555,6 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         return this._nextBreakpointActionIdentifier++;
     }
 
-    initializeTarget(target)
-    {
-        let DebuggerAgent = target.DebuggerAgent;
-        let targetData = this.dataForTarget(target);
-
-        // Initialize global state.
-        DebuggerAgent.enable();
-        DebuggerAgent.setBreakpointsActive(this._breakpointsEnabledSetting.value);
-        DebuggerAgent.setPauseOnAssertions(this._assertionsBreakpointEnabledSetting.value);
-        DebuggerAgent.setPauseOnExceptions(this._breakOnExceptionsState);
-        DebuggerAgent.setAsyncStackTraceDepth(this._asyncStackTraceDepthSetting.value);
-
-        if (this.paused)
-            targetData.pauseIfNeeded();
-
-        // Initialize breakpoints.
-        this._restoringBreakpoints = true;
-        for (let breakpoint of this._breakpoints) {
-            if (breakpoint.disabled)
-                continue;
-            if (!breakpoint.contentIdentifier)
-                continue;
-            this._setBreakpoint(breakpoint, target);
-        }
-        this._restoringBreakpoints = false;
-    }
-
     // Protected (Called from WI.DebuggerObserver)
 
     breakpointResolved(target, breakpointIdentifier, location)
@@ -710,11 +729,18 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         targetData.addScript(script);
 
-        if (!target.mainResource && (target !== WI.mainResource || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker)) {
-            // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script
-            // We make the main resource of a WorkerTarget the Script instead of the Resource
-            // because the frontend may not be informed of the Resource. We should guarantee
-            // the frontend is informed of the Resource.
+        // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script
+        // We make the main resource of a WorkerTarget the Script instead of the Resource
+        // because the frontend may not be informed of the Resource. We should guarantee
+        // the frontend is informed of the Resource.
+        if (WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker) {
+            // A ServiceWorker starts with a LocalScript for the main resource but we can replace it during initialization.
+            if (target.mainResource instanceof WI.LocalScript) {
+                if (script.url === target.name)
+                    target.mainResource = script;
+            }
+        } else if (!target.mainResource && target !== WI.mainTarget) {
+            // A Worker starts without a main resource and we insert one.
             if (script.url === target.name) {
                 target.mainResource = script;
                 if (script.resource)
@@ -734,10 +760,19 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         this.dispatchEventToListeners(WI.DebuggerManager.Event.ScriptAdded, {script});
 
-        if (target !== WI.mainTarget && !script.isMainResource() && !script.resource)
+        if ((target !== WI.mainTarget || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker) && !script.isMainResource() && !script.resource)
             target.addScript(script);
     }
 
+    didSampleProbe(target, sample)
+    {
+        console.assert(this._probesByIdentifier.has(sample.probeId), "Unknown probe identifier specified for sample: ", sample);
+        let probe = this._probesByIdentifier.get(sample.probeId);
+        let elapsedTime = WI.timelineManager.computeElapsedTime(sample.timestamp);
+        let object = WI.RemoteObject.fromPayload(sample.payload, target);
+        probe.addSample(new WI.ProbeSample(sample.sampleId, sample.batchId, elapsedTime, object));
+    }
+
     // Private
 
     _sourceCodeLocationFromPayload(target, payload)
@@ -803,6 +838,8 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
     {
         // FIXME: Handle other backend pause reasons.
         switch (payload) {
+        case DebuggerAgent.PausedReason.AnimationFrame:
+            return WI.DebuggerManager.PauseReason.AnimationFrame;
         case DebuggerAgent.PausedReason.Assert:
             return WI.DebuggerManager.PauseReason.Assertion;
         case DebuggerAgent.PausedReason.Breakpoint:
@@ -813,10 +850,14 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
             return WI.DebuggerManager.PauseReason.DOM;
         case DebuggerAgent.PausedReason.DebuggerStatement:
             return WI.DebuggerManager.PauseReason.DebuggerStatement;
+        case DebuggerAgent.PausedReason.EventListener:
+            return WI.DebuggerManager.PauseReason.EventListener;
         case DebuggerAgent.PausedReason.Exception:
             return WI.DebuggerManager.PauseReason.Exception;
         case DebuggerAgent.PausedReason.PauseOnNextStatement:
             return WI.DebuggerManager.PauseReason.PauseOnNextStatement;
+        case DebuggerAgent.PausedReason.Timer:
+            return WI.DebuggerManager.PauseReason.Timer;
         case DebuggerAgent.PausedReason.XHR:
             return WI.DebuggerManager.PauseReason.XHR;
         default:
@@ -921,18 +962,12 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
 
         // Convert BreakpointAction types to DebuggerAgent protocol types.
         // NOTE: Breakpoint.options returns new objects each time, so it is safe to modify.
-        // COMPATIBILITY (iOS 7): Debugger.BreakpointActionType did not exist yet.
-        let options;
-        if (DebuggerAgent.BreakpointActionType) {
-            options = this._debuggerBreakpointOptions(breakpoint);
-            if (options.actions.length) {
-                for (let action of options.actions)
-                    action.type = this._debuggerBreakpointActionType(action.type);
-            }
+        let options = this._debuggerBreakpointOptions(breakpoint);
+        if (options.actions.length) {
+            for (let action of options.actions)
+                action.type = this._debuggerBreakpointActionType(action.type);
         }
 
-        // COMPATIBILITY (iOS 7): iOS 7 and earlier, DebuggerAgent.setBreakpoint* took a "condition" string argument.
-        // This has been replaced with an "options" BreakpointOptions object.
         if (breakpoint.contentIdentifier) {
             let targets = specificTarget ? [specificTarget] : WI.targets;
             for (let target of targets) {
@@ -941,7 +976,6 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
                     url: breakpoint.contentIdentifier,
                     urlRegex: undefined,
                     columnNumber: breakpoint.sourceCodeLocation.columnNumber,
-                    condition: breakpoint.condition,
                     options
                 }, didSetBreakpoint.bind(this, target), target.DebuggerAgent);
             }
@@ -949,7 +983,6 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
             let target = breakpoint.target;
             target.DebuggerAgent.setBreakpoint.invoke({
                 location: {scriptId: breakpoint.scriptIdentifier, lineNumber: breakpoint.sourceCodeLocation.lineNumber, columnNumber: breakpoint.sourceCodeLocation.columnNumber},
-                condition: breakpoint.condition,
                 options
             }, didSetBreakpoint.bind(this, target), target.DebuggerAgent);
         }
@@ -1021,22 +1054,22 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
             return;
         }
 
-        if (breakpoint === this._allUncaughtExceptionsBreakpoint) {
+        if (breakpoint === this._uncaughtExceptionsBreakpoint) {
             if (!breakpoint.disabled && !this.breakpointsDisabledTemporarily)
                 this.breakpointsEnabled = true;
-            this._allUncaughtExceptionsBreakpointEnabledSetting.value = !breakpoint.disabled;
+            this._uncaughtExceptionsBreakpointEnabledSetting.value = !breakpoint.disabled;
             this._updateBreakOnExceptionsState();
             for (let target of WI.targets)
                 target.DebuggerAgent.setPauseOnExceptions(this._breakOnExceptionsState);
             return;
         }
 
-        if (breakpoint === this._assertionsBreakpoint) {
+        if (breakpoint === this._assertionFailuresBreakpoint) {
             if (!breakpoint.disabled && !this.breakpointsDisabledTemporarily)
                 this.breakpointsEnabled = true;
-            this._assertionsBreakpointEnabledSetting.value = !breakpoint.disabled;
+            this._assertionFailuresBreakpointEnabledSetting.value = !breakpoint.disabled;
             for (let target of WI.targets)
-                target.DebuggerAgent.setPauseOnAssertions(this._assertionsBreakpointEnabledSetting.value);
+                target.DebuggerAgent.setPauseOnAssertions(this._assertionFailuresBreakpointEnabledSetting.value);
             return;
         }
 
@@ -1068,6 +1101,13 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         }
     }
 
+    _handleBreakpointActionsDidChange(event)
+    {
+        this._breakpointEditablePropertyDidChange(event);
+
+        this._updateProbesForBreakpoint(event.target);
+    }
+
     _startDisablingBreakpointsTemporarily()
     {
         console.assert(!this.breakpointsDisabledTemporarily, "Already temporarily disabling breakpoints.");
@@ -1114,6 +1154,15 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
             this.dispatchEventToListeners(WI.DebuggerManager.Event.Resumed);
     }
 
+    _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);
+    }
+
     _mainResourceDidChange(event)
     {
         if (!event.target.isMainFrame())
@@ -1156,7 +1205,7 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         if (this._breakpointsEnabledSetting.value) {
             if (!this._allExceptionsBreakpoint.disabled)
                 state = "all";
-            else if (!this._allUncaughtExceptionsBreakpoint.disabled)
+            else if (!this._uncaughtExceptionsBreakpoint.disabled)
                 state = "uncaught";
         }
 
@@ -1166,12 +1215,12 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         case "all":
             // Mark the uncaught breakpoint as unresolved since "all" includes "uncaught".
             // That way it is clear in the user interface that the breakpoint is ignored.
-            this._allUncaughtExceptionsBreakpoint.resolved = false;
+            this._uncaughtExceptionsBreakpoint.resolved = false;
             break;
         case "uncaught":
         case "none":
             // Mark the uncaught breakpoint as resolved again.
-            this._allUncaughtExceptionsBreakpoint.resolved = true;
+            this._uncaughtExceptionsBreakpoint.resolved = true;
             break;
         }
     }
@@ -1200,6 +1249,88 @@ WI.DebuggerManager = class DebuggerManager extends WI.Object
         this._ignoreBreakpointDisplayLocationDidChangeEvent = false;
     }
 
+    _addProbesForBreakpoint(breakpoint)
+    {
+        if (this._knownProbeIdentifiersForBreakpoint.has(breakpoint))
+            return;
+
+        this._knownProbeIdentifiersForBreakpoint.set(breakpoint, new Set);
+
+        this._updateProbesForBreakpoint(breakpoint);
+    }
+
+    _removeProbesForBreakpoint(breakpoint)
+    {
+        console.assert(this._knownProbeIdentifiersForBreakpoint.has(breakpoint));
+
+        this._updateProbesForBreakpoint(breakpoint);
+        this._knownProbeIdentifiersForBreakpoint.delete(breakpoint);
+    }
+
+    _updateProbesForBreakpoint(breakpoint)
+    {
+        let knownProbeIdentifiers = this._knownProbeIdentifiersForBreakpoint.get(breakpoint);
+        if (!knownProbeIdentifiers) {
+            // Sometimes actions change before the added breakpoint is fully dispatched.
+            this._addProbesForBreakpoint(breakpoint);
+            return;
+        }
+
+        let seenProbeIdentifiers = new Set;
+
+        for (let probeAction of breakpoint.probeActions) {
+            let probeIdentifier = probeAction.id;
+            console.assert(probeIdentifier, "Probe added without breakpoint action identifier: ", breakpoint);
+
+            seenProbeIdentifiers.add(probeIdentifier);
+            if (!knownProbeIdentifiers.has(probeIdentifier)) {
+                // New probe; find or create relevant probe set.
+                knownProbeIdentifiers.add(probeIdentifier);
+                let probeSet = this._probeSetForBreakpoint(breakpoint);
+                let newProbe = new WI.Probe(probeIdentifier, breakpoint, probeAction.data);
+                this._probesByIdentifier.set(probeIdentifier, newProbe);
+                probeSet.addProbe(newProbe);
+                break;
+            }
+
+            let probe = this._probesByIdentifier.get(probeIdentifier);
+            console.assert(probe, "Probe known but couldn't be found by identifier: ", probeIdentifier);
+            // Update probe expression; if it differed, change events will fire.
+            probe.expression = probeAction.data;
+        }
+
+        // Look for missing probes based on what we saw last.
+        for (let probeIdentifier of knownProbeIdentifiers) {
+            if (seenProbeIdentifiers.has(probeIdentifier))
+                break;
+
+            // The probe has gone missing, remove it.
+            let probeSet = this._probeSetForBreakpoint(breakpoint);
+            let probe = this._probesByIdentifier.get(probeIdentifier);
+            this._probesByIdentifier.delete(probeIdentifier);
+            knownProbeIdentifiers.delete(probeIdentifier);
+            probeSet.removeProbe(probe);
+
+            // Remove the probe set if it has become empty.
+            if (!probeSet.probes.length) {
+                this._probeSetsByBreakpoint.delete(probeSet.breakpoint);
+                probeSet.willRemove();
+                this.dispatchEventToListeners(WI.DebuggerManager.Event.ProbeSetRemoved, {probeSet});
+            }
+        }
+    }
+
+    _probeSetForBreakpoint(breakpoint)
+    {
+        let probeSet = this._probeSetsByBreakpoint.get(breakpoint);
+        if (!probeSet) {
+            probeSet = new WI.ProbeSet(breakpoint);
+            this._probeSetsByBreakpoint.set(breakpoint, probeSet);
+            this.dispatchEventToListeners(WI.DebuggerManager.Event.ProbeSetAdded, {probeSet});
+        }
+        return probeSet;
+    }
+
     _debugUIEnabledDidChange()
     {
         let eventType = WI.isDebugUIEnabled() ? WI.DebuggerManager.Event.ScriptAdded : WI.DebuggerManager.Event.ScriptRemoved;
@@ -1220,17 +1351,22 @@ WI.DebuggerManager.Event = {
     ScriptAdded: "debugger-manager-script-added",
     ScriptRemoved: "debugger-manager-script-removed",
     ScriptsCleared: "debugger-manager-scripts-cleared",
-    BreakpointsEnabledDidChange: "debugger-manager-breakpoints-enabled-did-change"
+    BreakpointsEnabledDidChange: "debugger-manager-breakpoints-enabled-did-change",
+    ProbeSetAdded: "debugger-manager-probe-set-added",
+    ProbeSetRemoved: "debugger-manager-probe-set-removed",
 };
 
 WI.DebuggerManager.PauseReason = {
+    AnimationFrame: "animation-frame",
     Assertion: "assertion",
     Breakpoint: "breakpoint",
     CSPViolation: "CSP-violation",
     DebuggerStatement: "debugger-statement",
     DOM: "DOM",
+    EventListener: "event-listener",
     Exception: "exception",
     PauseOnNextStatement: "pause-on-next-statement",
+    Timer: "timer",
     XHR: "xhr",
     Other: "other",
 };