Web Inspector: Debugger: modernize serialization of breakpoints and the maps that...
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / DebuggerSidebarPanel.js
1 /*
2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSidebarPanel
27 {
28     constructor()
29     {
30         super("debugger", WI.UIString("Debugger"), true);
31
32         WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
33         WI.Frame.addEventListener(WI.Frame.Event.ResourceWasAdded, this._resourceAdded, this);
34         WI.Target.addEventListener(WI.Target.Event.ResourceAdded, this._resourceAdded, this);
35
36         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.BreakpointAdded, this._breakpointAdded, this);
37         WI.domDebuggerManager.addEventListener(WI.DOMDebuggerManager.Event.DOMBreakpointAdded, this._breakpointAdded, this);
38         WI.domDebuggerManager.addEventListener(WI.DOMDebuggerManager.Event.EventBreakpointAdded, this._breakpointAdded, this);
39         WI.domDebuggerManager.addEventListener(WI.DOMDebuggerManager.Event.URLBreakpointAdded, this._breakpointAdded, this);
40
41         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.BreakpointRemoved, this._breakpointRemoved, this);
42         WI.domDebuggerManager.addEventListener(WI.DOMDebuggerManager.Event.DOMBreakpointRemoved, this._breakpointRemoved, this);
43         WI.domDebuggerManager.addEventListener(WI.DOMDebuggerManager.Event.EventBreakpointRemoved, this._breakpointRemoved, this);
44         WI.domDebuggerManager.addEventListener(WI.DOMDebuggerManager.Event.URLBreakpointRemoved, this._breakpointRemoved, this);
45
46         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.BreakpointsEnabledDidChange, this._breakpointsEnabledDidChange, this);
47         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ScriptAdded, this._scriptAdded, this);
48         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ScriptRemoved, this._scriptRemoved, this);
49         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ScriptsCleared, this._scriptsCleared, this);
50         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, this._debuggerDidPause, this);
51         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Resumed, this._debuggerDidResume, this);
52         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.CallFramesDidChange, this._debuggerCallFramesDidChange, this);
53         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ActiveCallFrameDidChange, this._debuggerActiveCallFrameDidChange, this);
54         WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.WaitingToPause, this._debuggerWaitingToPause, this);
55
56         WI.DOMBreakpoint.addEventListener(WI.DOMBreakpoint.Event.DOMNodeChanged, this._handleDOMBreakpointDOMNodeChanged, this);
57
58         WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._timelineCapturingWillStart, this);
59         WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._timelineCapturingStopped, this);
60
61         WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this);
62         WI.auditManager.addEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditManagerTestCompleted, this);
63
64         WI.targetManager.addEventListener(WI.TargetManager.Event.TargetAdded, this._targetAdded, this);
65         WI.targetManager.addEventListener(WI.TargetManager.Event.TargetRemoved, this._targetRemoved, this);
66
67         this._timelineRecordingWarningElement = document.createElement("div");
68         this._timelineRecordingWarningElement.classList.add("warning-banner");
69         this._timelineRecordingWarningElement.append(WI.UIString("Debugger disabled during Timeline recording"), document.createElement("br"));
70         let timelineStopRecordingLink = this._timelineRecordingWarningElement.appendChild(document.createElement("a"));
71         timelineStopRecordingLink.textContent = WI.UIString("Stop recording");
72         timelineStopRecordingLink.addEventListener("click", () => { WI.timelineManager.stopCapturing(); });
73
74         this._auditTestWarningElement = document.createElement("div");
75         this._auditTestWarningElement.classList.add("warning-banner");
76         this._auditTestWarningElement.append(WI.UIString("Debugger disabled during Audit"), document.createElement("br"));
77         let auditStopRecordingLink = this._auditTestWarningElement.appendChild(document.createElement("a"));
78         auditStopRecordingLink.textContent = WI.UIString("Stop Audit");
79         auditStopRecordingLink.addEventListener("click", () => { WI.auditManager.stop(); });
80
81         this._breakpointsDisabledWarningElement = document.createElement("div");
82         this._breakpointsDisabledWarningElement.classList.add("warning-banner");
83         this._breakpointsDisabledWarningElement.append(WI.UIString("Breakpoints disabled"), document.createElement("br"));
84         let enableBreakpointsLink = this._breakpointsDisabledWarningElement.appendChild(document.createElement("a"));
85         enableBreakpointsLink.textContent = WI.UIString("Enable breakpoints");
86         enableBreakpointsLink.addEventListener("click", () => { WI.debuggerToggleBreakpoints(); });
87
88         this._navigationBar = new WI.NavigationBar;
89         this.addSubview(this._navigationBar);
90
91         var breakpointsImage = {src: "Images/Breakpoints.svg", width: 15, height: 15};
92         var pauseImage = {src: "Images/Pause.svg", width: 15, height: 15};
93         var resumeImage = {src: "Images/Resume.svg", width: 15, height: 15};
94         var stepOverImage = {src: "Images/StepOver.svg", width: 15, height: 15};
95         var stepIntoImage = {src: "Images/StepInto.svg", width: 15, height: 15};
96         var stepOutImage = {src: "Images/StepOut.svg", width: 15, height: 15};
97
98         var toolTip = WI.UIString("Enable all breakpoints (%s)").format(WI.toggleBreakpointsKeyboardShortcut.displayName);
99         var altToolTip = WI.UIString("Disable all breakpoints (%s)").format(WI.toggleBreakpointsKeyboardShortcut.displayName);
100
101         this._debuggerBreakpointsButtonItem = new WI.ActivateButtonNavigationItem("debugger-breakpoints", toolTip, altToolTip, breakpointsImage.src, breakpointsImage.width, breakpointsImage.height);
102         this._debuggerBreakpointsButtonItem.activated = WI.debuggerManager.breakpointsEnabled;
103         this._debuggerBreakpointsButtonItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.debuggerToggleBreakpoints, this);
104         this._navigationBar.addNavigationItem(this._debuggerBreakpointsButtonItem);
105
106         toolTip = WI.UIString("Pause script execution (%s or %s)").format(WI.pauseOrResumeKeyboardShortcut.displayName, WI.pauseOrResumeAlternateKeyboardShortcut.displayName);
107         altToolTip = WI.UIString("Continue script execution (%s or %s)").format(WI.pauseOrResumeKeyboardShortcut.displayName, WI.pauseOrResumeAlternateKeyboardShortcut.displayName);
108
109         this._debuggerPauseResumeButtonItem = new WI.ToggleButtonNavigationItem("debugger-pause-resume", toolTip, altToolTip, pauseImage.src, resumeImage.src, pauseImage.width, pauseImage.height);
110         this._debuggerPauseResumeButtonItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.debuggerPauseResumeToggle, this);
111         this._navigationBar.addNavigationItem(this._debuggerPauseResumeButtonItem);
112
113         this._debuggerStepOverButtonItem = new WI.ButtonNavigationItem("debugger-step-over", WI.UIString("Step over (%s or %s)").format(WI.stepOverKeyboardShortcut.displayName, WI.stepOverAlternateKeyboardShortcut.displayName), stepOverImage.src, stepOverImage.width, stepOverImage.height);
114         this._debuggerStepOverButtonItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.debuggerStepOver, this);
115         this._debuggerStepOverButtonItem.enabled = false;
116         this._navigationBar.addNavigationItem(this._debuggerStepOverButtonItem);
117
118         this._debuggerStepIntoButtonItem = new WI.ButtonNavigationItem("debugger-step-into", WI.UIString("Step into (%s or %s)").format(WI.stepIntoKeyboardShortcut.displayName, WI.stepIntoAlternateKeyboardShortcut.displayName), stepIntoImage.src, stepIntoImage.width, stepIntoImage.height);
119         this._debuggerStepIntoButtonItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.debuggerStepInto, this);
120         this._debuggerStepIntoButtonItem.enabled = false;
121         this._navigationBar.addNavigationItem(this._debuggerStepIntoButtonItem);
122
123         this._debuggerStepOutButtonItem = new WI.ButtonNavigationItem("debugger-step-out", WI.UIString("Step out (%s or %s)").format(WI.stepOutKeyboardShortcut.displayName, WI.stepOutAlternateKeyboardShortcut.displayName), stepOutImage.src, stepOutImage.width, stepOutImage.height);
124         this._debuggerStepOutButtonItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.debuggerStepOut, this);
125         this._debuggerStepOutButtonItem.enabled = false;
126         this._navigationBar.addNavigationItem(this._debuggerStepOutButtonItem);
127
128         // Add this offset-sections class name so the sticky headers don't overlap the navigation bar.
129         this.element.classList.add(WI.DebuggerSidebarPanel.OffsetSectionsStyleClassName);
130
131         function showResourcesWithIssuesOnlyFilterFunction(treeElement)
132         {
133             // Issues are only shown in the scripts tree outline.
134             if (treeElement.treeOutline !== this._scriptsContentTreeOutline)
135                 return true;
136
137             // Keep issues.
138             if (treeElement instanceof WI.IssueTreeElement)
139                 return true;
140
141             // Keep resources with issues.
142             if (treeElement.hasChildren) {
143                 for (let child of treeElement.children) {
144                     if (child instanceof WI.IssueTreeElement)
145                         return true;
146                 }
147             }
148             return false;
149         }
150
151         this.filterBar.addFilterBarButton("debugger-show-resources-with-issues-only", showResourcesWithIssuesOnlyFilterFunction.bind(this), false, WI.UIString("Only show resources with issues"), WI.UIString("Show all resources"), "Images/Errors.svg", 15, 15);
152
153         this._breakpointsContentTreeOutline = this.contentTreeOutline;
154
155         let breakpointsRow = new WI.DetailsSectionRow;
156         breakpointsRow.element.appendChild(this._breakpointsContentTreeOutline.element);
157
158         let breakpointNavigationBarWrapper = document.createElement("div");
159
160         let breakpointNavigationBar = new WI.NavigationBar;
161         breakpointNavigationBarWrapper.appendChild(breakpointNavigationBar.element);
162
163         this._createBreakpointButton = new WI.ButtonNavigationItem("create-breakpoint", WI.UIString("Create Breakpoint"), "Images/Plus13.svg", 13, 13);
164         this._createBreakpointButton.element.addEventListener("mousedown", this._handleCreateBreakpointMouseDown.bind(this));
165         breakpointNavigationBar.addNavigationItem(this._createBreakpointButton);
166
167         let breakpointsGroup = new WI.DetailsSectionGroup([breakpointsRow]);
168         let breakpointsSection = new WI.DetailsSection("breakpoints", WI.UIString("Breakpoints"), [breakpointsGroup], breakpointNavigationBarWrapper);
169         this.contentView.element.appendChild(breakpointsSection.element);
170
171         this._breakpointsContentTreeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, this._handleBreakpointElementAddedOrRemoved, this);
172         this._breakpointsContentTreeOutline.addEventListener(WI.TreeOutline.Event.ElementRemoved, this._handleBreakpointElementAddedOrRemoved, this);
173         this._breakpointsContentTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
174         this._breakpointsContentTreeOutline.ondelete = this._breakpointTreeOutlineDeleteTreeElement.bind(this);
175         this._breakpointsContentTreeOutline.populateContextMenu = function(contextMenu, event, treeElement) {
176             this._breakpointTreeOutlineContextMenuTreeElement(contextMenu, event, treeElement);
177
178             WI.TreeOutline.prototype.populateContextMenu(contextMenu, event, treeElement);
179         }.bind(this);
180
181         this._scriptsContentTreeOutline = this.createContentTreeOutline();
182         this._scriptsContentTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
183         this._scriptsContentTreeOutline.includeSourceMapResourceChildren = true;
184
185         let scriptsRow = new WI.DetailsSectionRow;
186         scriptsRow.element.appendChild(this._scriptsContentTreeOutline.element);
187
188         let scriptsGroup = new WI.DetailsSectionGroup([scriptsRow]);
189         this._scriptsSection = new WI.DetailsSection("scripts", WI.UIString("Sources"), [scriptsGroup]);
190         this.contentView.element.appendChild(this._scriptsSection.element);
191
192         this._callStackTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
193         this._callStackTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
194
195         this._callStackRow = new WI.DetailsSectionRow;
196         this._callStackRow.element.appendChild(this._callStackTreeOutline.element);
197
198         this._callStackGroup = new WI.DetailsSectionGroup([this._callStackRow]);
199         this._callStackSection = new WI.DetailsSection("call-stack", WI.UIString("Call Stack"), [this._callStackGroup]);
200
201         this._mainTargetTreeElement = null;
202         this._activeCallFrameTreeElement = null;
203
204         this._pauseReasonTreeOutline = null;
205
206         this._pauseReasonLinkContainerElement = document.createElement("span");
207         this._pauseReasonTextRow = new WI.DetailsSectionTextRow;
208         this._pauseReasonGroup = new WI.DetailsSectionGroup([this._pauseReasonTextRow]);
209         this._pauseReasonSection = new WI.DetailsSection("paused-reason", WI.UIString("Pause Reason"), [this._pauseReasonGroup], this._pauseReasonLinkContainerElement);
210
211         WI.Breakpoint.addEventListener(WI.Breakpoint.Event.DisplayLocationDidChange, this._handleDebuggerObjectDisplayLocationDidChange, this);
212         WI.IssueMessage.addEventListener(WI.IssueMessage.Event.DisplayLocationDidChange, this._handleDebuggerObjectDisplayLocationDidChange, this);
213         WI.consoleManager.addEventListener(WI.ConsoleManager.Event.IssueAdded, this._handleIssueAdded, this);
214         WI.consoleManager.addEventListener(WI.ConsoleManager.Event.Cleared, this._handleIssuesCleared, this);
215
216         WI.debuggerManager.addBreakpoint(WI.debuggerManager.allExceptionsBreakpoint);
217         WI.debuggerManager.addBreakpoint(WI.debuggerManager.uncaughtExceptionsBreakpoint);
218
219         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
220         if (InspectorBackend.domains.Debugger.setPauseOnAssertions && WI.settings.showAssertionFailuresBreakpoint.value)
221             WI.debuggerManager.addBreakpoint(WI.debuggerManager.assertionFailuresBreakpoint);
222
223         for (let target of WI.targets)
224             this._addTarget(target);
225         this._updateCallStackTreeOutline();
226
227         if (WI.networkManager.mainFrame)
228             this._addResourcesRecursivelyForFrame(WI.networkManager.mainFrame);
229
230         for (let script of WI.debuggerManager.knownNonResourceScripts)
231             this._addScript(script);
232
233         if (WI.domDebuggerManager.supported) {
234             if (WI.settings.showAllRequestsBreakpoint.value)
235                 WI.domDebuggerManager.addURLBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
236
237             for (let eventBreakpoint of WI.domDebuggerManager.eventBreakpoints)
238                 this._addBreakpoint(eventBreakpoint);
239
240             for (let domBreakpoint of WI.domDebuggerManager.domBreakpoints)
241                 this._addBreakpoint(domBreakpoint);
242
243             for (let eventListenerBreakpoint of WI.domManager.eventListenerBreakpoints)
244                 this._addBreakpoint(eventListenerBreakpoint);
245
246             for (let urlBreakpoints of WI.domDebuggerManager.urlBreakpoints)
247                 this._addBreakpoint(urlBreakpoints);
248         }
249
250         if (WI.debuggerManager.paused)
251             this._debuggerDidPause(null);
252
253         if (WI.debuggerManager.breakpointsDisabledTemporarily) {
254             if (WI.timelineManager.isCapturing())
255                 this._timelineCapturingWillStart();
256
257             if (WI.auditManager.runningState === WI.AuditManager.RunningState.Active || WI.auditManager.runningState === WI.AuditManager.RunningState.Stopping)
258                 this._handleAuditManagerTestScheduled();
259         }
260
261         this._updateBreakpointsDisabledBanner();
262     }
263
264     // Public
265
266     get minimumWidth()
267     {
268         return this._navigationBar.minimumWidth;
269     }
270
271     closed()
272     {
273         super.closed();
274
275         WI.Frame.removeEventListener(null, null, this);
276         WI.Target.removeEventListener(null, null, this);
277         WI.debuggerManager.removeEventListener(null, null, this);
278         WI.domDebuggerManager.removeEventListener(null, null, this);
279         WI.DOMBreakpoint.removeEventListener(null, null, this);
280         WI.timelineManager.removeEventListener(null, null, this);
281         WI.targetManager.removeEventListener(null, null, this);
282         WI.Breakpoint.removeEventListener(null, null, this);
283         WI.IssueMessage.removeEventListener(null, null, this);
284     }
285
286     showDefaultContentView()
287     {
288         if (WI.networkManager.mainFrame) {
289             let mainTreeElement = this._scriptsContentTreeOutline.findTreeElement(WI.networkManager.mainFrame.mainResource);
290             if (mainTreeElement && this.showDefaultContentViewForTreeElement(mainTreeElement))
291                 return;
292         }
293
294         let currentTreeElement = this._scriptsContentTreeOutline.children[0];
295         while (currentTreeElement && !currentTreeElement.root) {
296             if (currentTreeElement instanceof WI.ResourceTreeElement || currentTreeElement instanceof WI.ScriptTreeElement) {
297                 if (this.showDefaultContentViewForTreeElement(currentTreeElement))
298                     return;
299             }
300
301             currentTreeElement = currentTreeElement.traverseNextTreeElement(false, null, true);
302         }
303     }
304
305     treeElementForRepresentedObject(representedObject)
306     {
307         // The main resource is used as the representedObject instead of Frame in our tree.
308         if (representedObject instanceof WI.Frame)
309             representedObject = representedObject.mainResource;
310
311         let treeElement = this._breakpointsContentTreeOutline.findTreeElement(representedObject);
312         if (!treeElement)
313             treeElement = this._scriptsContentTreeOutline.findTreeElement(representedObject);
314
315         if (treeElement)
316             return treeElement;
317
318         // Only special case Script objects.
319         if (!(representedObject instanceof WI.Script)) {
320             console.error("Didn't find a TreeElement for representedObject", representedObject);
321             return null;
322         }
323
324         // If the Script has a URL we should have found it earlier.
325         if (representedObject.url) {
326             console.error("Didn't find a ScriptTreeElement for a Script with a URL.");
327             return null;
328         }
329
330         // Since the Script does not have a URL we consider it an 'anonymous' script. These scripts happen from calls to
331         // window.eval() or browser features like Auto Fill and Reader. They are not normally added to the sidebar, but since
332         // we have a ScriptContentView asking for the tree element we will make a ScriptTreeElement on demand and add it.
333
334         return this._addScript(representedObject);
335     }
336
337     // Protected
338
339     saveStateToCookie(cookie)
340     {
341         console.assert(cookie);
342
343         var selectedTreeElement = this._breakpointsContentTreeOutline.selectedTreeElement;
344         if (!selectedTreeElement) {
345             super.saveStateToCookie(cookie);
346             return;
347         }
348
349         var representedObject = selectedTreeElement.representedObject;
350
351         if (representedObject === WI.debuggerManager.allExceptionsBreakpoint) {
352             cookie[WI.DebuggerSidebarPanel.SelectedAllExceptionsCookieKey] = true;
353             return;
354         }
355
356         if (representedObject === WI.debuggerManager.uncaughtExceptionsBreakpoint) {
357             cookie[WI.DebuggerSidebarPanel.SelectedUncaughtExceptionsCookieKey] = true;
358             return;
359         }
360
361         if (representedObject === WI.debuggerManager.assertionFailuresBreakpoint) {
362             cookie[WI.DebuggerSidebarPanel.SelectedAssertionFailuresCookieKey] = true;
363             return;
364         }
365
366         if (representedObject === WI.domDebuggerManager.allRequestsBreakpoint) {
367             cookie[WI.DebuggerSidebarPanel.SelectedAllRequestsCookieKey] = true;
368             return;
369         }
370
371         super.saveStateToCookie(cookie);
372     }
373
374     restoreStateFromCookie(cookie, relaxedMatchDelay)
375     {
376         console.assert(cookie);
377
378         function revealAndSelect(treeOutline, breakpoint) {
379             let treeElement = treeOutline.findTreeElement(breakpoint);
380             if (!treeElement)
381                 return;
382
383             treeElement.revealAndSelect();
384         }
385
386         // Eagerly resolve the special breakpoints; otherwise, use the default behavior.
387         if (cookie[WI.DebuggerSidebarPanel.SelectedAllExceptionsCookieKey])
388             revealAndSelect(this._breakpointsContentTreeOutline, WI.debuggerManager.allExceptionsBreakpoint);
389         else if (cookie[WI.DebuggerSidebarPanel.SelectedUncaughtExceptionsCookieKey])
390             revealAndSelect(this._breakpointsContentTreeOutline, WI.debuggerManager.uncaughtExceptionsBreakpoint);
391         else if (cookie[WI.DebuggerSidebarPanel.SelectedAssertionFailuresCookieKey])
392             revealAndSelect(this._breakpointsContentTreeOutline, WI.debuggerManager.assertionFailuresBreakpoint);
393         else if (cookie[WI.DebuggerSidebarPanel.SelectedAllRequestsCookieKey])
394             revealAndSelect(this._breakpointsContentTreeOutline, WI.domDebuggerManager.allRequestsBreakpoint);
395         else
396             super.restoreStateFromCookie(cookie, relaxedMatchDelay);
397     }
398
399     // Popover delegate
400
401     willDismissPopover(popover)
402     {
403         let breakpoint = popover.breakpoint;
404         if (!breakpoint)
405             return;
406
407         if (breakpoint instanceof WI.EventBreakpoint)
408             WI.domDebuggerManager.addEventBreakpoint(breakpoint);
409         else if (breakpoint instanceof WI.URLBreakpoint)
410             WI.domDebuggerManager.addURLBreakpoint(breakpoint);
411     }
412
413     // Private
414
415     _debuggerWaitingToPause(event)
416     {
417         this._debuggerPauseResumeButtonItem.enabled = false;
418     }
419
420     _debuggerDidPause(event)
421     {
422         this.contentView.element.insertBefore(this._callStackSection.element, this.contentView.element.firstChild);
423
424         if (this._updatePauseReason())
425             this.contentView.element.insertBefore(this._pauseReasonSection.element, this.contentView.element.firstChild);
426
427         this._debuggerPauseResumeButtonItem.enabled = true;
428         this._debuggerPauseResumeButtonItem.toggled = true;
429         this._debuggerStepOverButtonItem.enabled = true;
430         this._debuggerStepIntoButtonItem.enabled = true;
431         this._debuggerStepOutButtonItem.enabled = true;
432
433         this.element.classList.add(WI.DebuggerSidebarPanel.DebuggerPausedStyleClassName);
434     }
435
436     _debuggerDidResume(event)
437     {
438         this._callStackSection.element.remove();
439
440         this._pauseReasonSection.element.remove();
441
442         this._debuggerPauseResumeButtonItem.enabled = true;
443         this._debuggerPauseResumeButtonItem.toggled = false;
444         this._debuggerStepOverButtonItem.enabled = false;
445         this._debuggerStepIntoButtonItem.enabled = false;
446         this._debuggerStepOutButtonItem.enabled = false;
447
448         this.element.classList.remove(WI.DebuggerSidebarPanel.DebuggerPausedStyleClassName);
449     }
450
451     _breakpointsEnabledDidChange(event)
452     {
453         this._debuggerBreakpointsButtonItem.activated = WI.debuggerManager.breakpointsEnabled;
454
455         this._updateBreakpointsDisabledBanner();
456     }
457
458     _addBreakpoint(breakpoint)
459     {
460         let constructor = WI.BreakpointTreeElement;
461         let options = {};
462         let parentTreeElement = this._breakpointsContentTreeOutline;
463
464         let getDOMNodeTreeElement = (domNode) => {
465             console.assert(domNode, "Missing DOMNode for identifier", breakpoint.domNodeIdentifier);
466             if (!domNode)
467                 return null;
468
469             let domNodeTreeElement = this._breakpointsContentTreeOutline.findTreeElement(domNode);
470             if (!domNodeTreeElement) {
471                 domNodeTreeElement = new WI.DOMNodeTreeElement(domNode);
472                 this._addTreeElement(domNodeTreeElement, parentTreeElement);
473             }
474             return domNodeTreeElement;
475         };
476
477         if (breakpoint === WI.debuggerManager.allExceptionsBreakpoint) {
478             options.className = WI.DebuggerSidebarPanel.ExceptionIconStyleClassName;
479             options.title = WI.UIString("All Exceptions");
480         } else if (breakpoint === WI.debuggerManager.uncaughtExceptionsBreakpoint) {
481             options.className = WI.DebuggerSidebarPanel.ExceptionIconStyleClassName;
482             options.title = WI.UIString("Uncaught Exceptions");
483         } else if (breakpoint === WI.debuggerManager.assertionFailuresBreakpoint) {
484             options.className = WI.DebuggerSidebarPanel.AssertionIconStyleClassName;
485             options.title = WI.UIString("Assertion Failures");
486         } else if (breakpoint instanceof WI.DOMBreakpoint) {
487             if (!breakpoint.domNodeIdentifier)
488                 return null;
489
490             constructor = WI.DOMBreakpointTreeElement;
491
492             let domNode = WI.domManager.nodeForId(breakpoint.domNodeIdentifier);
493             parentTreeElement = getDOMNodeTreeElement(domNode);
494         } else if (breakpoint instanceof WI.EventBreakpoint) {
495             constructor = WI.EventBreakpointTreeElement;
496
497             if (breakpoint.eventListener) {
498                 let eventTargetTreeElement = null;
499                 if (breakpoint.eventListener.onWindow) {
500                     if (!DebuggerSidebarPanel.__windowEventTargetRepresentedObject)
501                         DebuggerSidebarPanel.__windowEventTargetRepresentedObject = {__window: true};
502
503                     eventTargetTreeElement = this._breakpointsContentTreeOutline.findTreeElement(DebuggerSidebarPanel.__windowEventTargetRepresentedObject);
504                     if (!eventTargetTreeElement) {
505                         const subtitle = null;
506                         eventTargetTreeElement = new WI.GeneralTreeElement(["event-target-window"], WI.unlocalizedString("window"), subtitle, DebuggerSidebarPanel.__windowEventTargetRepresentedObject);
507                         this._addTreeElement(eventTargetTreeElement, parentTreeElement);
508                     }
509                 } else if (breakpoint.eventListener.node)
510                     eventTargetTreeElement = getDOMNodeTreeElement(breakpoint.eventListener.node);
511                 if (eventTargetTreeElement)
512                     parentTreeElement = eventTargetTreeElement;
513             }
514         } else if (breakpoint instanceof WI.URLBreakpoint) {
515             constructor = WI.URLBreakpointTreeElement;
516
517             if (breakpoint === WI.domDebuggerManager.allRequestsBreakpoint) {
518                 options.className = WI.DebuggerSidebarPanel.AssertionIconStyleClassName;
519                 options.title = WI.UIString("All Requests");
520             }
521         } else {
522             let sourceCode = breakpoint.sourceCodeLocation && breakpoint.sourceCodeLocation.displaySourceCode;
523             if (!sourceCode)
524                 return null;
525
526             if (this._breakpointsContentTreeOutline.findTreeElement(breakpoint))
527                 return null;
528
529             parentTreeElement = this._addTreeElementForSourceCodeToTreeOutline(sourceCode, this._breakpointsContentTreeOutline);
530
531             // Mark disabled breakpoints as resolved if there is source code loaded with that URL.
532             // This gives the illusion the breakpoint was resolved, but since we don't send disabled
533             // breakpoints to the backend we don't know for sure. If the user enables the breakpoint
534             // it will be resolved properly.
535             if (breakpoint.disabled)
536                 breakpoint.resolved = true;
537         }
538
539         let breakpointTreeElement = new constructor(breakpoint, options);
540         this._addTreeElement(breakpointTreeElement, parentTreeElement);
541         if (parentTreeElement.children.length === 1)
542             parentTreeElement.expand();
543         return breakpointTreeElement;
544     }
545
546     _removeBreakpoint(breakpoint)
547     {
548         if (this._pauseReasonTreeOutline) {
549             let pauseReasonBreakpointTreeElement = this._pauseReasonTreeOutline.getCachedTreeElement(breakpoint);
550             if (pauseReasonBreakpointTreeElement)
551                 pauseReasonBreakpointTreeElement.status = null;
552         }
553
554         let breakpointTreeElement = this._breakpointsContentTreeOutline.getCachedTreeElement(breakpoint);
555         if (!breakpointTreeElement)
556             return;
557
558         this._removeDebuggerTreeElement(breakpointTreeElement);
559     }
560
561     _addBreakpointsForSourceCode(sourceCode)
562     {
563         for (let breakpoint of WI.debuggerManager.breakpointsForSourceCode(sourceCode))
564             this._addBreakpoint(breakpoint, sourceCode);
565     }
566
567     _addIssuesForSourceCode(sourceCode)
568     {
569         var issues = WI.consoleManager.issuesForSourceCode(sourceCode);
570         for (var issue of issues)
571             this._addIssue(issue);
572     }
573
574     _addTreeElementForSourceCodeToTreeOutline(sourceCode, treeOutline)
575     {
576         let treeElement = treeOutline.getCachedTreeElement(sourceCode);
577         if (!treeElement) {
578             if (sourceCode instanceof WI.SourceMapResource)
579                 treeElement = new WI.SourceMapResourceTreeElement(sourceCode);
580             else if (sourceCode instanceof WI.Resource)
581                 treeElement = new WI.ResourceTreeElement(sourceCode);
582             else if (sourceCode instanceof WI.Script)
583                 treeElement = new WI.ScriptTreeElement(sourceCode);
584         }
585
586         if (!treeElement) {
587             console.error("Unknown sourceCode instance", sourceCode);
588             return null;
589         }
590
591         if (!treeElement.parent) {
592             treeElement.hasChildren = false;
593             treeElement.expand();
594
595             this._addTreeElement(treeElement, treeOutline);
596         }
597
598         return treeElement;
599     }
600
601     _addResourcesRecursivelyForFrame(frame)
602     {
603         this._addResource(frame.mainResource);
604
605         for (let resource of frame.resourceCollection)
606             this._addResource(resource);
607
608         for (let childFrame of frame.childFrameCollection)
609             this._addResourcesRecursivelyForFrame(childFrame);
610     }
611
612     _resourceAdded(event)
613     {
614         this._addResource(event.data.resource);
615     }
616
617     _addResource(resource)
618     {
619         if (![WI.Resource.Type.Document, WI.Resource.Type.Script].includes(resource.type))
620             return;
621
622         let treeElement = this._addTreeElementForSourceCodeToTreeOutline(resource, this._scriptsContentTreeOutline);
623         this._addBreakpointsForSourceCode(resource);
624         this._addIssuesForSourceCode(resource);
625
626         if (this.parentSidebar && !this.contentBrowser.currentContentView)
627             this.showDefaultContentViewForTreeElement(treeElement);
628     }
629
630     _mainResourceDidChange(event)
631     {
632         if (event.target.isMainFrame()) {
633             // Aggressively prune resources now so the old resources are removed before
634             // the new main resource is added below. This avoids a visual flash when the
635             // prune normally happens on a later event loop cycle.
636             this.pruneStaleResourceTreeElements();
637             this.contentBrowser.contentViewContainer.closeAllContentViews();
638
639             for (let domBreakpoint of WI.domDebuggerManager.domBreakpoints)
640                 this._removeBreakpoint(domBreakpoint);
641         }
642
643         if (!event.data.oldMainResource) {
644             var resource = event.target.mainResource;
645             this._addTreeElementForSourceCodeToTreeOutline(resource, this._scriptsContentTreeOutline);
646             this._addBreakpointsForSourceCode(resource);
647             this._addIssuesForSourceCode(resource);
648         }
649     }
650
651     _timelineCapturingWillStart(event)
652     {
653         this._updateTemporarilyDisabledBreakpointsButtons();
654
655         this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild);
656         this._updateBreakpointsDisabledBanner();
657     }
658
659     _timelineCapturingStopped(event)
660     {
661         this._updateTemporarilyDisabledBreakpointsButtons();
662
663         this._timelineRecordingWarningElement.remove();
664         this._updateBreakpointsDisabledBanner();
665     }
666
667     _handleAuditManagerTestScheduled(event)
668     {
669         this._updateTemporarilyDisabledBreakpointsButtons();
670
671         this.contentView.element.insertBefore(this._auditTestWarningElement, this.contentView.element.firstChild);
672         this._updateBreakpointsDisabledBanner();
673     }
674
675     _handleAuditManagerTestCompleted(event)
676     {
677         this._updateTemporarilyDisabledBreakpointsButtons();
678
679         this._auditTestWarningElement.remove();
680         this._updateBreakpointsDisabledBanner();
681     }
682
683     _updateTemporarilyDisabledBreakpointsButtons()
684     {
685         let breakpointsDisabledTemporarily = WI.debuggerManager.breakpointsDisabledTemporarily;
686         this._debuggerBreakpointsButtonItem.enabled = !breakpointsDisabledTemporarily;
687         this._debuggerPauseResumeButtonItem.enabled = !breakpointsDisabledTemporarily;
688     }
689
690     _updateBreakpointsDisabledBanner()
691     {
692         let breakpointsEnabled = WI.debuggerManager.breakpointsEnabled;
693         let timelineWarningShowing = !!this._timelineRecordingWarningElement.parentElement;
694         let auditWarningShowing = !!this._auditTestWarningElement.parentElement;
695
696         if (!breakpointsEnabled && !timelineWarningShowing && !auditWarningShowing)
697             this.contentView.element.insertBefore(this._breakpointsDisabledWarningElement, this.contentView.element.firstChild);
698         else
699             this._breakpointsDisabledWarningElement.remove();
700     }
701
702     _scriptAdded(event)
703     {
704         this._addScript(event.data.script);
705     }
706
707     _addScript(script)
708     {
709         // COMPATIBILITY(iOS 9): Backends could send the frontend built-in code, filter out JSC internals.
710         if (!script.url && !script.sourceURL)
711             return null;
712
713         // In general, do not show dynamically added script elements.
714         if (script.dynamicallyAddedScriptElement && !script.sourceURL)
715             return null;
716
717         // Don't add breakpoints if the script is represented by a Resource. They were
718         // already added by _resourceAdded.
719         if (script.resource)
720             return null;
721
722         let treeElement = this._addTreeElementForSourceCodeToTreeOutline(script, this._scriptsContentTreeOutline);
723         this._addBreakpointsForSourceCode(script);
724         this._addIssuesForSourceCode(script);
725
726         if (this.parentSidebar && !this.contentBrowser.currentContentView)
727             this.showDefaultContentViewForTreeElement(treeElement);
728
729         return treeElement;
730     }
731
732     _scriptRemoved(event)
733     {
734         function removeScript(script, treeOutline)
735         {
736             let scriptTreeElement = treeOutline.getCachedTreeElement(script);
737             if (scriptTreeElement)
738                 scriptTreeElement.parent.removeChild(scriptTreeElement);
739         }
740
741         let script = event.data.script;
742         removeScript(script, this._breakpointsContentTreeOutline);
743         removeScript(script, this._scriptsContentTreeOutline);
744     }
745
746     _scriptsCleared(event)
747     {
748         for (var i = this._breakpointsContentTreeOutline.children.length - 1; i >= 0; --i) {
749             var treeElement = this._breakpointsContentTreeOutline.children[i];
750             if (!(treeElement instanceof WI.ScriptTreeElement))
751                 continue;
752
753             this._breakpointsContentTreeOutline.removeChildAtIndex(i, true, true);
754         }
755
756         this._scriptsContentTreeOutline.removeChildren();
757
758         this._addResourcesRecursivelyForFrame(WI.networkManager.mainFrame);
759     }
760
761     _breakpointAdded(event)
762     {
763         var breakpoint = event.data.breakpoint;
764         this._addBreakpoint(breakpoint);
765     }
766
767     _breakpointRemoved(event)
768     {
769         var breakpoint = event.data.breakpoint;
770         this._removeBreakpoint(breakpoint);
771     }
772
773     _findThreadTreeElementForTarget(target)
774     {
775         for (let child of this._callStackTreeOutline.children) {
776             if (child.target === target)
777                 return child;
778         }
779
780         return null;
781     }
782
783     _targetAdded(event)
784     {
785         this._addTarget(event.data.target);
786     }
787
788     _addTarget(target)
789     {
790         let treeElement = new WI.ThreadTreeElement(target);
791         this._callStackTreeOutline.appendChild(treeElement);
792
793         // FIXME: When WI.mainTarget changes?
794         if (target === WI.mainTarget)
795             this._mainTargetTreeElement = treeElement;
796
797         this._updateCallStackTreeOutline();
798     }
799
800     _targetRemoved(event)
801     {
802         let target = event.data.target;
803         let treeElement = this._findThreadTreeElementForTarget(target);
804         this._callStackTreeOutline.removeChild(treeElement);
805
806         this._updateCallStackTreeOutline();
807     }
808
809     _updateCallStackTreeOutline()
810     {
811         let singleThreadShowing = WI.targets.length <= 1;
812         this._callStackTreeOutline.element.classList.toggle("single-thread", singleThreadShowing);
813         if (this._mainTargetTreeElement)
814             this._mainTargetTreeElement.selectable = !singleThreadShowing;
815     }
816
817     _handleDebuggerObjectDisplayLocationDidChange(event)
818     {
819         var debuggerObject = event.target;
820
821         if (event.data.oldDisplaySourceCode === debuggerObject.sourceCodeLocation.displaySourceCode)
822             return;
823
824         // A known debugger object (breakpoint, issueMessage, etc.) moved between resources. Remove
825         // the old tree element and create a new tree element with the updated file.
826
827         let wasSelected = false;
828         let oldDebuggerTreeElement = this._breakpointsContentTreeOutline.getCachedTreeElement(debuggerObject);
829         if (oldDebuggerTreeElement)
830             wasSelected = oldDebuggerTreeElement.selected;
831
832         let newDebuggerTreeElement = null;
833         if (debuggerObject instanceof WI.Breakpoint)
834             newDebuggerTreeElement = this._addBreakpoint(debuggerObject);
835         else if (debuggerObject instanceof WI.IssueMessage)
836             newDebuggerTreeElement = this._addIssue(debuggerObject);
837         if (!newDebuggerTreeElement)
838             return;
839
840         if (oldDebuggerTreeElement)
841             this._removeDebuggerTreeElement(oldDebuggerTreeElement);
842
843         if (wasSelected)
844             newDebuggerTreeElement.revealAndSelect(true, false, true);
845     }
846
847     _removeDebuggerTreeElement(debuggerTreeElement)
848     {
849         // If this is a BreakpointTreeElement being deleted because of a cause
850         // outside of the TreeOutline then deselect if it is selected to avoid
851         // TreeOutline selection changes causing unexpected ContentView changes.
852         if (!debuggerTreeElement.__deletedViaDeleteKeyboardShortcut)
853             debuggerTreeElement.deselect();
854
855         let parentTreeElement = debuggerTreeElement.parent;
856         parentTreeElement.removeChild(debuggerTreeElement);
857
858         if (parentTreeElement.children.length || parentTreeElement === this._breakpointsContentTreeOutline)
859             return;
860
861         parentTreeElement.treeOutline.removeChild(parentTreeElement);
862     }
863
864     _debuggerCallFramesDidChange(event)
865     {
866         let target = event.data.target;
867         let treeElement = this._findThreadTreeElementForTarget(target);
868         treeElement.refresh();
869     }
870
871     _debuggerActiveCallFrameDidChange()
872     {
873         if (this._activeCallFrameTreeElement) {
874             this._activeCallFrameTreeElement.isActiveCallFrame = false;
875             this._activeCallFrameTreeElement = null;
876         }
877
878         if (!WI.debuggerManager.activeCallFrame)
879             return;
880
881         this._activeCallFrameTreeElement = this._callStackTreeOutline.findTreeElement(WI.debuggerManager.activeCallFrame);
882         if (this._activeCallFrameTreeElement)
883             this._activeCallFrameTreeElement.isActiveCallFrame = true;
884     }
885
886     _breakpointsBeneathTreeElement(treeElement)
887     {
888         console.assert(treeElement instanceof WI.ResourceTreeElement || treeElement instanceof WI.ScriptTreeElement);
889         if (!(treeElement instanceof WI.ResourceTreeElement) && !(treeElement instanceof WI.ScriptTreeElement))
890             return [];
891
892         var breakpoints = [];
893         var breakpointTreeElements = treeElement.children;
894         for (var i = 0; i < breakpointTreeElements.length; ++i) {
895             console.assert(breakpointTreeElements[i] instanceof WI.BreakpointTreeElement);
896             console.assert(breakpointTreeElements[i].breakpoint);
897             var breakpoint = breakpointTreeElements[i].breakpoint;
898             if (breakpoint)
899                 breakpoints.push(breakpoint);
900         }
901
902         return breakpoints;
903     }
904
905     _removeAllBreakpoints(breakpoints)
906     {
907         for (var i = 0; i < breakpoints.length; ++i) {
908             var breakpoint = breakpoints[i];
909             if (WI.debuggerManager.isBreakpointRemovable(breakpoint))
910                 WI.debuggerManager.removeBreakpoint(breakpoint);
911         }
912     }
913
914     _toggleAllBreakpoints(breakpoints, disabled)
915     {
916         for (var i = 0; i < breakpoints.length; ++i)
917             breakpoints[i].disabled = disabled;
918     }
919
920     _breakpointTreeOutlineDeleteTreeElement(treeElement)
921     {
922         console.assert(treeElement.selected);
923
924         if (treeElement.representedObject === DebuggerSidebarPanel.__windowEventTargetRepresentedObject) {
925             let eventBreakpointsOnWindow = WI.domManager.eventListenerBreakpoints.filter((eventBreakpoint) => eventBreakpoint.eventListener.onWindow);
926             for (let eventBreakpoint of eventBreakpointsOnWindow)
927                 WI.domManager.removeBreakpointForEventListener(eventBreakpoint.eventListener);
928             return true;
929         }
930
931         console.assert(treeElement instanceof WI.ResourceTreeElement || treeElement instanceof WI.ScriptTreeElement);
932         if (!(treeElement instanceof WI.ResourceTreeElement) && !(treeElement instanceof WI.ScriptTreeElement))
933             return false;
934
935         var wasTopResourceTreeElement = treeElement.previousSibling === this._assertionsBreakpointTreeElement || treeElement.previousSibling === this._allUncaughtExceptionsBreakpointTreeElement;
936         var nextSibling = treeElement.nextSibling;
937
938         var breakpoints = this._breakpointsBeneathTreeElement(treeElement);
939         this._removeAllBreakpoints(breakpoints);
940
941         if (wasTopResourceTreeElement && nextSibling)
942             nextSibling.select(true, true);
943
944         return true;
945     }
946
947     _breakpointTreeOutlineContextMenuTreeElement(contextMenu, event, treeElement)
948     {
949         // This check is necessary since the context menu is created by the TreeOutline, meaning
950         // that any child could be the target of the context menu event.
951         if (!(treeElement instanceof WI.ResourceTreeElement) && !(treeElement instanceof WI.ScriptTreeElement))
952             return;
953
954         let breakpoints = this._breakpointsBeneathTreeElement(treeElement);
955         let shouldDisable = breakpoints.some((breakpoint) => !breakpoint.disabled);
956
957         let removeAllResourceBreakpoints = () => {
958             this._removeAllBreakpoints(breakpoints);
959         };
960
961         let toggleAllResourceBreakpoints = () => {
962             this._toggleAllBreakpoints(breakpoints, shouldDisable);
963         };
964
965         if (shouldDisable)
966             contextMenu.appendItem(WI.UIString("Disable Breakpoints"), toggleAllResourceBreakpoints);
967         else
968             contextMenu.appendItem(WI.UIString("Enable Breakpoints"), toggleAllResourceBreakpoints);
969         contextMenu.appendItem(WI.UIString("Delete Breakpoints"), removeAllResourceBreakpoints);
970     }
971
972     _treeSelectionDidChange(event)
973     {
974         if (!this.selected)
975             return;
976
977         let treeElement = event.target.selectedTreeElement;
978         if (!treeElement)
979             return;
980
981         if (treeElement instanceof WI.DOMNodeTreeElement
982             || treeElement instanceof WI.DOMBreakpointTreeElement
983             || treeElement instanceof WI.EventBreakpointTreeElement
984             || treeElement instanceof WI.URLBreakpointTreeElement)
985             return;
986
987         if (treeElement.representedObject === DebuggerSidebarPanel.__windowEventTargetRepresentedObject)
988             return;
989
990         const options = {
991             ignoreNetworkTab: true,
992             ignoreSearchTab: true,
993         };
994
995         if (treeElement instanceof WI.ResourceTreeElement || treeElement instanceof WI.ScriptTreeElement) {
996             WI.showSourceCode(treeElement.representedObject, options);
997             return;
998         }
999
1000         if (treeElement instanceof WI.CallFrameTreeElement) {
1001             let callFrame = treeElement.callFrame;
1002             if (callFrame.id)
1003                 WI.debuggerManager.activeCallFrame = callFrame;
1004
1005             if (callFrame.sourceCodeLocation)
1006                 WI.showSourceCodeLocation(callFrame.sourceCodeLocation, options);
1007
1008             return;
1009         }
1010
1011         if (treeElement instanceof WI.IssueTreeElement) {
1012             WI.showSourceCodeLocation(treeElement.issueMessage.sourceCodeLocation, options);
1013             return;
1014         }
1015
1016         if (!(treeElement instanceof WI.BreakpointTreeElement))
1017             return;
1018
1019         let breakpoint = treeElement.breakpoint;
1020         if (treeElement.treeOutline === this._pauseReasonTreeOutline) {
1021             WI.showSourceCodeLocation(breakpoint.sourceCodeLocation, options);
1022             return;
1023         }
1024
1025         if (!treeElement.parent.representedObject)
1026             return;
1027
1028         console.assert(treeElement.parent.representedObject instanceof WI.SourceCode);
1029         if (!(treeElement.parent.representedObject instanceof WI.SourceCode))
1030             return;
1031
1032         WI.showSourceCodeLocation(breakpoint.sourceCodeLocation, options);
1033     }
1034
1035     _addTreeElement(treeElement, parentTreeElement)
1036     {
1037         if (!parentTreeElement)
1038             parentTreeElement = this._breakpointsContentTreeOutline;
1039
1040         let comparator = (a, b) => {
1041             const rankFunctions = [
1042                 (treeElement) => treeElement.representedObject === WI.debuggerManager.allExceptionsBreakpoint,
1043                 (treeElement) => treeElement.representedObject === WI.debuggerManager.uncaughtExceptionsBreakpoint,
1044                 (treeElement) => treeElement.representedObject === WI.debuggerManager.assertionFailuresBreakpoint,
1045                 (treeElement) => treeElement.representedObject === WI.domDebuggerManager.allRequestsBreakpoint,
1046                 (treeElement) => treeElement instanceof WI.BreakpointTreeElement || treeElement instanceof WI.ResourceTreeElement || treeElement instanceof WI.ScriptTreeElement,
1047                 (treeElement) => treeElement instanceof WI.EventBreakpointTreeElement,
1048                 (treeElement) => treeElement instanceof WI.DOMNodeTreeElement,
1049                 (treeElement) => treeElement instanceof WI.DOMBreakpointTreeElement,
1050                 (treeElement) => treeElement instanceof WI.URLBreakpointTreeElement,
1051             ];
1052
1053             let aRank = rankFunctions.findIndex((rankFunction) => rankFunction(a));
1054             let bRank = rankFunctions.findIndex((rankFunction) => rankFunction(b));
1055             if (aRank >= 0 && bRank >= 0) {
1056                 if (aRank < bRank)
1057                     return -1;
1058                 if (bRank < aRank)
1059                     return 1;
1060             }
1061
1062             if (a instanceof WI.BreakpointTreeElement && b instanceof WI.BreakpointTreeElement)
1063                 return this._compareBreakpointTreeElements(a, b);
1064
1065             return a.mainTitle.extendedLocaleCompare(b.mainTitle) || a.subtitle.extendedLocaleCompare(b.subtitle);
1066         };
1067
1068         parentTreeElement.insertChild(treeElement, insertionIndexForObjectInListSortedByFunction(treeElement, parentTreeElement.children, comparator));
1069     }
1070
1071     _compareBreakpointTreeElements(a, b)
1072     {
1073         if (!a.representedObject || !b.representedObject)
1074             return 0;
1075
1076         let aLocation = a.representedObject.sourceCodeLocation;
1077         let bLocation = b.representedObject.sourceCodeLocation;
1078         if (!aLocation || !bLocation)
1079             return 0;
1080
1081         var comparisonResult = aLocation.displayLineNumber - bLocation.displayLineNumber;
1082         if (comparisonResult !== 0)
1083             return comparisonResult;
1084
1085         return aLocation.displayColumnNumber - bLocation.displayColumnNumber;
1086     }
1087
1088     _updatePauseReason()
1089     {
1090         this._pauseReasonTreeOutline = null;
1091
1092         this._updatePauseReasonGotoArrow();
1093         return this._updatePauseReasonSection();
1094     }
1095
1096     _updatePauseReasonSection()
1097     {
1098         let target = WI.debuggerManager.activeCallFrame.target;
1099         let targetData = WI.debuggerManager.dataForTarget(target);
1100         let {pauseReason, pauseData} = targetData;
1101
1102         switch (pauseReason) {
1103         case WI.DebuggerManager.PauseReason.AnimationFrame:
1104             console.assert(pauseData, "Expected data with an animation frame, but found none.");
1105             if (!pauseData)
1106                 return false;
1107
1108             var eventBreakpoint = WI.domDebuggerManager.eventBreakpointForTypeAndEventName(WI.EventBreakpoint.Type.AnimationFrame, pauseData.eventName);
1109             console.assert(eventBreakpoint, "Expected AnimationFrame breakpoint for event name.", pauseData.eventName);
1110             if (!eventBreakpoint)
1111                 return false;
1112
1113             this._pauseReasonTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
1114
1115             var eventBreakpointTreeElement = new WI.EventBreakpointTreeElement(eventBreakpoint, {
1116                 className: WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName,
1117                 title: WI.UIString("%s Fired").format(pauseData.eventName),
1118             });
1119             this._pauseReasonTreeOutline.appendChild(eventBreakpointTreeElement);
1120
1121             var eventBreakpointRow = new WI.DetailsSectionRow;
1122             eventBreakpointRow.element.appendChild(this._pauseReasonTreeOutline.element);
1123
1124             this._pauseReasonGroup.rows = [eventBreakpointRow];
1125             return true;
1126
1127         case WI.DebuggerManager.PauseReason.Assertion:
1128             // FIXME: We should include the assertion condition string.
1129             console.assert(pauseData, "Expected data with an assertion, but found none.");
1130             if (pauseData && pauseData.message) {
1131                 this._pauseReasonTextRow.text = WI.UIString("Assertion with message: %s").format(pauseData.message);
1132                 return true;
1133             }
1134
1135             this._pauseReasonTextRow.text = WI.UIString("Assertion Failed");
1136             this._pauseReasonGroup.rows = [this._pauseReasonTextRow];
1137             return true;
1138
1139         case WI.DebuggerManager.PauseReason.Breakpoint:
1140             console.assert(pauseData, "Expected breakpoint identifier, but found none.");
1141             if (pauseData && pauseData.breakpointId) {
1142                 this._pauseReasonTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
1143                 this._pauseReasonTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
1144
1145                 let breakpoint = WI.debuggerManager.breakpointForIdentifier(pauseData.breakpointId);
1146                 let breakpointTreeElement = new WI.BreakpointTreeElement(breakpoint, {
1147                     className: WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName,
1148                     title: WI.UIString("Triggered Breakpoint"),
1149                 });
1150                 let breakpointDetailsSection = new WI.DetailsSectionRow;
1151                 this._pauseReasonTreeOutline.appendChild(breakpointTreeElement);
1152                 breakpointDetailsSection.element.appendChild(this._pauseReasonTreeOutline.element);
1153
1154                 this._pauseReasonGroup.rows = [breakpointDetailsSection];
1155                 return true;
1156             }
1157             break;
1158
1159         case WI.DebuggerManager.PauseReason.CSPViolation:
1160             console.assert(pauseData, "Expected data with a CSP Violation, but found none.");
1161             if (pauseData) {
1162                 // COMPATIBILITY (iOS 8): 'directive' was 'directiveText'.
1163                 this._pauseReasonTextRow.text = WI.UIString("Content Security Policy violation of directive: %s").format(pauseData.directive || pauseData.directiveText);
1164                 this._pauseReasonGroup.rows = [this._pauseReasonTextRow];
1165                 return true;
1166             }
1167             break;
1168
1169         case WI.DebuggerManager.PauseReason.DebuggerStatement:
1170             this._pauseReasonTextRow.text = WI.UIString("Debugger Statement");
1171             this._pauseReasonGroup.rows = [this._pauseReasonTextRow];
1172             return true;
1173
1174         case WI.DebuggerManager.PauseReason.DOM:
1175             console.assert(WI.domDebuggerManager.supported);
1176             console.assert(pauseData, "Expected DOM breakpoint data, but found none.");
1177             if (pauseData && pauseData.nodeId) {
1178                 let domNode = WI.domManager.nodeForId(pauseData.nodeId);
1179                 let domBreakpoints = WI.domDebuggerManager.domBreakpointsForNode(domNode);
1180                 let domBreakpoint;
1181                 for (let breakpoint of domBreakpoints) {
1182                     if (breakpoint.type === pauseData.type) {
1183                         domBreakpoint = breakpoint;
1184                         break;
1185                     }
1186                 }
1187
1188                 if (!domBreakpoint)
1189                     return;
1190
1191                 this._pauseReasonTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
1192
1193                 let type = WI.DOMBreakpointTreeElement.displayNameForType(domBreakpoint.type);
1194                 let domBreakpointTreeElement = new WI.DOMBreakpointTreeElement(domBreakpoint, {
1195                     className: WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName,
1196                     title: type,
1197                 });
1198                 let domBreakpointRow = new WI.DetailsSectionRow;
1199                 this._pauseReasonTreeOutline.appendChild(domBreakpointTreeElement);
1200                 domBreakpointRow.element.appendChild(this._pauseReasonTreeOutline.element);
1201
1202                 let ownerElementRow = new WI.DetailsSectionSimpleRow(WI.UIString("Element"), WI.linkifyNodeReference(domNode));
1203                 this._pauseReasonGroup.rows = [domBreakpointRow, ownerElementRow];
1204
1205                 if (domBreakpoint.type !== WI.DOMBreakpoint.Type.SubtreeModified)
1206                     return true;
1207
1208                 console.assert(pauseData.targetNode);
1209
1210                 let remoteObject = WI.RemoteObject.fromPayload(pauseData.targetNode, target);
1211                 remoteObject.pushNodeToFrontend((nodeId) => {
1212                     if (!nodeId)
1213                         return;
1214
1215                     let node = WI.domManager.nodeForId(nodeId);
1216                     console.assert(node, "Missing node for id.", nodeId);
1217                     if (!node)
1218                         return;
1219
1220                     let fragment = document.createDocumentFragment();
1221                     let description = pauseData.insertion ? WI.UIString("Child added to ") : WI.UIString("Removed descendant ");
1222                     fragment.append(description, WI.linkifyNodeReference(node));
1223
1224                     let targetDescriptionRow = new WI.DetailsSectionSimpleRow(WI.UIString("Details"), fragment);
1225                     targetDescriptionRow.element.classList.add("target-description");
1226
1227                     this._pauseReasonGroup.rows = this._pauseReasonGroup.rows.concat(targetDescriptionRow);
1228                 });
1229
1230                 return true;
1231             }
1232             break;
1233
1234         case WI.DebuggerManager.PauseReason.EventListener:
1235             console.assert(pauseData, "Expected data with an event listener, but found none.");
1236             if (!pauseData)
1237                 return false;
1238
1239             var eventBreakpoint = null;
1240             if (pauseData.eventListenerId)
1241                 eventBreakpoint = WI.domManager.breakpointForEventListenerId(pauseData.eventListenerId);
1242             if (!eventBreakpoint)
1243                 eventBreakpoint = WI.domDebuggerManager.eventBreakpointForTypeAndEventName(WI.EventBreakpoint.Type.Listener, pauseData.eventName);
1244
1245             console.assert(eventBreakpoint, "Expected Event Listener breakpoint for event name.", pauseData.eventName);
1246             if (!eventBreakpoint)
1247                 return false;
1248
1249             this._pauseReasonTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
1250
1251             var eventBreakpointTreeElement = new WI.EventBreakpointTreeElement(eventBreakpoint, {
1252                 className: WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName,
1253                 title: WI.UIString("\u201C%s\u201D Event Fired").format(pauseData.eventName),
1254             });
1255             this._pauseReasonTreeOutline.appendChild(eventBreakpointTreeElement);
1256
1257             var eventBreakpointRow = new WI.DetailsSectionRow;
1258             eventBreakpointRow.element.appendChild(this._pauseReasonTreeOutline.element);
1259
1260             var rows = [eventBreakpointRow];
1261
1262             var eventListener = eventBreakpoint.eventListener;
1263             if (eventListener) {
1264                 console.assert(eventListener.eventListenerId === pauseData.eventListenerId);
1265
1266                 let value = null;
1267                 if (eventListener.onWindow)
1268                     value = WI.unlocalizedString("window");
1269                 else if (eventListener.node)
1270                     value = WI.linkifyNodeReference(eventListener.node);
1271                 if (value)
1272                     rows.push(new WI.DetailsSectionSimpleRow(WI.UIString("Target"), value));
1273             }
1274
1275             this._pauseReasonGroup.rows = rows;
1276             return true;
1277
1278         case WI.DebuggerManager.PauseReason.Exception:
1279             console.assert(pauseData, "Expected data with an exception, but found none.");
1280             if (pauseData) {
1281                 // FIXME: We should improve the appearance of thrown objects. This works well for exception strings.
1282                 var data = WI.RemoteObject.fromPayload(pauseData, target);
1283                 this._pauseReasonTextRow.text = WI.UIString("Exception with thrown value: %s").format(data.description);
1284                 this._pauseReasonGroup.rows = [this._pauseReasonTextRow];
1285                 return true;
1286             }
1287             break;
1288
1289         case WI.DebuggerManager.PauseReason.PauseOnNextStatement:
1290             this._pauseReasonTextRow.text = WI.UIString("Immediate Pause Requested");
1291             this._pauseReasonGroup.rows = [this._pauseReasonTextRow];
1292             return true;
1293
1294         case WI.DebuggerManager.PauseReason.Timer:
1295             console.assert(pauseData, "Expected data with a timer, but found none.");
1296             if (!pauseData)
1297                 return false;
1298
1299             var eventBreakpoint = WI.domDebuggerManager.eventBreakpointForTypeAndEventName(WI.EventBreakpoint.Type.Timer, pauseData.eventName);
1300             console.assert(eventBreakpoint, "Expected Timer breakpoint for event name.", pauseData.eventName);
1301             if (!eventBreakpoint)
1302                 return false;
1303
1304             this._pauseReasonTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
1305
1306             var eventBreakpointTreeElement = new WI.EventBreakpointTreeElement(eventBreakpoint, {
1307                 className: WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName,
1308                 title: WI.UIString("%s Fired").format(pauseData.eventName),
1309             });
1310             this._pauseReasonTreeOutline.appendChild(eventBreakpointTreeElement);
1311
1312             var eventBreakpointRow = new WI.DetailsSectionRow;
1313             eventBreakpointRow.element.appendChild(this._pauseReasonTreeOutline.element);
1314
1315             this._pauseReasonGroup.rows = [eventBreakpointRow];
1316             return true;
1317
1318         case WI.DebuggerManager.PauseReason.Fetch:
1319         case WI.DebuggerManager.PauseReason.XHR:
1320             console.assert(WI.domDebuggerManager.supported);
1321             console.assert(pauseData, "Expected URL breakpoint data, but found none.");
1322             if (pauseData) {
1323                 if (pauseData.breakpointURL) {
1324                     let urlBreakpoint = WI.domDebuggerManager.urlBreakpointForURL(pauseData.breakpointURL);
1325                     console.assert(urlBreakpoint, "Expected URL breakpoint for URL.", pauseData.breakpointURL);
1326
1327                     this._pauseReasonTreeOutline = this.createContentTreeOutline({suppressFiltering: true});
1328
1329                     let urlBreakpointTreeElement = new WI.URLBreakpointTreeElement(urlBreakpoint, {
1330                         className: WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName,
1331                         title: WI.DOMDebuggerManager.supportsURLBreakpoints() ? WI.UIString("Triggered URL Breakpoint") : WI.UIString("Triggered XHR Breakpoint"),
1332                     });
1333                     let urlBreakpointRow = new WI.DetailsSectionRow;
1334                     this._pauseReasonTreeOutline.appendChild(urlBreakpointTreeElement);
1335                     urlBreakpointRow.element.appendChild(this._pauseReasonTreeOutline.element);
1336
1337                     this._pauseReasonTextRow.text = pauseData.url;
1338                     this._pauseReasonGroup.rows = [urlBreakpointRow, this._pauseReasonTextRow];
1339                 } else {
1340                     console.assert(pauseData.breakpointURL === "", "Should be the All Requests breakpoint which has an empty URL");
1341                     this._pauseReasonTextRow.text = WI.UIString("Requesting: %s").format(pauseData.url);
1342                     this._pauseReasonGroup.rows = [this._pauseReasonTextRow];
1343                 }
1344                 this._pauseReasonTextRow.element.title = pauseData.url;
1345                 return true;
1346             }
1347             break;
1348
1349         case WI.DebuggerManager.PauseReason.Other:
1350             console.error("Paused for unknown reason. We should always have a reason.");
1351             break;
1352         }
1353
1354         return false;
1355     }
1356
1357     _updatePauseReasonGotoArrow()
1358     {
1359         this._pauseReasonLinkContainerElement.removeChildren();
1360
1361         var activeCallFrame = WI.debuggerManager.activeCallFrame;
1362         if (!activeCallFrame)
1363             return;
1364
1365         var sourceCodeLocation = activeCallFrame.sourceCodeLocation;
1366         if (!sourceCodeLocation)
1367             return;
1368
1369         const options = {
1370             useGoToArrowButton: true,
1371             ignoreNetworkTab: true,
1372             ignoreSearchTab: true,
1373         };
1374         let linkElement = WI.createSourceCodeLocationLink(sourceCodeLocation, options);
1375         this._pauseReasonLinkContainerElement.appendChild(linkElement);
1376     }
1377
1378     _addIssue(issueMessage)
1379     {
1380         let issueTreeElement = this._scriptsContentTreeOutline.findTreeElement(issueMessage);
1381         if (issueTreeElement)
1382             return issueTreeElement;
1383
1384         let parentTreeElement = this._addTreeElementForSourceCodeToTreeOutline(issueMessage.sourceCodeLocation.sourceCode, this._scriptsContentTreeOutline);
1385         if (!parentTreeElement)
1386             return null;
1387
1388         issueTreeElement = new WI.IssueTreeElement(issueMessage);
1389
1390         parentTreeElement.insertChild(issueTreeElement, insertionIndexForObjectInListSortedByFunction(issueTreeElement, parentTreeElement.children, this._compareBreakpointTreeElements));
1391         if (parentTreeElement.children.length === 1)
1392             parentTreeElement.expand();
1393
1394         return issueTreeElement;
1395     }
1396
1397     _handleDOMBreakpointDOMNodeChanged(event)
1398     {
1399         let breakpoint = event.target;
1400         if (breakpoint.domNodeIdentifier)
1401             this._addBreakpoint(breakpoint);
1402         else
1403             this._removeBreakpoint(breakpoint);
1404     }
1405
1406     _handleIssueAdded(event)
1407     {
1408         var issue = event.data.issue;
1409
1410         // We only want to show issues originating from JavaScript source code.
1411         if (!issue.sourceCodeLocation || !issue.sourceCodeLocation.sourceCode || (issue.source !== "javascript" && issue.source !== "console-api"))
1412             return;
1413
1414         this._addIssue(issue);
1415     }
1416
1417     _handleIssuesCleared(event)
1418     {
1419         let currentTreeElement = this._scriptsContentTreeOutline.children[0];
1420         let issueTreeElements = [];
1421
1422         while (currentTreeElement && !currentTreeElement.root) {
1423             if (currentTreeElement instanceof WI.IssueTreeElement)
1424                 issueTreeElements.push(currentTreeElement);
1425             currentTreeElement = currentTreeElement.traverseNextTreeElement(false, null, true);
1426         }
1427
1428         issueTreeElements.forEach((treeElement) => treeElement.parent.removeChild(treeElement));
1429     }
1430
1431     _handleBreakpointElementAddedOrRemoved(event)
1432     {
1433         let treeElement = event.data.element;
1434
1435         let setting = null;
1436         if (treeElement.breakpoint === WI.debuggerManager.assertionFailuresBreakpoint)
1437             setting = WI.settings.showAssertionFailuresBreakpoint;
1438         else if (treeElement.representedObject === WI.domDebuggerManager.allRequestsBreakpoint)
1439             setting = WI.settings.showAllRequestsBreakpoint;
1440
1441         if (setting)
1442             setting.value = !!treeElement.parent;
1443     }
1444
1445     _handleCreateBreakpointMouseDown(event)
1446     {
1447         if (this._ignoreCreateBreakpointMouseDown)
1448             return;
1449
1450         this._ignoreCreateBreakpointMouseDown = true;
1451
1452         let contextMenu = WI.ContextMenu.createFromEvent(event);
1453         contextMenu.addBeforeShowCallback(() => {
1454             this._ignoreCreateBreakpointMouseDown = false;
1455         });
1456
1457         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
1458         if (InspectorBackend.domains.Debugger.setPauseOnAssertions) {
1459             let assertionFailuresBreakpointShown = WI.settings.showAssertionFailuresBreakpoint.value;
1460
1461             contextMenu.appendCheckboxItem(WI.UIString("Assertion Failures"), () => {
1462                 if (assertionFailuresBreakpointShown)
1463                     WI.debuggerManager.removeBreakpoint(WI.debuggerManager.assertionFailuresBreakpoint);
1464                 else {
1465                     WI.debuggerManager.assertionFailuresBreakpoint.disabled = false;
1466                     WI.debuggerManager.addBreakpoint(WI.debuggerManager.assertionFailuresBreakpoint);
1467                 }
1468             }, assertionFailuresBreakpointShown);
1469         }
1470
1471         if (WI.domDebuggerManager.supported) {
1472             contextMenu.appendSeparator();
1473
1474             contextMenu.appendItem(WI.UIString("Event Breakpoint\u2026"), () => {
1475                 let popover = new WI.EventBreakpointPopover(this);
1476                 popover.show(this._createBreakpointButton.element, [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MAX_X]);
1477             });
1478
1479             contextMenu.appendSeparator();
1480
1481             let allRequestsBreakpointShown = WI.settings.showAllRequestsBreakpoint.value;
1482
1483             contextMenu.appendCheckboxItem(WI.UIString("All Requests"), () => {
1484                 if (allRequestsBreakpointShown)
1485                     WI.domDebuggerManager.removeURLBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
1486                 else {
1487                     WI.domDebuggerManager.allRequestsBreakpoint.disabled = false;
1488                     WI.domDebuggerManager.addURLBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
1489                 }
1490             }, allRequestsBreakpointShown);
1491
1492             contextMenu.appendItem(WI.DOMDebuggerManager.supportsURLBreakpoints() ? WI.UIString("URL Breakpoint\u2026") : WI.UIString("XHR Breakpoint\u2026"), () => {
1493                 let popover = new WI.URLBreakpointPopover(this);
1494                 popover.show(this._createBreakpointButton.element, [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MAX_X]);
1495             });
1496         }
1497
1498         contextMenu.show();
1499     }
1500 };
1501
1502 WI.DebuggerSidebarPanel.DebuggerPausedStyleClassName = "paused";
1503 WI.DebuggerSidebarPanel.ExceptionIconStyleClassName = "breakpoint-exception-icon";
1504 WI.DebuggerSidebarPanel.AssertionIconStyleClassName = "breakpoint-assertion-icon";
1505 WI.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName = "breakpoint-paused-icon";
1506
1507 WI.DebuggerSidebarPanel.SelectedAllExceptionsCookieKey = "debugger-sidebar-panel-all-exceptions-breakpoint";
1508 WI.DebuggerSidebarPanel.SelectedUncaughtExceptionsCookieKey = "debugger-sidebar-panel-uncaught-exceptions-breakpoint";
1509 WI.DebuggerSidebarPanel.SelectedAssertionFailuresCookieKey = "debugger-sidebar-panel-assertion-failures-breakpoint";
1510 WI.DebuggerSidebarPanel.SelectedAllRequestsCookieKey = "debugger-sidebar-panel-all-requests-breakpoint";