fix(trace): show waitForLoadState when event has already fired (#17826)
Fixes https://github.com/microsoft/playwright/issues/17807
This commit is contained in:
parent
b140b29df0
commit
1b5c2f9aba
|
|
@ -148,14 +148,16 @@ export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Fr
|
||||||
|
|
||||||
async waitForLoadState(state: LifecycleEvent = 'load', options: { timeout?: number } = {}): Promise<void> {
|
async waitForLoadState(state: LifecycleEvent = 'load', options: { timeout?: number } = {}): Promise<void> {
|
||||||
state = verifyLoadState('state', state);
|
state = verifyLoadState('state', state);
|
||||||
if (this._loadStates.has(state))
|
|
||||||
return;
|
|
||||||
return this._page!._wrapApiCall(async () => {
|
return this._page!._wrapApiCall(async () => {
|
||||||
const waiter = this._setupNavigationWaiter(options);
|
const waiter = this._setupNavigationWaiter(options);
|
||||||
await waiter.waitForEvent<LifecycleEvent>(this._eventEmitter, 'loadstate', s => {
|
if (this._loadStates.has(state)) {
|
||||||
waiter.log(` "${s}" event fired`);
|
waiter.log(` not waiting, "${state}" event already fired`);
|
||||||
return s === state;
|
} else {
|
||||||
});
|
await waiter.waitForEvent<LifecycleEvent>(this._eventEmitter, 'loadstate', s => {
|
||||||
|
waiter.log(` "${s}" event fired`);
|
||||||
|
return s === state;
|
||||||
|
});
|
||||||
|
}
|
||||||
waiter.dispose();
|
waiter.dispose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -717,3 +717,15 @@ test('should serve overridden request', async ({ page, runAndTrace, server }) =>
|
||||||
expect(color).toBe('rgb(255, 0, 0)');
|
expect(color).toBe('rgb(255, 0, 0)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should display waitForLoadState even if did not wait for it', async ({ runAndTrace, server, page }) => {
|
||||||
|
const traceViewer = await runAndTrace(async () => {
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
await page.waitForLoadState('load');
|
||||||
|
await page.waitForLoadState('load');
|
||||||
|
});
|
||||||
|
await expect(traceViewer.actionTitles).toHaveText([
|
||||||
|
/page.goto/,
|
||||||
|
/page.waitForLoadState/,
|
||||||
|
/page.waitForLoadState/,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue