Skip to content

Commit 3cace8f

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Fix CXX debugging extension build
Fix TypeScript build issues Bug: none Change-Id: I73d6870b64c5f8ad76746dc1d4358fa013689b10 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6269096 Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Philip Pfaffe <[email protected]>
1 parent 8b5c09f commit 3cace8f

File tree

6 files changed

+32
-21
lines changed

6 files changed

+32
-21
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ export default [
601601
'test/**/*.ts',
602602
'**/testing/*.ts',
603603
'scripts/eslint_rules/test/**/*.js',
604+
'extensions/cxx_debugging/e2e/**',
604605
],
605606

606607
rules: {

extensions/cxx_debugging/e2e/TestDriver.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import {assert} from 'chai';
6-
import type {ElementHandle, JSHandle} from 'puppeteer-core';
6+
import type {ElementHandle} from 'puppeteer-core';
77
import {TestConfig} from 'test/conductor/test_config.js';
88
import {
99
CONSOLE_TAB_SELECTOR,
@@ -90,7 +90,7 @@ describe('CXX Debugging Extension Test Suite', function() {
9090
const stopped = await waitFor(PAUSE_INDICATOR_SELECTOR);
9191
const stoppedText = await waitForFunction(async () => stopped.evaluate(node => node.textContent));
9292

93-
assert.equal(stoppedText, pausedReasonText(reason));
93+
assert.strictEqual(stoppedText, pausedReasonText(reason));
9494

9595
const pausedLocation = await retrieveTopCallFrameWithoutResuming();
9696
if (pausedLocation?.includes('…')) {
@@ -121,9 +121,9 @@ describe('CXX Debugging Extension Test Suite', function() {
121121
}
122122
} else {
123123
if (variableType) {
124-
assert.equal(scopeVariable, `${variableName}: ${variableType}`);
124+
assert.strictEqual(scopeVariable, `${variableName}: ${variableType}`);
125125
} else if (value) {
126-
assert.equal(scopeVariable, `${variableName}: ${value}`);
126+
assert.strictEqual(scopeVariable, `${variableName}: ${value}`);
127127
}
128128
}
129129
}
@@ -142,7 +142,7 @@ describe('CXX Debugging Extension Test Suite', function() {
142142
.map(node => node.textContent);
143143
});
144144
const result = evaluateResults[evaluateResults.length - 1];
145-
assert.equal(result, value.toString());
145+
assert.strictEqual(result, value.toString());
146146
}
147147

148148
await openSourcesPanel();
@@ -174,12 +174,12 @@ async function readScopeView(scope: string, variable: string[]) {
174174
throw new Error(`Scope entry for ${scope} not found`);
175175
}
176176

177-
let parentNode = await scopeElement.evaluateHandle(n => n.nextElementSibling);
177+
let parentNode = await scopeElement.evaluateHandle(n => n.nextElementSibling!);
178178
assert(parentNode, 'Scope element has no siblings');
179179

180180
const result = [];
181181
for (const node of variable) {
182-
const elementHandle: ElementHandle<Element> = await getMember(node, parentNode);
182+
const elementHandle = await getMember(node, parentNode);
183183
const isExpanded = await elementHandle.evaluate((node: Element) => {
184184
node.scrollIntoView();
185185
return node.getAttribute('aria-expanded');
@@ -202,12 +202,12 @@ async function readScopeView(scope: string, variable: string[]) {
202202
result.push(await name.evaluate(node => node.textContent));
203203
}
204204

205-
parentNode = await elementHandle.evaluateHandle(n => n.nextElementSibling);
205+
parentNode = await elementHandle.evaluateHandle(n => n.nextElementSibling!);
206206
assert(parentNode, 'Element has no siblings');
207207
}
208208
return result;
209209

210-
async function getMember(name: string, parentNode: ElementHandle|JSHandle<null>): Promise<ElementHandle<Element>> {
210+
async function getMember(name: string, parentNode: ElementHandle): Promise<ElementHandle<Element>> {
211211
if (name.startsWith('$')) {
212212
const index = parseInt(name.slice(1), 10);
213213
if (!isNaN(index)) {

extensions/cxx_debugging/e2e/standalone/MemoryInspector_test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
PAUSE_INDICATOR_SELECTOR,
1010
} from 'test/e2e/helpers/sources-helpers';
1111
import {
12-
clickElement,
12+
click,
1313
getBrowserAndPages,
1414
getPendingEvents,
1515
installEventListener,
@@ -41,11 +41,12 @@ describe('LinearMemoryInspector', () => {
4141
const stopped = await waitFor(PAUSE_INDICATOR_SELECTOR);
4242
const stoppedText = await waitForFunction(async () => stopped.evaluate(node => node.textContent));
4343

44-
assert.equal(stoppedText, 'Paused on breakpoint');
44+
assert.strictEqual(stoppedText, 'Paused on breakpoint');
4545

4646
const localVariable = await waitFor('[data-object-property-name-for-test="d"]');
47-
const memIcon = await waitFor('[title="Open in Memory inspector panel"]', localVariable);
48-
await clickElement(memIcon);
47+
await click('[title="Open in Memory inspector panel"]', {
48+
root: localVariable,
49+
});
4950

5051
const byteHighlights = await waitForMany('.byte-cell.highlight-area', 8);
5152
const byteHighlightText = await Promise.all(byteHighlights.map(cell => cell.evaluate(cell => cell.textContent)));

extensions/cxx_debugging/src/CustomFormatters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface TypeInfo {
3333
}
3434

3535
export interface WasmInterface {
36-
readMemory(offset: number, length: number): Uint8Array;
36+
readMemory(offset: number, length: number): Uint8Array<ArrayBuffer>;
3737
getOp(op: number): WasmValue;
3838
getLocal(local: number): WasmValue;
3939
getGlobal(global: number): WasmValue;
@@ -607,7 +607,7 @@ export class HostWasmInterface {
607607
this.stopId = stopId;
608608
this.view = new WasmMemoryView(this);
609609
}
610-
readMemory(offset: number, length: number): Uint8Array {
610+
readMemory(offset: number, length: number): Uint8Array<ArrayBuffer> {
611611
return new Uint8Array(this.hostInterface.getWasmLinearMemory(offset, length, this.stopId));
612612
}
613613
getOp(op: number): WasmValue {

extensions/cxx_debugging/src/Formatters.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ function formatLibCXXString<T extends CharArrayConstructor>(
9696

9797
const copyLen = Math.min(stringSize * charSize, Constants.MAX_STRING_LEN);
9898
const bytes = wasm.readMemory(data, copyLen);
99+
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/60934
99100
const text = new charType(bytes.buffer, bytes.byteOffset, stringSize) as InstanceType<T>;
100101
return {size: stringSize, string: decode(text)};
101102
}
102103

103104
const bytes = shortString.$('__data_').asDataView(0, size * charSize);
105+
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/60934
104106
const text = new charType(bytes.buffer, bytes.byteOffset, size) as InstanceType<T>;
105107
return {size, string: decode(text)};
106108
}
@@ -147,7 +149,8 @@ CustomFormatters.addFormatter({
147149
format: formatLibCXX32String,
148150
});
149151

150-
type CharArrayConstructor = typeof Uint8Array|typeof Uint16Array|typeof Uint32Array;
152+
type CharArrayConstructor = Uint8ArrayConstructor|Uint16ArrayConstructor|Uint32ArrayConstructor;
153+
151154
function formatRawString<T extends CharArrayConstructor>(
152155
wasm: WasmInterface, value: Value, charType: T, decode: (chars: InstanceType<T>) => string): string|{
153156
[key: string]: Value|null,
@@ -164,13 +167,15 @@ function formatRawString<T extends CharArrayConstructor>(
164167
// Copy PAGE_SIZE bytes
165168
const buffer = deref.asDataView(bufferSize, Constants.PAGE_SIZE);
166169
// Convert to charType
170+
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/60934
167171
const substr = new charType(buffer.buffer, buffer.byteOffset, buffer.byteLength / charSize);
168172
const strlen = substr.indexOf(0);
169173
if (strlen >= 0) {
170174
// buffer size is in bytes, strlen in characters
171175
const str = new charType(bufferSize / charSize + strlen) as InstanceType<T>;
172176
for (let i = 0; i < slices.length; ++i) {
173177
str.set(
178+
// @ts-expect-error TypeScript can't find the deduce the intersection type correctly
174179
new charType(slices[i].buffer, slices[i].byteOffset, slices[i].byteLength / charSize),
175180
i * Constants.PAGE_SIZE / charSize);
176181
}
@@ -185,12 +190,16 @@ function formatRawString<T extends CharArrayConstructor>(
185190
export function formatCString(wasm: WasmInterface, value: Value): string|{
186191
[key: string]: Value|null,
187192
}
188-
{ return formatRawString(wasm, value, Uint8Array, str => new TextDecoder().decode(str)); }
193+
{
194+
return formatRawString(wasm, value, Uint8Array, str => new TextDecoder().decode(str));
195+
}
189196

190197
export function formatU16CString(wasm: WasmInterface, value: Value): string|{
191198
[key: string]: Value|null,
192199
}
193-
{ return formatRawString(wasm, value, Uint16Array, str => new TextDecoder('utf-16le').decode(str)); }
200+
{
201+
return formatRawString(wasm, value, Uint16Array, str => new TextDecoder('utf-16le').decode(str));
202+
}
194203

195204
export function formatCWString(wasm: WasmInterface, value: Value): string|{
196205
[key: string]: Value|null,

extensions/cxx_debugging/tests/TestUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export function nonNull<T>(value: T|null|undefined): T {
7070
return value as T;
7171
}
7272

73-
export function remoteObject(value: Chrome.DevTools.RemoteObject|Chrome.DevTools.ForeignObject|
74-
null): Chrome.DevTools.RemoteObject {
73+
export function remoteObject(value: Chrome.DevTools.RemoteObject|Chrome.DevTools.ForeignObject|null):
74+
Chrome.DevTools.RemoteObject {
7575
assert.exists(value);
7676
assert(value.type !== 'reftype');
7777
return value;
@@ -83,7 +83,7 @@ export class TestWasmInterface implements WasmInterface {
8383
globals = new Map<number, WasmValue>();
8484
stack = new Map<number, WasmValue>();
8585

86-
readMemory(offset: number, length: number): Uint8Array {
86+
readMemory(offset: number, length: number): Uint8Array<ArrayBuffer> {
8787
return new Uint8Array(this.memory, offset, length);
8888
}
8989
getOp(op: number): WasmValue {

0 commit comments

Comments
 (0)