Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class DispatcherConnection {
return;
}
if (method === '__abort__') {
await this._activeProgressControllers.get(`call@${params.id}`)?.abort(new AbortError(undefined, { cause: params.reason }));
await this._activeProgressControllers.get(`call@${params.id}`)?.abort(new AbortError(params.reason));
return;
}
if (!dispatcher) {
Expand Down
5 changes: 1 addition & 4 deletions packages/playwright-core/src/server/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

import yaml from 'yaml';
import { assertionAbortedMessage } from '@isomorphic/abortSignal';
import { parseAriaSnapshotUnsafe } from '@isomorphic/ariaSnapshot';
import { isInvalidSelectorError } from '@isomorphic/selectorParser';
import { ManualPromise } from '@isomorphic/manualPromise';
Expand All @@ -29,7 +28,7 @@ import { makeWaitForNextTask } from '@utils/task';
import { createGuid } from '@utils/crypto';
import { BrowserContext } from './browserContext';
import * as dom from './dom';
import { TimeoutError, AbortError, isTargetClosedError } from './errors';
import { TimeoutError, isTargetClosedError } from './errors';
import { prepareFilesForUpload } from './fileUploadUtils';
import { FrameSelectors } from './frameSelectors';
import { helper } from './helper';
Expand Down Expand Up @@ -1545,8 +1544,6 @@ export class Frame extends SdkObject<FrameEventMap> {
progress.log(e.message);
if (e instanceof TimeoutError)
details.timedOut = true;
if (e instanceof AbortError)
details.customErrorMessage = assertionAbortedMessage(e.cause);
throw new ExpectError(details);
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/playwright-core/src/server/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ export class ProgressController {
});
}


async abort(error: Error) {
const logMessage = `operation was aborted: ${error.message}`;
if (this._state === 'running') {
this.metadata.log.push(logMessage);
(error as any)[kAbortErrorSymbol] = true;
this._state = { error };
this._forceAbortPromise.reject(error);
this._controller.abort(error);
} else if (this._state === 'before') {
this.metadata.log.push(logMessage);
(error as any)[kAbortErrorSymbol] = true;
this._pendingAbortError = error;
}
Expand Down
5 changes: 3 additions & 2 deletions tests/page/expect-timeout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ test('should fail like a timeout when the signal is aborted mid-assertion', asyn

Locator: locator('span')
Expected: visible
Error: The assertion was aborted: stop it
Error: element(s) not found

Call log:
- Expect "toBeVisible" with timeout 5000ms
- waiting for locator('span')`);
- waiting for locator('span')
- operation was aborted: stop it`);
});

test('should fail like a timeout when toHaveText is aborted mid-assertion', async ({ page }) => {
Expand Down
7 changes: 4 additions & 3 deletions tests/page/page-click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,11 +1368,11 @@ it('should abort via signal', async ({ page }) => {
// Give the action time to start and emit call log entries before aborting.
await page.waitForTimeout(500);

const reason = new Error('Aborted by user');
const reason = new Error('foo bar');
controller.abort(reason);
const error = await promise;
expect(error.message).toContain('The operation was aborted');
expect(error.message).toContain(`Call log:`);
expect(error.message).toContain('locator.click: foo bar');
expect(error.message).toMatch(/Call log:[\s\S]*operation was aborted: foo bar/);
expect(error.name).toBe('AbortError');
expect(error.cause).toBe(reason);
});
Expand All @@ -1384,6 +1384,7 @@ it('should throw an Error when aborted in-flight with a string reason', async ({
controller.abort('aborted by user');
const error = await promise.catch(e => e);
expect(error).toBeInstanceOf(Error);
expect(error.message).toContain('locator.click: aborted by user');
expect(error.name).toBe('AbortError');
expect(error.cause).toBe('aborted by user');
});
Expand Down
Loading