Skip to content

Commit e9953f0

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
Replace and update can-show-wasm-scopes test for non-hosted version
This replaces the test and makes some adjustments to counter the flakiness. Fixed: 416405377, 416485093 Change-Id: I613668edf2e4a153cfcdf0a7cb4245664907697e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6620519 Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
1 parent ea366f5 commit e9953f0

10 files changed

+128
-144
lines changed

test/e2e/helpers/sources-helpers.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
waitForAria,
3131
waitForFunction,
3232
waitForFunctionWithTries,
33-
waitForMany,
3433
waitForNone,
3534
waitForVisible,
3635
} from '../../shared/helper.js';
@@ -526,9 +525,12 @@ export async function captureAddedSourceFiles(
526525
return capturedFileNames.map(f => new URL(`http://${f}`).pathname);
527526
}
528527

529-
export async function reloadPageAndWaitForSourceFile(target: puppeteer.Page, sourceFile: string) {
528+
export async function reloadPageAndWaitForSourceFile(
529+
sourceFile: string, devToolsPage: DevToolsPage = getBrowserAndPagesWrappers().devToolsPage,
530+
inspectedPage: InspectedPage = getBrowserAndPagesWrappers().inspectedPage) {
530531
await waitForSourceFiles(
531-
SourceFileEvents.SOURCE_FILE_LOADED, files => files.some(f => f.endsWith(sourceFile)), () => target.reload());
532+
SourceFileEvents.SOURCE_FILE_LOADED, files => files.some(f => f.endsWith(sourceFile)),
533+
() => inspectedPage.reload(), devToolsPage);
532534
}
533535

534536
export function isEqualOrAbbreviation(abbreviated: string, full: string): boolean {
@@ -667,25 +669,27 @@ export async function typeIntoSourcesAndSave(text: string) {
667669
await pressKey('s', {control: true});
668670
}
669671

670-
export async function getScopeNames() {
671-
const scopeElements = await $$('.scope-chain-sidebar-pane-section-title');
672+
export async function getScopeNames(devToolsPage: DevToolsPage = getBrowserAndPagesWrappers().devToolsPage) {
673+
const scopeElements = await devToolsPage.$$('.scope-chain-sidebar-pane-section-title');
672674
const scopeNames = await Promise.all(scopeElements.map(nodes => nodes.evaluate(n => n.textContent)));
673675
return scopeNames;
674676
}
675677

676-
export async function getValuesForScope(scope: string, expandCount: number, waitForNoOfValues: number) {
678+
export async function getValuesForScope(
679+
scope: string, expandCount: number, waitForNoOfValues: number,
680+
devToolsPage: DevToolsPage = getBrowserAndPagesWrappers().devToolsPage) {
677681
const scopeSelector = `[aria-label="${scope}"]`;
678-
await waitFor(scopeSelector);
682+
await devToolsPage.waitFor(scopeSelector);
679683
for (let i = 0; i < expandCount; i++) {
680-
await click(`${scopeSelector} + ol li[aria-expanded=false]`);
684+
await devToolsPage.click(`${scopeSelector} + ol li[aria-expanded=false]`);
681685
}
682686
const valueSelector = `${scopeSelector} + ol .name-and-value`;
683687
async function readValues() {
684-
const valueSelectorElements = await waitForMany(valueSelector, waitForNoOfValues);
688+
const valueSelectorElements = await devToolsPage.waitForMany(valueSelector, waitForNoOfValues);
685689
return await Promise.all(valueSelectorElements.map(elem => elem.evaluate(n => n.textContent as string)));
686690
}
687691
const previousValues = await readValues();
688-
return await waitForFunction(async function() {
692+
return await devToolsPage.waitForFunction(async function() {
689693
const values = await readValues();
690694
if (values.join('') === previousValues.join('')) {
691695
return values;

test/e2e/sources/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ node_ts_library("sources") {
1212
"can-disable-auto-sources-focus_test.ts",
1313
"can-open-linear-memory-inspector_test.ts",
1414
"can-show-multiple-workers_test.ts",
15-
"can-show-wasm-scopes_test.ts",
1615
"debug-raw-wasm_test.ts",
1716
"header-overrides_test.ts",
1817
"icon-row-bucket_test.ts",

test/e2e/sources/can-break-with-wasm-sourcemaps_test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('The Sources Tab', () => {
3232
});
3333

3434
it('hits two breakpoints that are set and activated separately', async () => {
35-
const {target, frontend} = getBrowserAndPages();
35+
const {frontend} = getBrowserAndPages();
3636

3737
await step('navigate to a page and open the Sources tab', async () => {
3838
await openSourceCodeEditorForFile(fileName, 'wasm/wasm-with-sourcemap.html');
@@ -43,7 +43,7 @@ describe('The Sources Tab', () => {
4343
});
4444

4545
await step('reload the page', async () => {
46-
await reloadPageAndWaitForSourceFile(target, fileName);
46+
await reloadPageAndWaitForSourceFile(fileName);
4747
});
4848

4949
await step('open original source file', async () => {
@@ -69,7 +69,7 @@ describe('The Sources Tab', () => {
6969
});
7070

7171
await step('reload the page', async () => {
72-
await reloadPageAndWaitForSourceFile(target, fileName);
72+
await reloadPageAndWaitForSourceFile(fileName);
7373
});
7474

7575
await step('open original source file', async () => {
@@ -84,7 +84,7 @@ describe('The Sources Tab', () => {
8484
});
8585

8686
await step('reload the page', async () => {
87-
await reloadPageAndWaitForSourceFile(target, fileName);
87+
await reloadPageAndWaitForSourceFile(fileName);
8888
});
8989

9090
await waitForFunction(async () => await isBreakpointSet(6));

test/e2e/sources/can-open-linear-memory-inspector_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const LINEAR_MEMORY_INSPECTOR_TAB_TITLE_SELECTOR = '.tabbed-pane-header-tab-titl
2323

2424
describe('Scope View', () => {
2525
it('opens linear memory inspector', async () => {
26-
const {frontend, target} = getBrowserAndPages();
26+
const {frontend} = getBrowserAndPages();
2727
const breakpointLine = '0x039';
2828
const fileName = 'memory.wasm';
2929

@@ -36,7 +36,7 @@ describe('Scope View', () => {
3636
});
3737

3838
await step('reload the page', async () => {
39-
await reloadPageAndWaitForSourceFile(target, fileName);
39+
await reloadPageAndWaitForSourceFile(fileName);
4040
});
4141

4242
await step('expand the module scope', async () => {

test/e2e/sources/can-show-wasm-scopes_test.ts

Lines changed: 0 additions & 109 deletions
This file was deleted.

test/e2e/sources/debug-raw-wasm_test.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('Sources Tab', function() {
8181
});
8282

8383
it('hits two breakpoints that are set and activated separately', async function() {
84-
const {target, frontend} = getBrowserAndPages();
84+
const {frontend} = getBrowserAndPages();
8585
const fileName = 'add.wasm';
8686

8787
await step('navigate to a page and open the Sources tab', async () => {
@@ -93,7 +93,7 @@ describe('Sources Tab', function() {
9393
});
9494

9595
await step('reload the page', async () => {
96-
await reloadPageAndWaitForSourceFile(target, fileName);
96+
await reloadPageAndWaitForSourceFile(fileName);
9797
});
9898

9999
await waitForFunction(async () => await isBreakpointSet('0x027'));
@@ -113,7 +113,7 @@ describe('Sources Tab', function() {
113113
});
114114

115115
await step('reload the page', async () => {
116-
await reloadPageAndWaitForSourceFile(target, fileName);
116+
await reloadPageAndWaitForSourceFile(fileName);
117117
});
118118

119119
await waitForFunction(async () => !(await isBreakpointSet('0x027')));
@@ -124,7 +124,7 @@ describe('Sources Tab', function() {
124124
});
125125

126126
await step('reload the page', async () => {
127-
await reloadPageAndWaitForSourceFile(target, fileName);
127+
await reloadPageAndWaitForSourceFile(fileName);
128128
});
129129

130130
await waitForFunction(async () => await isBreakpointSet('0x028'));
@@ -136,7 +136,6 @@ describe('Sources Tab', function() {
136136
});
137137

138138
it('shows variable value in popover', async function() {
139-
const {target} = getBrowserAndPages();
140139
const fileName = 'add.wasm';
141140

142141
await step('navigate to a page and open the Sources tab', async () => {
@@ -148,7 +147,7 @@ describe('Sources Tab', function() {
148147
});
149148

150149
await step('reload the page', async () => {
151-
await reloadPageAndWaitForSourceFile(target, fileName);
150+
await reloadPageAndWaitForSourceFile(fileName);
152151
});
153152

154153
await step('hover over the $var0 in line No.0x023', async () => {
@@ -183,7 +182,7 @@ describe('Sources Tab', function() {
183182
});
184183

185184
it('is able to step with state', async () => {
186-
const {target, frontend} = getBrowserAndPages();
185+
const {frontend} = getBrowserAndPages();
187186
const fileName = 'stepping-with-state.wasm';
188187

189188
await step('navigate to a page and open the Sources tab', async () => {
@@ -195,7 +194,7 @@ describe('Sources Tab', function() {
195194
});
196195

197196
await step('reload the page', async () => {
198-
await reloadPageAndWaitForSourceFile(target, fileName);
197+
await reloadPageAndWaitForSourceFile(fileName);
199198
});
200199

201200
await waitForFunction(async () => await isBreakpointSet('0x060'));
@@ -233,7 +232,7 @@ describe('Sources Tab', function() {
233232
});
234233

235234
await step('reload the page', async () => {
236-
await reloadPageAndWaitForSourceFile(target, fileName);
235+
await reloadPageAndWaitForSourceFile(fileName);
237236
});
238237

239238
await waitForFunction(async () => await isBreakpointSet('0x048'));
@@ -266,7 +265,7 @@ describe('Sources Tab', function() {
266265

267266
it('is able to step with state in multi-threaded code in main thread', async () => {
268267
await enableExperiment('instrumentation-breakpoints');
269-
const {target, frontend} = getBrowserAndPages();
268+
const {frontend} = getBrowserAndPages();
270269
// enableExperiment() reloads the devtools page, so we need to reinstall the listener on the new window.
271270
await installEventListener(frontend, DEBUGGER_PAUSED_EVENT);
272271
const fileName = 'stepping-with-state.wasm';
@@ -304,7 +303,7 @@ describe('Sources Tab', function() {
304303
});
305304

306305
await step('reload the page', async () => {
307-
await reloadPageAndWaitForSourceFile(target, fileName);
306+
await reloadPageAndWaitForSourceFile(fileName);
308307
});
309308

310309
await waitForFunction(async () => await isBreakpointSet('0x060'));
@@ -342,7 +341,7 @@ describe('Sources Tab', function() {
342341
});
343342

344343
await step('reload the page', async () => {
345-
await reloadPageAndWaitForSourceFile(target, fileName);
344+
await reloadPageAndWaitForSourceFile(fileName);
346345
});
347346

348347
await waitForFunction(async () => await isBreakpointSet('0x048'));
@@ -387,7 +386,7 @@ describe('Sources Tab', function() {
387386

388387
it('is able to step with state in multi-threaded code in worker thread', async () => {
389388
await enableExperiment('instrumentation-breakpoints');
390-
const {target, frontend} = getBrowserAndPages();
389+
const {frontend} = getBrowserAndPages();
391390
// enableExperiment() reloads the devtools page, so we need to reinstall the listener on the new window.
392391
await installEventListener(frontend, DEBUGGER_PAUSED_EVENT);
393392
const fileName = 'stepping-with-state.wasm';
@@ -416,7 +415,7 @@ describe('Sources Tab', function() {
416415
});
417416

418417
await step('reload the page', async () => {
419-
await reloadPageAndWaitForSourceFile(target, fileName);
418+
await reloadPageAndWaitForSourceFile(fileName);
420419
});
421420

422421
await waitForFunction(async () => await isBreakpointSet('0x06d'));
@@ -458,7 +457,7 @@ describe('Sources Tab', function() {
458457
});
459458

460459
await step('reload the page', async () => {
461-
await reloadPageAndWaitForSourceFile(target, fileName);
460+
await reloadPageAndWaitForSourceFile(fileName);
462461
});
463462

464463
await waitForFunction(async () => await isBreakpointSet('0x050'));

test/e2e/sources/live-edit-moving-breakpoint_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020

2121
describe('Live edit', () => {
2222
it('moves the breakpoint after reload when changes are not persisted', async () => {
23-
const {frontend, target} = getBrowserAndPages();
23+
const {frontend} = getBrowserAndPages();
2424
await openSourceCodeEditorForFile('live-edit-moving-breakpoint.js', 'live-edit-moving-breakpoint.html');
2525

2626
await step('add two newlines to the script', async () => {
@@ -46,7 +46,7 @@ describe('Live edit', () => {
4646
});
4747

4848
await step('reload the page and verify that the breakpoint has moved', async () => {
49-
await reloadPageAndWaitForSourceFile(target, 'live-edit-moving-breakpoint.js');
49+
await reloadPageAndWaitForSourceFile('live-edit-moving-breakpoint.js');
5050
await openSourceCodeEditorForFile('live-edit-moving-breakpoint.js', 'live-edit-moving-breakpoint.html');
5151

5252
assert.isFalse(await isBreakpointSet(9));

test/e2e/sources/sourcemap_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ describe('The Sources Tab', function() {
661661
await addBreakpointForLine(2);
662662

663663
// Reload the page and re-open (the initial) index.js.
664-
await reloadPageAndWaitForSourceFile(target, 'index.js');
664+
await reloadPageAndWaitForSourceFile('index.js');
665665

666666
// Check that the breakpoint still exists on line 2.
667667
assert.isTrue(await isBreakpointSet(2));

test/e2e_non_hosted/sources/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ts_e2e_library("sources") {
1010
"breakpoints-sidebarpane_test.ts",
1111
"can-handle-special-characters_test.ts",
1212
"can-pretty-print-sourcecode_test.ts",
13+
"can-show-wasm-scopes_test.ts",
1314
"color-swatch_test.ts",
1415
"debugger-sidebar_test.ts",
1516
"eval_test.ts",

0 commit comments

Comments
 (0)