mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(waitForEventInfo): reply from the server side (#8825)
Otherwise, client thinks that `waitForEventInfo` is a pending operation.
This commit is contained in:
parent
665143d629
commit
bcb0c1745b
@ -237,17 +237,19 @@ export class DispatcherConnection {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (sdkObject && params?.info?.waitId) {
|
if (sdkObject && params?.info?.waitId) {
|
||||||
// Process logs for waitForNavigation/waitForLoadState
|
// Process logs for waitForNavigation/waitForLoadState/etc.
|
||||||
const info = params.info;
|
const info = params.info;
|
||||||
switch (info.phase) {
|
switch (info.phase) {
|
||||||
case 'before': {
|
case 'before': {
|
||||||
this._waitOperations.set(info.waitId, callMetadata);
|
this._waitOperations.set(info.waitId, callMetadata);
|
||||||
await sdkObject.instrumentation.onBeforeCall(sdkObject, callMetadata);
|
await sdkObject.instrumentation.onBeforeCall(sdkObject, callMetadata);
|
||||||
|
this.onmessage({ id });
|
||||||
return;
|
return;
|
||||||
} case 'log': {
|
} case 'log': {
|
||||||
const originalMetadata = this._waitOperations.get(info.waitId)!;
|
const originalMetadata = this._waitOperations.get(info.waitId)!;
|
||||||
originalMetadata.log.push(info.message);
|
originalMetadata.log.push(info.message);
|
||||||
sdkObject.instrumentation.onCallLog('api', info.message, sdkObject, originalMetadata);
|
sdkObject.instrumentation.onCallLog('api', info.message, sdkObject, originalMetadata);
|
||||||
|
this.onmessage({ id });
|
||||||
return;
|
return;
|
||||||
} case 'after': {
|
} case 'after': {
|
||||||
const originalMetadata = this._waitOperations.get(info.waitId)!;
|
const originalMetadata = this._waitOperations.get(info.waitId)!;
|
||||||
@ -255,6 +257,7 @@ export class DispatcherConnection {
|
|||||||
originalMetadata.error = info.error ? { error: { name: 'Error', message: info.error } } : undefined;
|
originalMetadata.error = info.error ? { error: { name: 'Error', message: info.error } } : undefined;
|
||||||
this._waitOperations.delete(info.waitId);
|
this._waitOperations.delete(info.waitId);
|
||||||
await sdkObject.instrumentation.onAfterCall(sdkObject, originalMetadata);
|
await sdkObject.instrumentation.onAfterCall(sdkObject, originalMetadata);
|
||||||
|
this.onmessage({ id });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,26 @@ test('should report error and pending operations on timeout', async ({ runInline
|
|||||||
expect(stripAscii(result.output)).toContain(`10 | page.textContent('text=More missing'),`);
|
expect(stripAscii(result.output)).toContain(`10 | page.textContent('text=More missing'),`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not report waitForEventInfo as pending', async ({ runInlineTest }, testInfo) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'a.test.ts': `
|
||||||
|
const { test } = pwt;
|
||||||
|
test('timedout', async ({ page }) => {
|
||||||
|
await page.setContent('<div>Click me</div>');
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
await page.click('text=Missing');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { workers: 1, timeout: 2000 });
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.passed).toBe(0);
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
expect(result.output).toContain('Pending operations:');
|
||||||
|
expect(result.output).toContain('- page.click at a.test.ts:9:20');
|
||||||
|
expect(result.output).not.toContain('- page.waitForLoadState');
|
||||||
|
});
|
||||||
|
|
||||||
test('should throw when using page in beforeAll', async ({ runInlineTest }, testInfo) => {
|
test('should throw when using page in beforeAll', async ({ runInlineTest }, testInfo) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
'a.test.ts': `
|
'a.test.ts': `
|
||||||
|
Loading…
x
Reference in New Issue
Block a user