Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"chrome.label": "Web App (Chrome)",
"chrome.launch.description": "Launch Chrome to debug a URL",
"chrome.launch.label": "Chrome: Launch",
"browser.emulateFocusedPage": "Emulate a focused page",
"commands.callersAdd.label": "Exclude Caller",
"commands.callersAdd.paletteLabel": "Exclude caller from pausing in the current location",
"commands.callersGoToCaller.label": "Go to caller location",
Expand Down
3 changes: 3 additions & 0 deletions src/adapter/debugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export class DebugAdapter implements IDisposable {
this.dap.on('prettyPrintSource', params => this._prettyPrintSource(params));
this.dap.on('locations', params => this._onLocations(params));
this.dap.on('revealPage', () => this._withThread(thread => thread.revealPage()));
this.dap.on('setFocusEmulationEnabled', params =>
this._withThread(thread => thread.setFocusEmulationEnabled(params)),
);
this.dap.on(
'getPerformance',
() => this._withThread(thread => performanceProvider.retrieve(thread.cdp())),
Expand Down
15 changes: 15 additions & 0 deletions src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class Thread implements IVariableStoreLocationProvider {
private _expectedPauseReason?: ExpectedPauseReason;
private _excludedCallers: readonly Dap.ExcludedCaller[] = [];
private _enabledCustomBreakpoints?: ReadonlySet<string>;
private _focusEmulationEnabled = false;
/** Last parsed WASM script ID. Set immediately before breaking in {@link _breakOnWasmScriptId} */
private _lastParsedWasmScriptIds?: string[];
private readonly stateQueue = new StateQueue();
Expand Down Expand Up @@ -453,6 +454,20 @@ export class Thread implements IVariableStoreLocationProvider {
return {};
}

public async setFocusEmulationEnabled(
params: Dap.SetFocusEmulationEnabledParams,
): Promise<Dap.SetFocusEmulationEnabledResult> {
const enabled = params.enabled ?? !this._focusEmulationEnabled;
const emulation = this._cdp.Emulation;
if (!emulation) {
return { enabled: this._focusEmulationEnabled };
}

await emulation.setFocusEmulationEnabled({ enabled });
this._focusEmulationEnabled = enabled;
return { enabled: this._focusEmulationEnabled };
}

public async completions(
params: Dap.CompletionsParams,
): Promise<Dap.CompletionsResult | Dap.Error> {
Expand Down
23 changes: 23 additions & 0 deletions src/build/dapCustom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ const dapCustom: JSONSchema4 = {
required: ['ids', 'xhr'],
}),

...makeRequest(
'setFocusEmulationEnabled',
'Enables or disables focused page emulation.',
{
properties: {
enabled: {
type: 'boolean',
description: 'Whether to emulate a focused page. Defaults to toggling the current state.',
},
},
additionalProperties: false,
},
{
properties: {
enabled: {
type: 'boolean',
description: 'Whether focused page emulation is enabled after the request.',
},
},
required: ['enabled'],
},
),

...makeRequest('prettyPrintSource', 'Pretty prints source for debugging.', {
properties: {
source: {
Expand Down
18 changes: 18 additions & 0 deletions src/build/generate-contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,11 @@ const commands: ReadonlyArray<{
title: refString('browser.revealPage'),
category: 'Debug',
},
{
command: Commands.EmulateFocusedPage,
title: refString('browser.emulateFocusedPage'),
category: 'Debug',
},
{
command: Commands.DebugLink,
title: refString('debugLink.label'),
Expand Down Expand Up @@ -1447,6 +1452,11 @@ const menus: Menus = {
command: Commands.RevealPage,
when: 'false',
},
{
command: Commands.EmulateFocusedPage,
title: refString('browser.emulateFocusedPage'),
when: forBrowserDebugType('debugType', 'inDebugMode'),
},
{
command: Commands.DebugLink,
title: refString('debugLink.label'),
Expand Down Expand Up @@ -1569,6 +1579,14 @@ const menus: Menus = {
when: `view == ${CustomViews.EventListenerBreakpoints}`,
group: 'navigation',
},
{
command: Commands.EmulateFocusedPage,
when: forBrowserDebugType(
'debugType',
`view == ${CustomViews.EventListenerBreakpoints} && inDebugMode`,
),
group: 'navigation',
},
{
command: Commands.RemoveAllCustomBreakpoints,
when: `view == ${CustomViews.EventListenerBreakpoints}`,
Expand Down
3 changes: 3 additions & 0 deletions src/common/contributionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const enum Commands {
RemoveAllCustomBreakpoints = 'extension.js-debug.removeAllCustomBreakpoints',
RemoveXHRBreakpoints = 'extension.js-debug.removeXHRBreakpoint',
RevealPage = 'extension.js-debug.revealPage',
EmulateFocusedPage = 'extension.js-debug.emulateFocusedPage',
RequestCDPProxy = 'extension.js-debug.requestCDPProxy',
/** Use node-debug's command so existing keybindings work */
StartWithStopOnEntry = 'extension.node-debug.startWithStopOnEntry',
Expand Down Expand Up @@ -121,6 +122,7 @@ const commandsObj: { [K in Commands]: null } = {
[Commands.RemoveXHRBreakpoints]: null,
[Commands.RemoveAllCustomBreakpoints]: null,
[Commands.RevealPage]: null,
[Commands.EmulateFocusedPage]: null,
[Commands.StartProfile]: null,
[Commands.StopProfile]: null,
[Commands.ToggleSkipping]: null,
Expand Down Expand Up @@ -231,6 +233,7 @@ export interface ICommandTypes {
[Commands.AutoAttachClearVariables](): void;
[Commands.AutoAttachToProcess](info: IAutoAttachInfo): void;
[Commands.RevealPage](sessionId: string): void;
[Commands.EmulateFocusedPage](): Promise<void> | void;
[Commands.DebugLink](link?: string): void;
[Commands.StartWithStopOnEntry](): void;
[Commands.RequestCDPProxy](
Expand Down
Loading