Skip to content

Commit f1fdf0b

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[sources] Expand 'Threads' list when pausing in targets other than main
This CL force expands the 'Threads' list if we pause in non-main-frame targets and the target is different from the previously paused target. The restriction is to not annoy users that manually close the 'Threads' list and then repeatedly pause e.g. via stepping or hitting breakpoints multiple times. [email protected] Bug: 373893057 Change-Id: I20df41bf0d43f640da62ec2923f8ab28ce26b986 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5952206 Auto-Submit: Simon Zünd <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]>
1 parent 773b5a9 commit f1fdf0b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

front_end/panels/sources/SourcesPanel.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ export class SourcesPanel extends UI.Panel.Panel implements
206206
private tabbedLocationHeader?: Element|null;
207207
private extensionSidebarPanesContainer?: UI.View.ViewLocation;
208208
sidebarPaneView?: UI.Widget.VBox|UI.SplitWidget.SplitWidget;
209+
210+
#lastPausedTarget: WeakRef<SDK.Target.Target>|null = null;
211+
209212
constructor() {
210213
super('sources');
211214

@@ -483,6 +486,16 @@ export class SourcesPanel extends UI.Panel.Panel implements
483486
UI.Context.Context.instance().setFlavor(SDK.DebuggerModel.DebuggerPausedDetails, details);
484487
this.toggleDebuggerSidebarButton.setEnabled(false);
485488
this.revealDebuggerSidebar();
489+
const pausedTarget = details.debuggerModel.target();
490+
if (this.threadsSidebarPane && this.#lastPausedTarget?.deref() !== pausedTarget &&
491+
pausedTarget !== SDK.TargetManager.TargetManager.instance().primaryPageTarget()) {
492+
// If we pause in something other than the main frame (e.g. worker), we should expand the
493+
// "Threads" list to make it more clear which target is paused. We do this only if the target of
494+
// the previous pause is different from the new pause to prevent annoying the user by re-opening
495+
// the "Threads" list while stepping or hitting the same breakpoint multiple points.
496+
void this.sidebarPaneStack?.showView(this.threadsSidebarPane);
497+
}
498+
486499
window.focus();
487500
Host.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront();
488501
const withOverlay = UI.Context.Context.instance().flavor(SDK.Target.Target)?.model(SDK.OverlayModel.OverlayModel) &&
@@ -498,6 +511,7 @@ export class SourcesPanel extends UI.Panel.Panel implements
498511
this.overlayLoggables.stepOverButton, `${VisualLogging.action('debugger.step-over')}`,
499512
this.overlayLoggables.debuggerPausedMessage);
500513
}
514+
this.#lastPausedTarget = new WeakRef(details.debuggerModel.target());
501515
}
502516

503517
private maybeLogOverlayAction(): void {

test/e2e/sources/script-in-multiple-workers_test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ describe('Multi-Workers', function() {
118118

119119
// This typically happens too quickly to cause DevTools to switch to the other thread, so
120120
// click on the other paused thread.
121-
await Promise.all([
122-
click(THREADS_SELECTOR),
123-
waitFor(THREADS_SELECTOR + '[aria-expanded="true"]'),
124-
]);
121+
await waitFor(THREADS_SELECTOR + '[aria-expanded="true"]');
125122
await click('.thread-item:has( .thread-item-paused-state:not(:empty)):not(.selected)');
126123
});
127124

0 commit comments

Comments
 (0)