feat: add "commit" to possible waitUntil options (#9892)
This commit is contained in:
parent
ddda507ccd
commit
13cc266b37
|
|
@ -1,10 +1,11 @@
|
||||||
## navigation-wait-until
|
## navigation-wait-until
|
||||||
- `waitUntil` <[WaitUntilState]<"load"|"domcontentloaded"|"networkidle">>
|
- `waitUntil` <[WaitUntilState]<"load"|"domcontentloaded"|"networkidle"|"commit">>
|
||||||
|
|
||||||
When to consider operation succeeded, defaults to `load`. Events can be either:
|
When to consider operation succeeded, defaults to `load`. Events can be either:
|
||||||
* `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* `'load'` - consider operation to be finished when the `load` event is fired.
|
* `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
|
|
||||||
## navigation-timeout
|
## navigation-timeout
|
||||||
- `timeout` <[float]>
|
- `timeout` <[float]>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import { Page } from './page';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { Waiter } from './waiter';
|
import { Waiter } from './waiter';
|
||||||
import { Events } from './events';
|
import { Events } from './events';
|
||||||
import { LifecycleEvent, URLMatch, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, kLifecycleEvents, StrictOptions } from './types';
|
import { LifecycleEvent, URLMatch, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, StrictOptions, kLifecycleEvents } from './types';
|
||||||
import { urlMatches } from './clientHelper';
|
import { urlMatches } from './clientHelper';
|
||||||
import * as api from '../../types/types';
|
import * as api from '../../types/types';
|
||||||
import * as structs from '../../types/structs';
|
import * as structs from '../../types/structs';
|
||||||
|
|
@ -157,7 +157,8 @@ export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameIni
|
||||||
|
|
||||||
async waitForURL(url: URLMatch, options: { waitUntil?: LifecycleEvent, timeout?: number } = {}): Promise<void> {
|
async waitForURL(url: URLMatch, options: { waitUntil?: LifecycleEvent, timeout?: number } = {}): Promise<void> {
|
||||||
if (urlMatches(this._page?.context()._options.baseURL, this.url(), url))
|
if (urlMatches(this._page?.context()._options.baseURL, this.url(), url))
|
||||||
return await this.waitForLoadState(options?.waitUntil, options);
|
return await this.waitForLoadState(options.waitUntil, options);
|
||||||
|
|
||||||
await this.waitForNavigation({ url, ...options });
|
await this.waitForNavigation({ url, ...options });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -476,6 +477,6 @@ export function verifyLoadState(name: string, waitUntil: LifecycleEvent): Lifecy
|
||||||
if (waitUntil as unknown === 'networkidle0')
|
if (waitUntil as unknown === 'networkidle0')
|
||||||
waitUntil = 'networkidle';
|
waitUntil = 'networkidle';
|
||||||
if (!kLifecycleEvents.has(waitUntil))
|
if (!kLifecycleEvents.has(waitUntil))
|
||||||
throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle)`);
|
throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
|
||||||
return waitUntil;
|
return waitUntil;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ export type SetStorageState = {
|
||||||
origins?: channels.OriginStorage[]
|
origins?: channels.OriginStorage[]
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';
|
export type LifecycleEvent = channels.LifecycleEvent;
|
||||||
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle']);
|
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle', 'commit']);
|
||||||
|
|
||||||
export type BrowserContextOptions = Omit<channels.BrowserNewContextOptions, 'viewport' | 'noDefaultViewport' | 'extraHTTPHeaders' | 'storageState'> & {
|
export type BrowserContextOptions = Omit<channels.BrowserNewContextOptions, 'viewport' | 'noDefaultViewport' | 'extraHTTPHeaders' | 'storageState'> & {
|
||||||
viewport?: Size | null,
|
viewport?: Size | null,
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,7 @@ export type FetchResponse = {
|
||||||
headers: NameValue[],
|
headers: NameValue[],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
||||||
// ----------- Root -----------
|
// ----------- Root -----------
|
||||||
export type RootInitializer = {};
|
export type RootInitializer = {};
|
||||||
export interface RootChannel extends Channel {
|
export interface RootChannel extends Channel {
|
||||||
|
|
@ -1311,33 +1312,33 @@ export type PageExposeBindingOptions = {
|
||||||
export type PageExposeBindingResult = void;
|
export type PageExposeBindingResult = void;
|
||||||
export type PageGoBackParams = {
|
export type PageGoBackParams = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type PageGoBackOptions = {
|
export type PageGoBackOptions = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type PageGoBackResult = {
|
export type PageGoBackResult = {
|
||||||
response?: ResponseChannel,
|
response?: ResponseChannel,
|
||||||
};
|
};
|
||||||
export type PageGoForwardParams = {
|
export type PageGoForwardParams = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type PageGoForwardOptions = {
|
export type PageGoForwardOptions = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type PageGoForwardResult = {
|
export type PageGoForwardResult = {
|
||||||
response?: ResponseChannel,
|
response?: ResponseChannel,
|
||||||
};
|
};
|
||||||
export type PageReloadParams = {
|
export type PageReloadParams = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type PageReloadOptions = {
|
export type PageReloadOptions = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type PageReloadResult = {
|
export type PageReloadResult = {
|
||||||
response?: ResponseChannel,
|
response?: ResponseChannel,
|
||||||
|
|
@ -1604,7 +1605,7 @@ export type FrameInitializer = {
|
||||||
url: string,
|
url: string,
|
||||||
name: string,
|
name: string,
|
||||||
parentFrame?: FrameChannel,
|
parentFrame?: FrameChannel,
|
||||||
loadStates: ('load' | 'domcontentloaded' | 'networkidle')[],
|
loadStates: LifecycleEvent[],
|
||||||
};
|
};
|
||||||
export interface FrameChannel extends Channel {
|
export interface FrameChannel extends Channel {
|
||||||
on(event: 'loadstate', callback: (params: FrameLoadstateEvent) => void): this;
|
on(event: 'loadstate', callback: (params: FrameLoadstateEvent) => void): this;
|
||||||
|
|
@ -1653,8 +1654,8 @@ export interface FrameChannel extends Channel {
|
||||||
expect(params: FrameExpectParams, metadata?: Metadata): Promise<FrameExpectResult>;
|
expect(params: FrameExpectParams, metadata?: Metadata): Promise<FrameExpectResult>;
|
||||||
}
|
}
|
||||||
export type FrameLoadstateEvent = {
|
export type FrameLoadstateEvent = {
|
||||||
add?: 'load' | 'domcontentloaded' | 'networkidle',
|
add?: LifecycleEvent,
|
||||||
remove?: 'load' | 'domcontentloaded' | 'networkidle',
|
remove?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type FrameNavigatedEvent = {
|
export type FrameNavigatedEvent = {
|
||||||
url: string,
|
url: string,
|
||||||
|
|
@ -1886,12 +1887,12 @@ export type FrameGetAttributeResult = {
|
||||||
export type FrameGotoParams = {
|
export type FrameGotoParams = {
|
||||||
url: string,
|
url: string,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
referer?: string,
|
referer?: string,
|
||||||
};
|
};
|
||||||
export type FrameGotoOptions = {
|
export type FrameGotoOptions = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
referer?: string,
|
referer?: string,
|
||||||
};
|
};
|
||||||
export type FrameGotoResult = {
|
export type FrameGotoResult = {
|
||||||
|
|
@ -2084,11 +2085,11 @@ export type FrameSelectOptionResult = {
|
||||||
export type FrameSetContentParams = {
|
export type FrameSetContentParams = {
|
||||||
html: string,
|
html: string,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type FrameSetContentOptions = {
|
export type FrameSetContentOptions = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle',
|
waitUntil?: LifecycleEvent,
|
||||||
};
|
};
|
||||||
export type FrameSetContentResult = void;
|
export type FrameSetContentResult = void;
|
||||||
export type FrameSetInputFilesParams = {
|
export type FrameSetInputFilesParams = {
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,16 @@ FetchResponse:
|
||||||
type: array
|
type: array
|
||||||
items: NameValue
|
items: NameValue
|
||||||
|
|
||||||
|
|
||||||
|
LifecycleEvent:
|
||||||
|
type: enum
|
||||||
|
literals:
|
||||||
|
- load
|
||||||
|
- domcontentloaded
|
||||||
|
- networkidle
|
||||||
|
- commit
|
||||||
|
|
||||||
|
|
||||||
LaunchOptions:
|
LaunchOptions:
|
||||||
type: mixin
|
type: mixin
|
||||||
properties:
|
properties:
|
||||||
|
|
@ -956,12 +966,7 @@ Page:
|
||||||
goBack:
|
goBack:
|
||||||
parameters:
|
parameters:
|
||||||
timeout: number?
|
timeout: number?
|
||||||
waitUntil:
|
waitUntil: LifecycleEvent?
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
returns:
|
returns:
|
||||||
response: Response?
|
response: Response?
|
||||||
tracing:
|
tracing:
|
||||||
|
|
@ -970,12 +975,7 @@ Page:
|
||||||
goForward:
|
goForward:
|
||||||
parameters:
|
parameters:
|
||||||
timeout: number?
|
timeout: number?
|
||||||
waitUntil:
|
waitUntil: LifecycleEvent?
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
returns:
|
returns:
|
||||||
response: Response?
|
response: Response?
|
||||||
tracing:
|
tracing:
|
||||||
|
|
@ -984,12 +984,7 @@ Page:
|
||||||
reload:
|
reload:
|
||||||
parameters:
|
parameters:
|
||||||
timeout: number?
|
timeout: number?
|
||||||
waitUntil:
|
waitUntil: LifecycleEvent?
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
returns:
|
returns:
|
||||||
response: Response?
|
response: Response?
|
||||||
tracing:
|
tracing:
|
||||||
|
|
@ -1280,12 +1275,7 @@ Frame:
|
||||||
parentFrame: Frame?
|
parentFrame: Frame?
|
||||||
loadStates:
|
loadStates:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items: LifecycleEvent
|
||||||
type: enum
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
|
||||||
|
|
@ -1490,12 +1480,7 @@ Frame:
|
||||||
parameters:
|
parameters:
|
||||||
url: string
|
url: string
|
||||||
timeout: number?
|
timeout: number?
|
||||||
waitUntil:
|
waitUntil: LifecycleEvent?
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
referer: string?
|
referer: string?
|
||||||
returns:
|
returns:
|
||||||
response: Response?
|
response: Response?
|
||||||
|
|
@ -1668,12 +1653,7 @@ Frame:
|
||||||
parameters:
|
parameters:
|
||||||
html: string
|
html: string
|
||||||
timeout: number?
|
timeout: number?
|
||||||
waitUntil:
|
waitUntil: LifecycleEvent?
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
tracing:
|
tracing:
|
||||||
snapshot: true
|
snapshot: true
|
||||||
|
|
||||||
|
|
@ -1819,18 +1799,8 @@ Frame:
|
||||||
|
|
||||||
loadstate:
|
loadstate:
|
||||||
parameters:
|
parameters:
|
||||||
add:
|
add: LifecycleEvent?
|
||||||
type: enum?
|
remove: LifecycleEvent?
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
remove:
|
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- load
|
|
||||||
- domcontentloaded
|
|
||||||
- networkidle
|
|
||||||
|
|
||||||
navigated:
|
navigated:
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
||||||
statusText: tString,
|
statusText: tString,
|
||||||
headers: tArray(tType('NameValue')),
|
headers: tArray(tType('NameValue')),
|
||||||
});
|
});
|
||||||
|
scheme.LifecycleEvent = tEnum(['load', 'domcontentloaded', 'networkidle', 'commit']);
|
||||||
scheme.RootInitializeParams = tObject({
|
scheme.RootInitializeParams = tObject({
|
||||||
sdkLanguage: tString,
|
sdkLanguage: tString,
|
||||||
});
|
});
|
||||||
|
|
@ -538,15 +539,15 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
||||||
});
|
});
|
||||||
scheme.PageGoBackParams = tObject({
|
scheme.PageGoBackParams = tObject({
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
waitUntil: tOptional(tEnum(['load', 'domcontentloaded', 'networkidle'])),
|
waitUntil: tOptional(tType('LifecycleEvent')),
|
||||||
});
|
});
|
||||||
scheme.PageGoForwardParams = tObject({
|
scheme.PageGoForwardParams = tObject({
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
waitUntil: tOptional(tEnum(['load', 'domcontentloaded', 'networkidle'])),
|
waitUntil: tOptional(tType('LifecycleEvent')),
|
||||||
});
|
});
|
||||||
scheme.PageReloadParams = tObject({
|
scheme.PageReloadParams = tObject({
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
waitUntil: tOptional(tEnum(['load', 'domcontentloaded', 'networkidle'])),
|
waitUntil: tOptional(tType('LifecycleEvent')),
|
||||||
});
|
});
|
||||||
scheme.PageScreenshotParams = tObject({
|
scheme.PageScreenshotParams = tObject({
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
|
|
@ -753,7 +754,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
||||||
scheme.FrameGotoParams = tObject({
|
scheme.FrameGotoParams = tObject({
|
||||||
url: tString,
|
url: tString,
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
waitUntil: tOptional(tEnum(['load', 'domcontentloaded', 'networkidle'])),
|
waitUntil: tOptional(tType('LifecycleEvent')),
|
||||||
referer: tOptional(tString),
|
referer: tOptional(tString),
|
||||||
});
|
});
|
||||||
scheme.FrameHoverParams = tObject({
|
scheme.FrameHoverParams = tObject({
|
||||||
|
|
@ -839,7 +840,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
||||||
scheme.FrameSetContentParams = tObject({
|
scheme.FrameSetContentParams = tObject({
|
||||||
html: tString,
|
html: tString,
|
||||||
timeout: tOptional(tNumber),
|
timeout: tOptional(tNumber),
|
||||||
waitUntil: tOptional(tEnum(['load', 'domcontentloaded', 'networkidle'])),
|
waitUntil: tOptional(tType('LifecycleEvent')),
|
||||||
});
|
});
|
||||||
scheme.FrameSetInputFilesParams = tObject({
|
scheme.FrameSetInputFilesParams = tObject({
|
||||||
selector: tString,
|
selector: tString,
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,9 @@ export class Frame extends SdkObject {
|
||||||
|
|
||||||
if (this._parentFrame)
|
if (this._parentFrame)
|
||||||
this._parentFrame._childFrames.add(this);
|
this._parentFrame._childFrames.add(this);
|
||||||
|
|
||||||
|
this._firedLifecycleEvents.add('commit');
|
||||||
|
this._subtreeLifecycleEvents.add('commit');
|
||||||
}
|
}
|
||||||
|
|
||||||
_onLifecycleEvent(event: types.LifecycleEvent) {
|
_onLifecycleEvent(event: types.LifecycleEvent) {
|
||||||
|
|
@ -471,6 +474,7 @@ export class Frame extends SdkObject {
|
||||||
this._stopNetworkIdleTimer();
|
this._stopNetworkIdleTimer();
|
||||||
if (this._inflightRequests.size === 0)
|
if (this._inflightRequests.size === 0)
|
||||||
this._startNetworkIdleTimer();
|
this._startNetworkIdleTimer();
|
||||||
|
this._onLifecycleEvent('commit');
|
||||||
}
|
}
|
||||||
|
|
||||||
setPendingDocument(documentInfo: DocumentInfo | undefined) {
|
setPendingDocument(documentInfo: DocumentInfo | undefined) {
|
||||||
|
|
@ -1492,6 +1496,6 @@ function verifyLifecycle(name: string, waitUntil: types.LifecycleEvent): types.L
|
||||||
if (waitUntil as unknown === 'networkidle0')
|
if (waitUntil as unknown === 'networkidle0')
|
||||||
waitUntil = 'networkidle';
|
waitUntil = 'networkidle';
|
||||||
if (!types.kLifecycleEvents.has(waitUntil))
|
if (!types.kLifecycleEvents.has(waitUntil))
|
||||||
throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle)`);
|
throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
|
||||||
return waitUntil;
|
return waitUntil;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ export type WaitForElementOptions = TimeoutOptions & StrictOptions & { state?: '
|
||||||
|
|
||||||
export type WaitForFunctionOptions = TimeoutOptions & { pollingInterval?: number };
|
export type WaitForFunctionOptions = TimeoutOptions & { pollingInterval?: number };
|
||||||
|
|
||||||
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';
|
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
||||||
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle']);
|
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle', 'commit']);
|
||||||
|
|
||||||
export type NavigateOptions = TimeoutOptions & {
|
export type NavigateOptions = TimeoutOptions & {
|
||||||
waitUntil?: LifecycleEvent,
|
waitUntil?: LifecycleEvent,
|
||||||
|
|
|
||||||
33
packages/playwright-core/types/types.d.ts
vendored
33
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -2146,8 +2146,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2173,8 +2174,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2224,8 +2226,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2750,8 +2753,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3000,8 +3004,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3648,8 +3653,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3770,8 +3776,9 @@ export interface Page {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -4925,8 +4932,9 @@ export interface Frame {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -5427,8 +5435,9 @@ export interface Frame {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -5769,8 +5778,9 @@ export interface Frame {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<null|Response>;
|
}): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -5810,8 +5820,9 @@ export interface Frame {
|
||||||
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
* - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
|
||||||
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
* - `'load'` - consider operation to be finished when the `load` event is fired.
|
||||||
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
* - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
|
||||||
|
* - `'commit'` - consider operation to be finished when network response is received and the document started loading.
|
||||||
*/
|
*/
|
||||||
waitUntil?: "load"|"domcontentloaded"|"networkidle";
|
waitUntil?: "load"|"domcontentloaded"|"networkidle"|"commit";
|
||||||
}): Promise<void>;}
|
}): Promise<void>;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ it('should throw if networkidle2 is passed as an option', async ({ page, server
|
||||||
let error = null;
|
let error = null;
|
||||||
// @ts-expect-error networkidle2 is not allowed
|
// @ts-expect-error networkidle2 is not allowed
|
||||||
await page.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle2' }).catch(err => error = err);
|
await page.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle2' }).catch(err => error = err);
|
||||||
expect(error.message).toContain(`waitUntil: expected one of (load|domcontentloaded|networkidle)`);
|
expect(error.message).toContain(`waitUntil: expected one of (load|domcontentloaded|networkidle|commit)`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when main resources failed to load', async ({ page, browserName, isWindows, mode }) => {
|
it('should fail when main resources failed to load', async ({ page, browserName, isWindows, mode }) => {
|
||||||
|
|
@ -628,3 +628,17 @@ it('should properly wait for load', async ({ page, server, browserName }) => {
|
||||||
'load'
|
'load'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return when navigation is committed if commit is specified', async ({ page, server }) => {
|
||||||
|
server.setRoute('/empty.html', (req, res) => {
|
||||||
|
res.writeHead(200, {
|
||||||
|
'content-type': 'text/html',
|
||||||
|
'content-length': '8192'
|
||||||
|
});
|
||||||
|
// Write enought bytes of the body to trigge response received event.
|
||||||
|
res.write('<title>' + 'A'.repeat(4100));
|
||||||
|
res.uncork();
|
||||||
|
});
|
||||||
|
const response = await page.goto(server.EMPTY_PAGE, { waitUntil: 'commit' });
|
||||||
|
expect(response.status()).toBe(200);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ it('should work with domcontentloaded', async ({ page, server }) => {
|
||||||
expect(result).toBe(expectedOutput);
|
expect(result).toBe(expectedOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with commit', async ({ page }) => {
|
||||||
|
await page.setContent('<div>hello</div>', { waitUntil: 'commit' });
|
||||||
|
const result = await page.content();
|
||||||
|
expect(result).toBe(expectedOutput);
|
||||||
|
});
|
||||||
|
|
||||||
it('should work with doctype', async ({ page, server }) => {
|
it('should work with doctype', async ({ page, server }) => {
|
||||||
const doctype = '<!DOCTYPE html>';
|
const doctype = '<!DOCTYPE html>';
|
||||||
await page.setContent(`${doctype}<div>hello</div>`);
|
await page.setContent(`${doctype}<div>hello</div>`);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ it('should throw for bad state', async ({ page, server }) => {
|
||||||
await page.goto(server.PREFIX + '/one-style.html');
|
await page.goto(server.PREFIX + '/one-style.html');
|
||||||
// @ts-expect-error 'bad' is not a valid load state
|
// @ts-expect-error 'bad' is not a valid load state
|
||||||
const error = await page.waitForLoadState('bad').catch(e => e);
|
const error = await page.waitForLoadState('bad').catch(e => e);
|
||||||
expect(error.message).toContain(`state: expected one of (load|domcontentloaded|networkidle)`);
|
expect(error.message).toContain(`state: expected one of (load|domcontentloaded|networkidle|commit)`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should resolve immediately if load state matches', async ({ page, server }) => {
|
it('should resolve immediately if load state matches', async ({ page, server }) => {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,21 @@ it('should work with both domcontentloaded and load', async ({ page, server }) =
|
||||||
await navigationPromise;
|
await navigationPromise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with commit', async ({ page, server }) => {
|
||||||
|
server.setRoute('/empty.html', (req, res) => {
|
||||||
|
res.writeHead(200, {
|
||||||
|
'content-type': 'text/html',
|
||||||
|
'content-length': '8192'
|
||||||
|
});
|
||||||
|
// Write enought bytes of the body to trigge response received event.
|
||||||
|
res.write('<title>' + 'A'.repeat(4100));
|
||||||
|
res.uncork();
|
||||||
|
});
|
||||||
|
|
||||||
|
page.goto(server.EMPTY_PAGE).catch(e => {});
|
||||||
|
await page.waitForNavigation({ waitUntil: 'commit' });
|
||||||
|
});
|
||||||
|
|
||||||
it('should work with clicking on anchor links', async ({ page, server }) => {
|
it('should work with clicking on anchor links', async ({ page, server }) => {
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
await page.setContent(`<a href='#foobar'>foobar</a>`);
|
await page.setContent(`<a href='#foobar'>foobar</a>`);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,25 @@ it('should work with both domcontentloaded and load', async ({ page, server }) =
|
||||||
await navigationPromise;
|
await navigationPromise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with commit', async ({ page, server }) => {
|
||||||
|
server.setRoute('/empty.html', (req, res) => {
|
||||||
|
res.writeHead(200, {
|
||||||
|
'content-type': 'text/html',
|
||||||
|
'content-length': '8192'
|
||||||
|
});
|
||||||
|
// Write enought bytes of the body to trigge response received event.
|
||||||
|
res.write('<title>' + 'A'.repeat(4100));
|
||||||
|
res.uncork();
|
||||||
|
});
|
||||||
|
|
||||||
|
page.goto(server.EMPTY_PAGE).catch(e => {});
|
||||||
|
await page.waitForURL('**/empty.html', { waitUntil: 'commit' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with commit and about:blank', async ({ page, server }) => {
|
||||||
|
await page.waitForURL('about:blank', { waitUntil: 'commit' });
|
||||||
|
});
|
||||||
|
|
||||||
it('should work with clicking on anchor links', async ({ page, server }) => {
|
it('should work with clicking on anchor links', async ({ page, server }) => {
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
await page.setContent(`<a href='#foobar'>foobar</a>`);
|
await page.setContent(`<a href='#foobar'>foobar</a>`);
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,10 @@ for (const [name, item] of Object.entries(protocol)) {
|
||||||
channels_ts.push(`export type ${name} = ${inner.ts};`);
|
channels_ts.push(`export type ${name} = ${inner.ts};`);
|
||||||
channels_ts.push(``);
|
channels_ts.push(``);
|
||||||
addScheme(name, inner.scheme);
|
addScheme(name, inner.scheme);
|
||||||
|
} else if (item.type === 'enum') {
|
||||||
|
const ts = item.literals.map(literal => `'${literal}'`).join(' | ');
|
||||||
|
channels_ts.push(`export type ${name} = ${ts};`)
|
||||||
|
addScheme(name, `tEnum([${item.literals.map(literal => `'${literal}'`).join(', ')}])`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue