Skip to content

Commit 9b4b907

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[test] Don't assert in recording
If the assertion is wrong the test will timeout instead of failing. Which will trigger a afterAll hook to fail due to us using console.error when a run fails. Bug: none Change-Id: I7aac1487086ae22fe158370a2fa30b541f97eb35 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6258002 Commit-Queue: Alex Rudenko <[email protected]> Reviewed-by: Alex Rudenko <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent e21e7c2 commit 9b4b907

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

test/conductor/hooks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,11 @@ async function throttleCPUIfRequired(page: puppeteer.Page): Promise<void> {
211211
return;
212212
}
213213
console.log(`Throttling CPU: ${envThrottleRate}x slowdown`);
214-
const client = await page.target().createCDPSession();
214+
const client = await page.createCDPSession();
215215
await client.send('Emulation.setCPUThrottlingRate', {
216216
rate: envThrottleRate,
217217
});
218+
await client.detach();
218219
}
219220

220221
export async function reloadDevTools(options?: DevToolsFrontendReloadOptions) {

test/conductor/target_tab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class TargetTab {
2929

3030
async reset(): Promise<void> {
3131
await loadEmptyPageAndWaitForContent(this.page);
32-
const client = await this.page.target().createCDPSession();
32+
const client = await this.page.createCDPSession();
3333
await client.send('ServiceWorker.enable');
3434
await client.send('ServiceWorker.stopAllWorkers');
3535
await client.detach();

test/e2e/layers/layers_test.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,24 @@ describe('The Layers Panel', () => {
5050
await waitFor('[aria-label="layers"]:not([test-current-url=""])');
5151
assert.strictEqual(await getCurrentUrl(), `${getResourcesPath()}/${targetUrl}`);
5252

53-
const session = await target.target().createCDPSession();
54-
await session.send('Network.emulateNetworkConditions', {
55-
offline: true,
56-
latency: 0,
57-
downloadThroughput: 0,
58-
uploadThroughput: 0,
59-
});
60-
await target.reload({waitUntil: 'networkidle0'});
61-
await target.bringToFront();
62-
await raf(target);
63-
await frontend.bringToFront();
64-
await waitFor(`[aria-label="layers"]:not([test-current-url="${targetUrl}"])`);
65-
await waitForFunction(async () => {
66-
return (await getCurrentUrl()) === 'chrome-error://chromewebdata/';
67-
});
68-
await session.detach();
53+
const session = await target.createCDPSession();
54+
try {
55+
await session.send('Network.emulateNetworkConditions', {
56+
offline: true,
57+
latency: 0,
58+
downloadThroughput: 0,
59+
uploadThroughput: 0,
60+
});
61+
await target.reload({waitUntil: 'networkidle0'});
62+
await target.bringToFront();
63+
await raf(target);
64+
await frontend.bringToFront();
65+
await waitFor(`[aria-label="layers"]:not([test-current-url="${targetUrl}"])`);
66+
await waitForFunction(async () => {
67+
return (await getCurrentUrl()) === 'chrome-error://chromewebdata/';
68+
});
69+
} finally {
70+
await session.detach();
71+
}
6972
});
7073
});

test/e2e/recorder/replay_test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ describe('Recorder', function() {
656656
});
657657

658658
it('should be able to navigate to a prerendered page', async () => {
659+
const {target} = getBrowserAndPages();
659660
await setupRecorderWithScriptAndReplay({
660661
title: 'Test Recording',
661662
steps: [
@@ -674,12 +675,14 @@ describe('Recorder', function() {
674675
url: `${getResourcesPath()}/recorder/prerendered.html`,
675676
},
676677
],
677-
},
678-
{
679-
type: 'waitForExpression' as StepType.WaitForExpression,
680-
expression: 'document.querySelector("div").innerText === "true"',
681-
},
678+
}
682679
],
680+
683681
});
682+
const isPrerendered = await target.evaluate(() => {
683+
return document.querySelector('div')!.innerText === 'true';
684+
});
685+
686+
assert.isTrue(isPrerendered);
684687
});
685688
});

0 commit comments

Comments
 (0)