mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-11 12:33:45 +03:00
parent
eda109388e
commit
4f8680f7a3
@ -203,14 +203,14 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||
await bindingCall.call(func);
|
||||
}
|
||||
|
||||
setDefaultNavigationTimeout(timeout: number) {
|
||||
setDefaultNavigationTimeout(timeout: number | undefined) {
|
||||
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
||||
this._wrapApiCall(async () => {
|
||||
this._channel.setDefaultNavigationTimeoutNoReply({ timeout }).catch(() => {});
|
||||
}, true);
|
||||
}
|
||||
|
||||
setDefaultTimeout(timeout: number) {
|
||||
setDefaultTimeout(timeout: number | undefined) {
|
||||
this._timeoutSettings.setDefaultTimeout(timeout);
|
||||
this._wrapApiCall(async () => {
|
||||
this._channel.setDefaultTimeoutNoReply({ timeout }).catch(() => {});
|
||||
|
@ -681,10 +681,14 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
|
||||
async pause() {
|
||||
if (require('inspector').url())
|
||||
return;
|
||||
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
|
||||
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
|
||||
this._browserContext.setDefaultNavigationTimeout(0);
|
||||
this._browserContext.setDefaultTimeout(0);
|
||||
this._instrumentation?.onWillPause();
|
||||
await this._closedOrCrashedRace.safeRace(this.context()._channel.pause());
|
||||
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
|
||||
this._browserContext.setDefaultTimeout(defaultTimeout);
|
||||
}
|
||||
|
||||
async pdf(options: PDFOptions = {}): Promise<Buffer> {
|
||||
|
@ -37,6 +37,14 @@ export class TimeoutSettings {
|
||||
this._defaultNavigationTimeout = timeout;
|
||||
}
|
||||
|
||||
defaultNavigationTimeout() {
|
||||
return this._defaultNavigationTimeout;
|
||||
}
|
||||
|
||||
defaultTimeout() {
|
||||
return this._defaultTimeout;
|
||||
}
|
||||
|
||||
navigationTimeout(options: { timeout?: number }): number {
|
||||
if (typeof options.timeout === 'number')
|
||||
return options.timeout;
|
||||
|
@ -30,6 +30,20 @@ it('should resume when closing inspector', async ({ page, recorderPageGetter, cl
|
||||
await scriptPromise;
|
||||
});
|
||||
|
||||
it('should not reset timeouts', async ({ page, recorderPageGetter, closeRecorder, server }) => {
|
||||
page.context().setDefaultNavigationTimeout(1000);
|
||||
page.context().setDefaultTimeout(1000);
|
||||
|
||||
const pausePromise = page.pause();
|
||||
await recorderPageGetter();
|
||||
await closeRecorder();
|
||||
await pausePromise;
|
||||
|
||||
server.setRoute('/empty.html', () => {});
|
||||
const error = await page.goto(server.EMPTY_PAGE).catch(e => e);
|
||||
expect(error.message).toContain('page.goto: Timeout 1000ms exceeded.');
|
||||
});
|
||||
|
||||
it.describe('pause', () => {
|
||||
it.skip(({ mode }) => mode !== 'default');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user