chore: enable 'return-await` (#10832)
This commit is contained in:
parent
25db3f1188
commit
7e74439c51
@ -218,6 +218,8 @@ module.exports = {
|
|||||||
{ignoreVoid: true, ignoreIIFE: true},
|
{ignoreVoid: true, ignoreIIFE: true},
|
||||||
],
|
],
|
||||||
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
||||||
|
// This is more performant; see https://v8.dev/blog/fast-async.
|
||||||
|
'@typescript-eslint/return-await': ['error', 'always'],
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -37,12 +37,12 @@ jobs:
|
|||||||
- uses: google/wireit@f3a3c79c553122e2fe5829eeac7d815326502903 # setup-github-actions-caching/v1
|
- uses: google/wireit@f3a3c79c553122e2fe5829eeac7d815326502903 # setup-github-actions-caching/v1
|
||||||
- name: Check code
|
- name: Check code
|
||||||
run: npm run check
|
run: npm run check
|
||||||
- name: Lint code
|
|
||||||
run: npm run lint
|
|
||||||
- name: Validate licenses
|
- name: Validate licenses
|
||||||
run: npm run validate-licenses
|
run: npm run validate-licenses
|
||||||
- name: Build every package
|
- name: Build every package
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
- name: Lint code
|
||||||
|
run: npm run lint
|
||||||
- name: Generate documents
|
- name: Generate documents
|
||||||
run: npm run docs
|
run: npm run docs
|
||||||
- name: Check if autogenerated docs differ
|
- name: Check if autogenerated docs differ
|
||||||
|
@ -305,7 +305,7 @@ export class Process {
|
|||||||
if (!this.#exited) {
|
if (!this.#exited) {
|
||||||
this.kill();
|
this.kill();
|
||||||
}
|
}
|
||||||
return this.#browserProcessExiting;
|
return await this.#browserProcessExiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasClosed(): Promise<void> {
|
hasClosed(): Promise<void> {
|
||||||
|
@ -179,14 +179,14 @@ export abstract class ElementHandle<
|
|||||||
override async getProperty<K extends keyof ElementType>(
|
override async getProperty<K extends keyof ElementType>(
|
||||||
propertyName: HandleOr<K>
|
propertyName: HandleOr<K>
|
||||||
): Promise<HandleFor<ElementType[K]>> {
|
): Promise<HandleFor<ElementType[K]>> {
|
||||||
return this.handle.getProperty(propertyName);
|
return await this.handle.getProperty(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
override async getProperties(): Promise<Map<string, JSHandle>> {
|
override async getProperties(): Promise<Map<string, JSHandle>> {
|
||||||
return this.handle.getProperties();
|
return await this.handle.getProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,7 +202,7 @@ export abstract class ElementHandle<
|
|||||||
pageFunction: Func | string,
|
pageFunction: Func | string,
|
||||||
...args: Params
|
...args: Params
|
||||||
): Promise<Awaited<ReturnType<Func>>> {
|
): Promise<Awaited<ReturnType<Func>>> {
|
||||||
return this.handle.evaluate(pageFunction, ...args);
|
return await this.handle.evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -225,7 +225,7 @@ export abstract class ElementHandle<
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
override async jsonValue(): Promise<ElementType> {
|
override async jsonValue(): Promise<ElementType> {
|
||||||
return this.handle.jsonValue();
|
return await this.handle.jsonValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,9 +288,9 @@ export abstract class ElementHandle<
|
|||||||
): Promise<Array<ElementHandle<NodeFor<Selector>>>> {
|
): Promise<Array<ElementHandle<NodeFor<Selector>>>> {
|
||||||
const {updatedSelector, QueryHandler} =
|
const {updatedSelector, QueryHandler} =
|
||||||
getQueryHandlerAndSelector(selector);
|
getQueryHandlerAndSelector(selector);
|
||||||
return AsyncIterableUtil.collect(
|
return await (AsyncIterableUtil.collect(
|
||||||
QueryHandler.queryAll(this, updatedSelector)
|
QueryHandler.queryAll(this, updatedSelector)
|
||||||
) as Promise<Array<ElementHandle<NodeFor<Selector>>>>;
|
) as Promise<Array<ElementHandle<NodeFor<Selector>>>>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -419,7 +419,7 @@ export abstract class ElementHandle<
|
|||||||
if (expression.startsWith('//')) {
|
if (expression.startsWith('//')) {
|
||||||
expression = `.${expression}`;
|
expression = `.${expression}`;
|
||||||
}
|
}
|
||||||
return this.$$(`xpath/${expression}`);
|
return await this.$$(`xpath/${expression}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -491,7 +491,7 @@ export abstract class ElementHandle<
|
|||||||
* {@link ElementHandle.waitForSelector}.
|
* {@link ElementHandle.waitForSelector}.
|
||||||
*/
|
*/
|
||||||
async isVisible(): Promise<boolean> {
|
async isVisible(): Promise<boolean> {
|
||||||
return this.#checkVisibility(true);
|
return await this.#checkVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -499,7 +499,7 @@ export abstract class ElementHandle<
|
|||||||
* {@link ElementHandle.waitForSelector}.
|
* {@link ElementHandle.waitForSelector}.
|
||||||
*/
|
*/
|
||||||
async isHidden(): Promise<boolean> {
|
async isHidden(): Promise<boolean> {
|
||||||
return this.#checkVisibility(false);
|
return await this.#checkVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -575,7 +575,7 @@ export abstract class ElementHandle<
|
|||||||
if (xpath.startsWith('//')) {
|
if (xpath.startsWith('//')) {
|
||||||
xpath = `.${xpath}`;
|
xpath = `.${xpath}`;
|
||||||
}
|
}
|
||||||
return this.waitForSelector(`xpath/${xpath}`, options);
|
return await this.waitForSelector(`xpath/${xpath}`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -745,7 +745,7 @@ export abstract class ElementHandle<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.evaluate((element, vals): string[] => {
|
return await this.evaluate((element, vals): string[] => {
|
||||||
const values = new Set(vals);
|
const values = new Set(vals);
|
||||||
if (!(element instanceof HTMLSelectElement)) {
|
if (!(element instanceof HTMLSelectElement)) {
|
||||||
throw new Error('Element is not a <select> element.');
|
throw new Error('Element is not a <select> element.');
|
||||||
|
@ -367,7 +367,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
this.evaluateHandle.name,
|
this.evaluateHandle.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.mainRealm().evaluateHandle(pageFunction, ...args);
|
return await this.mainRealm().evaluateHandle(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,7 +388,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
this.evaluate.name,
|
this.evaluate.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.mainRealm().evaluate(pageFunction, ...args);
|
return await this.mainRealm().evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,7 +437,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
async $<Selector extends string>(
|
async $<Selector extends string>(
|
||||||
selector: Selector
|
selector: Selector
|
||||||
): Promise<ElementHandle<NodeFor<Selector>> | null> {
|
): Promise<ElementHandle<NodeFor<Selector>> | null> {
|
||||||
return this.mainRealm().$(selector);
|
return await this.mainRealm().$(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -451,7 +451,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
async $$<Selector extends string>(
|
async $$<Selector extends string>(
|
||||||
selector: Selector
|
selector: Selector
|
||||||
): Promise<Array<ElementHandle<NodeFor<Selector>>>> {
|
): Promise<Array<ElementHandle<NodeFor<Selector>>>> {
|
||||||
return this.mainRealm().$$(selector);
|
return await this.mainRealm().$$(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -622,7 +622,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
if (xpath.startsWith('//')) {
|
if (xpath.startsWith('//')) {
|
||||||
xpath = `.${xpath}`;
|
xpath = `.${xpath}`;
|
||||||
}
|
}
|
||||||
return this.waitForSelector(`xpath/${xpath}`, options);
|
return await this.waitForSelector(`xpath/${xpath}`, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -773,7 +773,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
|
|
||||||
type = type ?? 'text/javascript';
|
type = type ?? 'text/javascript';
|
||||||
|
|
||||||
return this.mainRealm().transferHandle(
|
return await this.mainRealm().transferHandle(
|
||||||
await this.isolatedRealm().evaluateHandle(
|
await this.isolatedRealm().evaluateHandle(
|
||||||
async ({Deferred}, {url, id, type, content}) => {
|
async ({Deferred}, {url, id, type, content}) => {
|
||||||
const deferred = Deferred.create<void>();
|
const deferred = Deferred.create<void>();
|
||||||
@ -859,7 +859,7 @@ export abstract class Frame extends EventEmitter {
|
|||||||
options.content = content;
|
options.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.mainRealm().transferHandle(
|
return await this.mainRealm().transferHandle(
|
||||||
await this.isolatedRealm().evaluateHandle(
|
await this.isolatedRealm().evaluateHandle(
|
||||||
async ({Deferred}, {url, content}) => {
|
async ({Deferred}, {url, content}) => {
|
||||||
const deferred = Deferred.create<void>();
|
const deferred = Deferred.create<void>();
|
||||||
|
@ -903,7 +903,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
async $<Selector extends string>(
|
async $<Selector extends string>(
|
||||||
selector: Selector
|
selector: Selector
|
||||||
): Promise<ElementHandle<NodeFor<Selector>> | null> {
|
): Promise<ElementHandle<NodeFor<Selector>> | null> {
|
||||||
return this.mainFrame().$(selector);
|
return await this.mainFrame().$(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -916,7 +916,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
async $$<Selector extends string>(
|
async $$<Selector extends string>(
|
||||||
selector: Selector
|
selector: Selector
|
||||||
): Promise<Array<ElementHandle<NodeFor<Selector>>>> {
|
): Promise<Array<ElementHandle<NodeFor<Selector>>>> {
|
||||||
return this.mainFrame().$$(selector);
|
return await this.mainFrame().$$(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1095,7 +1095,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
...args: Params
|
...args: Params
|
||||||
): Promise<Awaited<ReturnType<Func>>> {
|
): Promise<Awaited<ReturnType<Func>>> {
|
||||||
pageFunction = withSourcePuppeteerURLIfNone(this.$eval.name, pageFunction);
|
pageFunction = withSourcePuppeteerURLIfNone(this.$eval.name, pageFunction);
|
||||||
return this.mainFrame().$eval(selector, pageFunction, ...args);
|
return await this.mainFrame().$eval(selector, pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1173,7 +1173,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
...args: Params
|
...args: Params
|
||||||
): Promise<Awaited<ReturnType<Func>>> {
|
): Promise<Awaited<ReturnType<Func>>> {
|
||||||
pageFunction = withSourcePuppeteerURLIfNone(this.$$eval.name, pageFunction);
|
pageFunction = withSourcePuppeteerURLIfNone(this.$$eval.name, pageFunction);
|
||||||
return this.mainFrame().$$eval(selector, pageFunction, ...args);
|
return await this.mainFrame().$$eval(selector, pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1187,7 +1187,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
* @param expression - Expression to evaluate
|
* @param expression - Expression to evaluate
|
||||||
*/
|
*/
|
||||||
async $x(expression: string): Promise<Array<ElementHandle<Node>>> {
|
async $x(expression: string): Promise<Array<ElementHandle<Node>>> {
|
||||||
return this.mainFrame().$x(expression);
|
return await this.mainFrame().$x(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1232,7 +1232,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
async addScriptTag(
|
async addScriptTag(
|
||||||
options: FrameAddScriptTagOptions
|
options: FrameAddScriptTagOptions
|
||||||
): Promise<ElementHandle<HTMLScriptElement>> {
|
): Promise<ElementHandle<HTMLScriptElement>> {
|
||||||
return this.mainFrame().addScriptTag(options);
|
return await this.mainFrame().addScriptTag(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1254,7 +1254,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
async addStyleTag(
|
async addStyleTag(
|
||||||
options: FrameAddStyleTagOptions
|
options: FrameAddStyleTagOptions
|
||||||
): Promise<ElementHandle<HTMLStyleElement | HTMLLinkElement>> {
|
): Promise<ElementHandle<HTMLStyleElement | HTMLLinkElement>> {
|
||||||
return this.mainFrame().addStyleTag(options);
|
return await this.mainFrame().addStyleTag(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1780,7 +1780,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return firstValueFrom(
|
return await firstValueFrom(
|
||||||
merge(
|
merge(
|
||||||
fromEvent(this, PageEmittedEvents.FrameAttached) as Observable<Frame>,
|
fromEvent(this, PageEmittedEvents.FrameAttached) as Observable<Frame>,
|
||||||
fromEvent(this, PageEmittedEvents.FrameNavigated) as Observable<Frame>,
|
fromEvent(this, PageEmittedEvents.FrameNavigated) as Observable<Frame>,
|
||||||
|
@ -131,7 +131,7 @@ export abstract class Realm implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async title(): Promise<string> {
|
async title(): Promise<string> {
|
||||||
return this.evaluate(() => {
|
return await this.evaluate(() => {
|
||||||
return document.title;
|
return document.title;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ export class ARIAQueryHandler extends QueryHandler {
|
|||||||
selector,
|
selector,
|
||||||
{ariaQuerySelector}
|
{ariaQuerySelector}
|
||||||
) => {
|
) => {
|
||||||
return ariaQuerySelector(node, selector);
|
return await ariaQuerySelector(node, selector);
|
||||||
};
|
};
|
||||||
|
|
||||||
static override async *queryAll(
|
static override async *queryAll(
|
||||||
|
@ -425,7 +425,7 @@ export class CDPBrowser extends BrowserBase {
|
|||||||
* a default browser context.
|
* a default browser context.
|
||||||
*/
|
*/
|
||||||
override async newPage(): Promise<Page> {
|
override async newPage(): Promise<Page> {
|
||||||
return this.#defaultContext.newPage();
|
return await this.#defaultContext.newPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
override async _createPageInContext(contextId?: string): Promise<Page> {
|
override async _createPageInContext(contextId?: string): Promise<Page> {
|
||||||
|
@ -182,7 +182,7 @@ export class DeviceRequestPrompt {
|
|||||||
this.#updateDevicesHandle
|
this.#updateDevicesHandle
|
||||||
);
|
);
|
||||||
this.#handled = true;
|
this.#handled = true;
|
||||||
return this.#client.send('DeviceAccess.selectPrompt', {
|
return await this.#client.send('DeviceAccess.selectPrompt', {
|
||||||
id: this.#id,
|
id: this.#id,
|
||||||
deviceId: device.id,
|
deviceId: device.id,
|
||||||
});
|
});
|
||||||
@ -205,7 +205,7 @@ export class DeviceRequestPrompt {
|
|||||||
this.#updateDevicesHandle
|
this.#updateDevicesHandle
|
||||||
);
|
);
|
||||||
this.#handled = true;
|
this.#handled = true;
|
||||||
return this.#client.send('DeviceAccess.cancelPrompt', {id: this.#id});
|
return await this.#client.send('DeviceAccess.cancelPrompt', {id: this.#id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,18 +80,18 @@ export class CDPElementHandle<
|
|||||||
override async $<Selector extends string>(
|
override async $<Selector extends string>(
|
||||||
selector: Selector
|
selector: Selector
|
||||||
): Promise<CDPElementHandle<NodeFor<Selector>> | null> {
|
): Promise<CDPElementHandle<NodeFor<Selector>> | null> {
|
||||||
return super.$(selector) as Promise<CDPElementHandle<
|
return await (super.$(selector) as Promise<CDPElementHandle<
|
||||||
NodeFor<Selector>
|
NodeFor<Selector>
|
||||||
> | null>;
|
> | null>);
|
||||||
}
|
}
|
||||||
|
|
||||||
@throwIfDisposed()
|
@throwIfDisposed()
|
||||||
override async $$<Selector extends string>(
|
override async $$<Selector extends string>(
|
||||||
selector: Selector
|
selector: Selector
|
||||||
): Promise<Array<CDPElementHandle<NodeFor<Selector>>>> {
|
): Promise<Array<CDPElementHandle<NodeFor<Selector>>>> {
|
||||||
return super.$$(selector) as Promise<
|
return await (super.$$(selector) as Promise<
|
||||||
Array<CDPElementHandle<NodeFor<Selector>>>
|
Array<CDPElementHandle<NodeFor<Selector>>>
|
||||||
>;
|
>);
|
||||||
}
|
}
|
||||||
|
|
||||||
@throwIfDisposed()
|
@throwIfDisposed()
|
||||||
|
@ -105,7 +105,7 @@ export class ExecutionContext {
|
|||||||
selector: string
|
selector: string
|
||||||
): Promise<JSHandle<Node[]>> => {
|
): Promise<JSHandle<Node[]>> => {
|
||||||
const results = ARIAQueryHandler.queryAll(element, selector);
|
const results = ARIAQueryHandler.queryAll(element, selector);
|
||||||
return (element as unknown as CDPJSHandle<Node>)
|
return await (element as unknown as CDPJSHandle<Node>)
|
||||||
.executionContext()
|
.executionContext()
|
||||||
.evaluateHandle(
|
.evaluateHandle(
|
||||||
(...elements) => {
|
(...elements) => {
|
||||||
@ -250,7 +250,7 @@ export class ExecutionContext {
|
|||||||
pageFunction: Func | string,
|
pageFunction: Func | string,
|
||||||
...args: Params
|
...args: Params
|
||||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
||||||
return this.#evaluate(false, pageFunction, ...args);
|
return await this.#evaluate(false, pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #evaluate<
|
async #evaluate<
|
||||||
|
@ -256,7 +256,7 @@ export class CDPFrame extends Frame {
|
|||||||
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
|
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.isolatedRealm().setContent(html, options);
|
return await this.isolatedRealm().setContent(html, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
override url(): string {
|
override url(): string {
|
||||||
|
@ -170,14 +170,14 @@ export class HTTPRequest extends BaseHTTPRequest {
|
|||||||
const {action} = this.interceptResolutionState();
|
const {action} = this.interceptResolutionState();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'abort':
|
case 'abort':
|
||||||
return this.#abort(this.#abortErrorReason);
|
return await this.#abort(this.#abortErrorReason);
|
||||||
case 'respond':
|
case 'respond':
|
||||||
if (this.#responseForRequest === null) {
|
if (this.#responseForRequest === null) {
|
||||||
throw new Error('Response is missing for the interception');
|
throw new Error('Response is missing for the interception');
|
||||||
}
|
}
|
||||||
return this.#respond(this.#responseForRequest);
|
return await this.#respond(this.#responseForRequest);
|
||||||
case 'continue':
|
case 'continue':
|
||||||
return this.#continue(this.#continueRequestOverrides);
|
return await this.#continue(this.#continueRequestOverrides);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ export class HTTPRequest extends BaseHTTPRequest {
|
|||||||
assert(this.#allowInterception, 'Request Interception is not enabled!');
|
assert(this.#allowInterception, 'Request Interception is not enabled!');
|
||||||
assert(!this.#interceptionHandled, 'Request is already handled!');
|
assert(!this.#interceptionHandled, 'Request is already handled!');
|
||||||
if (priority === undefined) {
|
if (priority === undefined) {
|
||||||
return this.#continue(overrides);
|
return await this.#continue(overrides);
|
||||||
}
|
}
|
||||||
this.#continueRequestOverrides = overrides;
|
this.#continueRequestOverrides = overrides;
|
||||||
if (
|
if (
|
||||||
@ -301,7 +301,7 @@ export class HTTPRequest extends BaseHTTPRequest {
|
|||||||
assert(this.#allowInterception, 'Request Interception is not enabled!');
|
assert(this.#allowInterception, 'Request Interception is not enabled!');
|
||||||
assert(!this.#interceptionHandled, 'Request is already handled!');
|
assert(!this.#interceptionHandled, 'Request is already handled!');
|
||||||
if (priority === undefined) {
|
if (priority === undefined) {
|
||||||
return this.#respond(response);
|
return await this.#respond(response);
|
||||||
}
|
}
|
||||||
this.#responseForRequest = response;
|
this.#responseForRequest = response;
|
||||||
if (
|
if (
|
||||||
@ -384,7 +384,7 @@ export class HTTPRequest extends BaseHTTPRequest {
|
|||||||
assert(this.#allowInterception, 'Request Interception is not enabled!');
|
assert(this.#allowInterception, 'Request Interception is not enabled!');
|
||||||
assert(!this.#interceptionHandled, 'Request is already handled!');
|
assert(!this.#interceptionHandled, 'Request is already handled!');
|
||||||
if (priority === undefined) {
|
if (priority === undefined) {
|
||||||
return this.#abort(errorReason);
|
return await this.#abort(errorReason);
|
||||||
}
|
}
|
||||||
this.#abortErrorReason = errorReason;
|
this.#abortErrorReason = errorReason;
|
||||||
if (
|
if (
|
||||||
|
@ -493,7 +493,7 @@ export class CDPMouse extends Mouse {
|
|||||||
await this.move(start.x, start.y);
|
await this.move(start.x, start.y);
|
||||||
await this.down();
|
await this.down();
|
||||||
await this.move(target.x, target.y);
|
await this.move(target.x, target.y);
|
||||||
return promise;
|
return await promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
override async dragEnter(
|
override async dragEnter(
|
||||||
|
@ -164,7 +164,7 @@ export class IsolatedWorld extends Realm {
|
|||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
const context = await this.executionContext();
|
const context = await this.executionContext();
|
||||||
return context.evaluateHandle(pageFunction, ...args);
|
return await context.evaluateHandle(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async evaluate<
|
async evaluate<
|
||||||
@ -179,7 +179,7 @@ export class IsolatedWorld extends Realm {
|
|||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
const context = await this.executionContext();
|
const context = await this.executionContext();
|
||||||
return context.evaluate(pageFunction, ...args);
|
return await context.evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setContent(
|
async setContent(
|
||||||
|
@ -104,7 +104,7 @@ export class CDPJSHandle<T = unknown> extends JSHandle<T> {
|
|||||||
override async getProperty<K extends keyof T>(
|
override async getProperty<K extends keyof T>(
|
||||||
propertyName: HandleOr<K>
|
propertyName: HandleOr<K>
|
||||||
): Promise<HandleFor<T[K]>> {
|
): Promise<HandleFor<T[K]>> {
|
||||||
return this.evaluateHandle((object, propertyName) => {
|
return await this.evaluateHandle((object, propertyName) => {
|
||||||
return object[propertyName as K];
|
return object[propertyName as K];
|
||||||
}, propertyName);
|
}, propertyName);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,6 @@ export class LazyArg<T, Context = PuppeteerUtilWrapper> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async get(context: Context): Promise<T> {
|
async get(context: Context): Promise<T> {
|
||||||
return this.#get(context);
|
return await this.#get(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,17 +483,19 @@ export class CDPPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override async setRequestInterception(value: boolean): Promise<void> {
|
override async setRequestInterception(value: boolean): Promise<void> {
|
||||||
return this.#frameManager.networkManager.setRequestInterception(value);
|
return await this.#frameManager.networkManager.setRequestInterception(
|
||||||
|
value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async setBypassServiceWorker(bypass: boolean): Promise<void> {
|
override async setBypassServiceWorker(bypass: boolean): Promise<void> {
|
||||||
this.#serviceWorkerBypassed = bypass;
|
this.#serviceWorkerBypassed = bypass;
|
||||||
return this.#client.send('Network.setBypassServiceWorker', {bypass});
|
return await this.#client.send('Network.setBypassServiceWorker', {bypass});
|
||||||
}
|
}
|
||||||
|
|
||||||
override async setDragInterception(enabled: boolean): Promise<void> {
|
override async setDragInterception(enabled: boolean): Promise<void> {
|
||||||
this.#userDragInterceptionEnabled = enabled;
|
this.#userDragInterceptionEnabled = enabled;
|
||||||
return this.#client.send('Input.setInterceptDrags', {enabled});
|
return await this.#client.send('Input.setInterceptDrags', {enabled});
|
||||||
}
|
}
|
||||||
|
|
||||||
override setOfflineMode(enabled: boolean): Promise<void> {
|
override setOfflineMode(enabled: boolean): Promise<void> {
|
||||||
@ -532,7 +534,7 @@ export class CDPPage extends Page {
|
|||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
const context = await this.mainFrame().executionContext();
|
const context = await this.mainFrame().executionContext();
|
||||||
return context.evaluateHandle(pageFunction, ...args);
|
return await context.evaluateHandle(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async queryObjects<Prototype>(
|
override async queryObjects<Prototype>(
|
||||||
@ -684,20 +686,20 @@ export class CDPPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override async authenticate(credentials: Credentials): Promise<void> {
|
override async authenticate(credentials: Credentials): Promise<void> {
|
||||||
return this.#frameManager.networkManager.authenticate(credentials);
|
return await this.#frameManager.networkManager.authenticate(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async setExtraHTTPHeaders(
|
override async setExtraHTTPHeaders(
|
||||||
headers: Record<string, string>
|
headers: Record<string, string>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.#frameManager.networkManager.setExtraHTTPHeaders(headers);
|
return await this.#frameManager.networkManager.setExtraHTTPHeaders(headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async setUserAgent(
|
override async setUserAgent(
|
||||||
userAgent: string,
|
userAgent: string,
|
||||||
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata
|
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this.#frameManager.networkManager.setUserAgent(
|
return await this.#frameManager.networkManager.setUserAgent(
|
||||||
userAgent,
|
userAgent,
|
||||||
userAgentMetadata
|
userAgentMetadata
|
||||||
);
|
);
|
||||||
@ -896,7 +898,7 @@ export class CDPPage extends Page {
|
|||||||
options: {timeout?: number} = {}
|
options: {timeout?: number} = {}
|
||||||
): Promise<HTTPRequest> {
|
): Promise<HTTPRequest> {
|
||||||
const {timeout = this.#timeoutSettings.timeout()} = options;
|
const {timeout = this.#timeoutSettings.timeout()} = options;
|
||||||
return waitForEvent(
|
return await waitForEvent(
|
||||||
this.#frameManager.networkManager,
|
this.#frameManager.networkManager,
|
||||||
NetworkManagerEmittedEvents.Request,
|
NetworkManagerEmittedEvents.Request,
|
||||||
async request => {
|
async request => {
|
||||||
@ -920,7 +922,7 @@ export class CDPPage extends Page {
|
|||||||
options: {timeout?: number} = {}
|
options: {timeout?: number} = {}
|
||||||
): Promise<HTTPResponse> {
|
): Promise<HTTPResponse> {
|
||||||
const {timeout = this.#timeoutSettings.timeout()} = options;
|
const {timeout = this.#timeoutSettings.timeout()} = options;
|
||||||
return waitForEvent(
|
return await waitForEvent(
|
||||||
this.#frameManager.networkManager,
|
this.#frameManager.networkManager,
|
||||||
NetworkManagerEmittedEvents.Response,
|
NetworkManagerEmittedEvents.Response,
|
||||||
async response => {
|
async response => {
|
||||||
@ -953,13 +955,13 @@ export class CDPPage extends Page {
|
|||||||
override async goBack(
|
override async goBack(
|
||||||
options: WaitForOptions = {}
|
options: WaitForOptions = {}
|
||||||
): Promise<HTTPResponse | null> {
|
): Promise<HTTPResponse | null> {
|
||||||
return this.#go(-1, options);
|
return await this.#go(-1, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async goForward(
|
override async goForward(
|
||||||
options: WaitForOptions = {}
|
options: WaitForOptions = {}
|
||||||
): Promise<HTTPResponse | null> {
|
): Promise<HTTPResponse | null> {
|
||||||
return this.#go(+1, options);
|
return await this.#go(+1, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #go(
|
async #go(
|
||||||
@ -1044,7 +1046,7 @@ export class CDPPage extends Page {
|
|||||||
this.evaluate.name,
|
this.evaluate.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.mainFrame().evaluate(pageFunction, ...args);
|
return await this.mainFrame().evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async evaluateOnNewDocument<
|
override async evaluateOnNewDocument<
|
||||||
@ -1173,7 +1175,7 @@ export class CDPPage extends Page {
|
|||||||
'Expected options.clip.height not to be 0.'
|
'Expected options.clip.height not to be 0.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.#screenshotTaskQueue.postTask(() => {
|
return await this.#screenshotTaskQueue.postTask(() => {
|
||||||
return this.#screenshotTask(screenshotType, options);
|
return this.#screenshotTask(screenshotType, options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1311,7 +1313,7 @@ export class CDPPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(result.stream, '`stream` is missing from `Page.printToPDF');
|
assert(result.stream, '`stream` is missing from `Page.printToPDF');
|
||||||
return getReadableFromProtocolStream(this.#client, result.stream);
|
return await getReadableFromProtocolStream(this.#client, result.stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async pdf(options: PDFOptions = {}): Promise<Buffer> {
|
override async pdf(options: PDFOptions = {}): Promise<Buffer> {
|
||||||
@ -1323,7 +1325,7 @@ export class CDPPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override async title(): Promise<string> {
|
override async title(): Promise<string> {
|
||||||
return this.mainFrame().title();
|
return await this.mainFrame().title();
|
||||||
}
|
}
|
||||||
|
|
||||||
override async close(
|
override async close(
|
||||||
|
@ -291,7 +291,7 @@ export class WorkerTarget extends CDPTarget {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.#workerPromise;
|
return await this.#workerPromise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +142,6 @@ export class Tracing {
|
|||||||
});
|
});
|
||||||
await this.#client.send('Tracing.end');
|
await this.#client.send('Tracing.end');
|
||||||
this.#recording = false;
|
this.#recording = false;
|
||||||
return contentDeferred.valueOrThrow();
|
return await contentDeferred.valueOrThrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ export class WebWorker extends EventEmitter {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
async executionContext(): Promise<ExecutionContext> {
|
async executionContext(): Promise<ExecutionContext> {
|
||||||
return this.#executionContext.valueOrThrow();
|
return await this.#executionContext.valueOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,7 +156,7 @@ export class WebWorker extends EventEmitter {
|
|||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
const context = await this.#executionContext.valueOrThrow();
|
const context = await this.#executionContext.valueOrThrow();
|
||||||
return context.evaluate(pageFunction, ...args);
|
return await context.evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,6 +183,6 @@ export class WebWorker extends EventEmitter {
|
|||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
const context = await this.#executionContext.valueOrThrow();
|
const context = await this.#executionContext.valueOrThrow();
|
||||||
return context.evaluateHandle(pageFunction, ...args);
|
return await context.evaluateHandle(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ export class BrowsingContext extends Realm {
|
|||||||
method: T,
|
method: T,
|
||||||
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
|
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
|
||||||
): Promise<ProtocolMapping.Commands[T]['returnType']> {
|
): Promise<ProtocolMapping.Commands[T]['returnType']> {
|
||||||
return this.#cdpSession.send(method, ...paramArgs);
|
return await this.#cdpSession.send(method, ...paramArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
title(): Promise<string> {
|
title(): Promise<string> {
|
||||||
|
@ -70,7 +70,7 @@ export class BidiJSHandle<T = unknown> extends JSHandle<T> {
|
|||||||
this.evaluateHandle.name,
|
this.evaluateHandle.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.context().evaluateHandle(pageFunction, this, ...args);
|
return await this.context().evaluateHandle(pageFunction, this, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async getProperty<K extends keyof T>(
|
override async getProperty<K extends keyof T>(
|
||||||
|
@ -437,7 +437,7 @@ export class BidiPage extends Page {
|
|||||||
this.evaluateHandle.name,
|
this.evaluateHandle.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.mainFrame().evaluateHandle(pageFunction, ...args);
|
return await this.mainFrame().evaluateHandle(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async evaluate<
|
override async evaluate<
|
||||||
@ -451,7 +451,7 @@ export class BidiPage extends Page {
|
|||||||
this.evaluate.name,
|
this.evaluate.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.mainFrame().evaluate(pageFunction, ...args);
|
return await this.mainFrame().evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async goto(
|
override async goto(
|
||||||
@ -461,7 +461,7 @@ export class BidiPage extends Page {
|
|||||||
referrerPolicy?: string | undefined;
|
referrerPolicy?: string | undefined;
|
||||||
}
|
}
|
||||||
): Promise<HTTPResponse | null> {
|
): Promise<HTTPResponse | null> {
|
||||||
return this.mainFrame().goto(url, options);
|
return await this.mainFrame().goto(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async reload(
|
override async reload(
|
||||||
@ -510,7 +510,7 @@ export class BidiPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override async content(): Promise<string> {
|
override async content(): Promise<string> {
|
||||||
return this.mainFrame().content();
|
return await this.mainFrame().content();
|
||||||
}
|
}
|
||||||
|
|
||||||
override isJavaScriptEnabled(): boolean {
|
override isJavaScriptEnabled(): boolean {
|
||||||
|
@ -89,7 +89,7 @@ export class Realm extends EventEmitter {
|
|||||||
pageFunction: Func | string,
|
pageFunction: Func | string,
|
||||||
...args: Params
|
...args: Params
|
||||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
||||||
return this.#evaluate(false, pageFunction, ...args);
|
return await this.#evaluate(false, pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async evaluate<
|
async evaluate<
|
||||||
@ -99,7 +99,7 @@ export class Realm extends EventEmitter {
|
|||||||
pageFunction: Func | string,
|
pageFunction: Func | string,
|
||||||
...args: Params
|
...args: Params
|
||||||
): Promise<Awaited<ReturnType<Func>>> {
|
): Promise<Awaited<ReturnType<Func>>> {
|
||||||
return this.#evaluate(true, pageFunction, ...args);
|
return await this.#evaluate(true, pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #evaluate<
|
async #evaluate<
|
||||||
|
@ -83,7 +83,7 @@ export class Sandbox extends Realm {
|
|||||||
this.evaluateHandle.name,
|
this.evaluateHandle.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.#realm.evaluateHandle(pageFunction, ...args);
|
return await this.#realm.evaluateHandle(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async evaluate<
|
async evaluate<
|
||||||
@ -97,7 +97,7 @@ export class Sandbox extends Realm {
|
|||||||
this.evaluate.name,
|
this.evaluate.name,
|
||||||
pageFunction
|
pageFunction
|
||||||
);
|
);
|
||||||
return this.#realm.evaluate(pageFunction, ...args);
|
return await this.#realm.evaluate(pageFunction, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async adoptHandle<T extends JSHandle<Node>>(handle: T): Promise<T> {
|
async adoptHandle<T extends JSHandle<Node>>(handle: T): Promise<T> {
|
||||||
|
@ -623,7 +623,7 @@ export async function setPageContent(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// We rely upon the fact that document.open() will reset frame lifecycle with "init"
|
// We rely upon the fact that document.open() will reset frame lifecycle with "init"
|
||||||
// lifecycle event. @see https://crrev.com/608658
|
// lifecycle event. @see https://crrev.com/608658
|
||||||
return page.evaluate(html => {
|
return await page.evaluate(html => {
|
||||||
document.open();
|
document.open();
|
||||||
document.write(html);
|
document.write(html);
|
||||||
document.close();
|
document.close();
|
||||||
|
@ -674,7 +674,7 @@ describe('AriaQueryHandler', () => {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
const getIds = async (elements: ElementHandle[]) => {
|
const getIds = async (elements: ElementHandle[]) => {
|
||||||
return Promise.all(
|
return await Promise.all(
|
||||||
elements.map(element => {
|
elements.map(element => {
|
||||||
return element.evaluate((element: Element) => {
|
return element.evaluate((element: Element) => {
|
||||||
return element.id;
|
return element.id;
|
||||||
|
@ -341,7 +341,7 @@ describe('ElementHandle specs', function () {
|
|||||||
`;
|
`;
|
||||||
});
|
});
|
||||||
await page.evaluate(async () => {
|
await page.evaluate(async () => {
|
||||||
return new Promise(resolve => {
|
return await new Promise(resolve => {
|
||||||
return window.requestAnimationFrame(resolve);
|
return window.requestAnimationFrame(resolve);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -423,7 +423,7 @@ describe('ElementHandle specs', function () {
|
|||||||
`;
|
`;
|
||||||
});
|
});
|
||||||
await page.evaluate(async () => {
|
await page.evaluate(async () => {
|
||||||
return new Promise(resolve => {
|
return await new Promise(resolve => {
|
||||||
return window.requestAnimationFrame(resolve);
|
return window.requestAnimationFrame(resolve);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -195,7 +195,7 @@ describe('Evaluation specs', function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const result = await page.evaluate(async function () {
|
const result = await page.evaluate(async function () {
|
||||||
return await (globalThis as any).callController(9, 3);
|
return (globalThis as any).callController(9, 3);
|
||||||
});
|
});
|
||||||
expect(result).toBe(27);
|
expect(result).toBe(27);
|
||||||
});
|
});
|
||||||
|
@ -202,7 +202,7 @@ describe('input tests', function () {
|
|||||||
return (reader.onload = fulfill);
|
return (reader.onload = fulfill);
|
||||||
});
|
});
|
||||||
reader.readAsText(pick.files![0]!);
|
reader.readAsText(pick.files![0]!);
|
||||||
return promise.then(() => {
|
return await promise.then(() => {
|
||||||
return reader.result;
|
return reader.result;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -294,7 +294,7 @@ describe('input tests', function () {
|
|||||||
return (reader.onerror = fulfill);
|
return (reader.onerror = fulfill);
|
||||||
});
|
});
|
||||||
reader.readAsText(pick.files![0]!);
|
reader.readAsText(pick.files![0]!);
|
||||||
return promise.then(() => {
|
return await promise.then(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -231,7 +231,7 @@ describe('network', function () {
|
|||||||
waitUntil: 'networkidle2',
|
waitUntil: 'networkidle2',
|
||||||
});
|
});
|
||||||
await page.evaluate(async () => {
|
await page.evaluate(async () => {
|
||||||
return await (globalThis as any).activationPromise;
|
return (globalThis as any).activationPromise;
|
||||||
});
|
});
|
||||||
await page.reload();
|
await page.reload();
|
||||||
|
|
||||||
@ -871,7 +871,7 @@ describe('network', function () {
|
|||||||
waitUntil: 'networkidle2',
|
waitUntil: 'networkidle2',
|
||||||
});
|
});
|
||||||
await page.evaluate(async () => {
|
await page.evaluate(async () => {
|
||||||
return await (globalThis as any).activationPromise;
|
return (globalThis as any).activationPromise;
|
||||||
});
|
});
|
||||||
await page.reload({
|
await page.reload({
|
||||||
waitUntil: 'networkidle2',
|
waitUntil: 'networkidle2',
|
||||||
|
@ -732,7 +732,7 @@ describe('Page', function () {
|
|||||||
const [message] = await Promise.all([
|
const [message] = await Promise.all([
|
||||||
waitEvent(page, 'console'),
|
waitEvent(page, 'console'),
|
||||||
page.evaluate(async (url: string) => {
|
page.evaluate(async (url: string) => {
|
||||||
return fetch(url).catch(() => {});
|
return await fetch(url).catch(() => {});
|
||||||
}, server.EMPTY_PAGE),
|
}, server.EMPTY_PAGE),
|
||||||
]);
|
]);
|
||||||
expect(message.text()).toContain('Access-Control-Allow-Origin');
|
expect(message.text()).toContain('Access-Control-Allow-Origin');
|
||||||
@ -1181,7 +1181,7 @@ describe('Page', function () {
|
|||||||
return a * b;
|
return a * b;
|
||||||
});
|
});
|
||||||
const result = await page.evaluate(async function () {
|
const result = await page.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(9, 4);
|
return (globalThis as any).compute(9, 4);
|
||||||
});
|
});
|
||||||
expect(result).toBe(36);
|
expect(result).toBe(36);
|
||||||
});
|
});
|
||||||
@ -1193,7 +1193,9 @@ describe('Page', function () {
|
|||||||
});
|
});
|
||||||
const {message, stack} = await page.evaluate(async () => {
|
const {message, stack} = await page.evaluate(async () => {
|
||||||
try {
|
try {
|
||||||
return await (globalThis as any).woof();
|
return await (
|
||||||
|
globalThis as unknown as {woof(): Promise<never>}
|
||||||
|
).woof();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
message: (error as Error).message,
|
message: (error as Error).message,
|
||||||
@ -1242,7 +1244,7 @@ describe('Page', function () {
|
|||||||
|
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
const result = await page.evaluate(async function () {
|
const result = await page.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(9, 4);
|
return (globalThis as any).compute(9, 4);
|
||||||
});
|
});
|
||||||
expect(result).toBe(36);
|
expect(result).toBe(36);
|
||||||
});
|
});
|
||||||
@ -1254,7 +1256,7 @@ describe('Page', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const result = await page.evaluate(async function () {
|
const result = await page.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(3, 5);
|
return (globalThis as any).compute(3, 5);
|
||||||
});
|
});
|
||||||
expect(result).toBe(15);
|
expect(result).toBe(15);
|
||||||
});
|
});
|
||||||
@ -1268,7 +1270,7 @@ describe('Page', function () {
|
|||||||
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
||||||
const frame = page.frames()[1]!;
|
const frame = page.frames()[1]!;
|
||||||
const result = await frame.evaluate(async function () {
|
const result = await frame.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(3, 5);
|
return (globalThis as any).compute(3, 5);
|
||||||
});
|
});
|
||||||
expect(result).toBe(15);
|
expect(result).toBe(15);
|
||||||
});
|
});
|
||||||
@ -1282,7 +1284,7 @@ describe('Page', function () {
|
|||||||
|
|
||||||
const frame = page.frames()[1]!;
|
const frame = page.frames()[1]!;
|
||||||
const result = await frame.evaluate(async function () {
|
const result = await frame.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(3, 5);
|
return (globalThis as any).compute(3, 5);
|
||||||
});
|
});
|
||||||
expect(result).toBe(15);
|
expect(result).toBe(15);
|
||||||
});
|
});
|
||||||
@ -1298,7 +1300,7 @@ describe('Page', function () {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.evaluate(async function () {
|
page.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(3, 5);
|
return (globalThis as any).compute(3, 5);
|
||||||
})
|
})
|
||||||
).resolves.toEqual(15);
|
).resolves.toEqual(15);
|
||||||
});
|
});
|
||||||
@ -1326,7 +1328,7 @@ describe('Page', function () {
|
|||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
await page.exposeFunction('compute', moduleObject);
|
await page.exposeFunction('compute', moduleObject);
|
||||||
const result = await page.evaluate(async function () {
|
const result = await page.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(9, 4);
|
return (globalThis as any).compute(9, 4);
|
||||||
});
|
});
|
||||||
expect(result).toBe(36);
|
expect(result).toBe(36);
|
||||||
});
|
});
|
||||||
@ -1340,7 +1342,7 @@ describe('Page', function () {
|
|||||||
return a * b;
|
return a * b;
|
||||||
});
|
});
|
||||||
const result = await page.evaluate(async function () {
|
const result = await page.evaluate(async function () {
|
||||||
return await (globalThis as any).compute(9, 4);
|
return (globalThis as any).compute(9, 4);
|
||||||
});
|
});
|
||||||
expect(result).toBe(36);
|
expect(result).toBe(36);
|
||||||
await page.removeExposedFunction('compute');
|
await page.removeExposedFunction('compute');
|
||||||
|
@ -62,28 +62,28 @@ class JobBuilder {
|
|||||||
console.log(`Running job ${this.#name}...`);
|
console.log(`Running job ${this.#name}...`);
|
||||||
// For debugging.
|
// For debugging.
|
||||||
if (this.#force) {
|
if (this.#force) {
|
||||||
return this.#run();
|
return await this.#run();
|
||||||
}
|
}
|
||||||
// In case we deleted an output file on purpose.
|
// In case we deleted an output file on purpose.
|
||||||
if (!this.getOutputStats()) {
|
if (!this.getOutputStats()) {
|
||||||
return this.#run();
|
return await this.#run();
|
||||||
}
|
}
|
||||||
// Run if the job has a value, but it changes.
|
// Run if the job has a value, but it changes.
|
||||||
if (this.#value) {
|
if (this.#value) {
|
||||||
if (!(await this.isValueDifferent())) {
|
if (!(await this.isValueDifferent())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this.#run();
|
return await this.#run();
|
||||||
}
|
}
|
||||||
// Always run when there is no output.
|
// Always run when there is no output.
|
||||||
if (!this.#outputs.length) {
|
if (!this.#outputs.length) {
|
||||||
return this.#run();
|
return await this.#run();
|
||||||
}
|
}
|
||||||
// Make-like comparator.
|
// Make-like comparator.
|
||||||
if (!(await this.areInputsNewer())) {
|
if (!(await this.areInputsNewer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this.#run();
|
return await this.#run();
|
||||||
}
|
}
|
||||||
|
|
||||||
async isValueDifferent(): Promise<boolean> {
|
async isValueDifferent(): Promise<boolean> {
|
||||||
|
Loading…
Reference in New Issue
Block a user