chore: enable 'return-await` (#10832)

This commit is contained in:
jrandolf 2023-09-01 09:49:33 +02:00 committed by GitHub
parent 25db3f1188
commit 7e74439c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 112 additions and 106 deletions

View File

@ -218,6 +218,8 @@ module.exports = {
{ignoreVoid: true, ignoreIIFE: true},
],
'@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: [
{

View File

@ -37,12 +37,12 @@ jobs:
- uses: google/wireit@f3a3c79c553122e2fe5829eeac7d815326502903 # setup-github-actions-caching/v1
- name: Check code
run: npm run check
- name: Lint code
run: npm run lint
- name: Validate licenses
run: npm run validate-licenses
- name: Build every package
run: npm run build
- name: Lint code
run: npm run lint
- name: Generate documents
run: npm run docs
- name: Check if autogenerated docs differ

View File

@ -305,7 +305,7 @@ export class Process {
if (!this.#exited) {
this.kill();
}
return this.#browserProcessExiting;
return await this.#browserProcessExiting;
}
hasClosed(): Promise<void> {

View File

@ -179,14 +179,14 @@ export abstract class ElementHandle<
override async getProperty<K extends keyof ElementType>(
propertyName: HandleOr<K>
): Promise<HandleFor<ElementType[K]>> {
return this.handle.getProperty(propertyName);
return await this.handle.getProperty(propertyName);
}
/**
* @internal
*/
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,
...args: Params
): 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
*/
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>>>> {
const {updatedSelector, QueryHandler} =
getQueryHandlerAndSelector(selector);
return AsyncIterableUtil.collect(
return await (AsyncIterableUtil.collect(
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('//')) {
expression = `.${expression}`;
}
return this.$$(`xpath/${expression}`);
return await this.$$(`xpath/${expression}`);
}
/**
@ -491,7 +491,7 @@ export abstract class ElementHandle<
* {@link ElementHandle.waitForSelector}.
*/
async isVisible(): Promise<boolean> {
return this.#checkVisibility(true);
return await this.#checkVisibility(true);
}
/**
@ -499,7 +499,7 @@ export abstract class ElementHandle<
* {@link ElementHandle.waitForSelector}.
*/
async isHidden(): Promise<boolean> {
return this.#checkVisibility(false);
return await this.#checkVisibility(false);
}
/**
@ -575,7 +575,7 @@ export abstract class ElementHandle<
if (xpath.startsWith('//')) {
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);
if (!(element instanceof HTMLSelectElement)) {
throw new Error('Element is not a <select> element.');

View File

@ -367,7 +367,7 @@ export abstract class Frame extends EventEmitter {
this.evaluateHandle.name,
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,
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>(
selector: Selector
): 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>(
selector: 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('//')) {
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';
return this.mainRealm().transferHandle(
return await this.mainRealm().transferHandle(
await this.isolatedRealm().evaluateHandle(
async ({Deferred}, {url, id, type, content}) => {
const deferred = Deferred.create<void>();
@ -859,7 +859,7 @@ export abstract class Frame extends EventEmitter {
options.content = content;
}
return this.mainRealm().transferHandle(
return await this.mainRealm().transferHandle(
await this.isolatedRealm().evaluateHandle(
async ({Deferred}, {url, content}) => {
const deferred = Deferred.create<void>();

View File

@ -903,7 +903,7 @@ export class Page extends EventEmitter implements AsyncDisposable, Disposable {
async $<Selector extends string>(
selector: Selector
): 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>(
selector: 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
): Promise<Awaited<ReturnType<Func>>> {
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
): Promise<Awaited<ReturnType<Func>>> {
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
*/
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(
options: FrameAddScriptTagOptions
): 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(
options: FrameAddStyleTagOptions
): 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(
fromEvent(this, PageEmittedEvents.FrameAttached) as Observable<Frame>,
fromEvent(this, PageEmittedEvents.FrameNavigated) as Observable<Frame>,

View File

@ -131,7 +131,7 @@ export abstract class Realm implements Disposable {
}
async title(): Promise<string> {
return this.evaluate(() => {
return await this.evaluate(() => {
return document.title;
});
}

View File

@ -99,7 +99,7 @@ export class ARIAQueryHandler extends QueryHandler {
selector,
{ariaQuerySelector}
) => {
return ariaQuerySelector(node, selector);
return await ariaQuerySelector(node, selector);
};
static override async *queryAll(

View File

@ -425,7 +425,7 @@ export class CDPBrowser extends BrowserBase {
* a default browser context.
*/
override async newPage(): Promise<Page> {
return this.#defaultContext.newPage();
return await this.#defaultContext.newPage();
}
override async _createPageInContext(contextId?: string): Promise<Page> {

View File

@ -182,7 +182,7 @@ export class DeviceRequestPrompt {
this.#updateDevicesHandle
);
this.#handled = true;
return this.#client.send('DeviceAccess.selectPrompt', {
return await this.#client.send('DeviceAccess.selectPrompt', {
id: this.#id,
deviceId: device.id,
});
@ -205,7 +205,7 @@ export class DeviceRequestPrompt {
this.#updateDevicesHandle
);
this.#handled = true;
return this.#client.send('DeviceAccess.cancelPrompt', {id: this.#id});
return await this.#client.send('DeviceAccess.cancelPrompt', {id: this.#id});
}
}

View File

@ -80,18 +80,18 @@ export class CDPElementHandle<
override async $<Selector extends string>(
selector: Selector
): Promise<CDPElementHandle<NodeFor<Selector>> | null> {
return super.$(selector) as Promise<CDPElementHandle<
return await (super.$(selector) as Promise<CDPElementHandle<
NodeFor<Selector>
> | null>;
> | null>);
}
@throwIfDisposed()
override async $$<Selector extends string>(
selector: Selector
): Promise<Array<CDPElementHandle<NodeFor<Selector>>>> {
return super.$$(selector) as Promise<
return await (super.$$(selector) as Promise<
Array<CDPElementHandle<NodeFor<Selector>>>
>;
>);
}
@throwIfDisposed()

View File

@ -105,7 +105,7 @@ export class ExecutionContext {
selector: string
): Promise<JSHandle<Node[]>> => {
const results = ARIAQueryHandler.queryAll(element, selector);
return (element as unknown as CDPJSHandle<Node>)
return await (element as unknown as CDPJSHandle<Node>)
.executionContext()
.evaluateHandle(
(...elements) => {
@ -250,7 +250,7 @@ export class ExecutionContext {
pageFunction: Func | string,
...args: Params
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
return this.#evaluate(false, pageFunction, ...args);
return await this.#evaluate(false, pageFunction, ...args);
}
async #evaluate<

View File

@ -256,7 +256,7 @@ export class CDPFrame extends Frame {
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
} = {}
): Promise<void> {
return this.isolatedRealm().setContent(html, options);
return await this.isolatedRealm().setContent(html, options);
}
override url(): string {

View File

@ -170,14 +170,14 @@ export class HTTPRequest extends BaseHTTPRequest {
const {action} = this.interceptResolutionState();
switch (action) {
case 'abort':
return this.#abort(this.#abortErrorReason);
return await this.#abort(this.#abortErrorReason);
case 'respond':
if (this.#responseForRequest === null) {
throw new Error('Response is missing for the interception');
}
return this.#respond(this.#responseForRequest);
return await this.#respond(this.#responseForRequest);
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.#interceptionHandled, 'Request is already handled!');
if (priority === undefined) {
return this.#continue(overrides);
return await this.#continue(overrides);
}
this.#continueRequestOverrides = overrides;
if (
@ -301,7 +301,7 @@ export class HTTPRequest extends BaseHTTPRequest {
assert(this.#allowInterception, 'Request Interception is not enabled!');
assert(!this.#interceptionHandled, 'Request is already handled!');
if (priority === undefined) {
return this.#respond(response);
return await this.#respond(response);
}
this.#responseForRequest = response;
if (
@ -384,7 +384,7 @@ export class HTTPRequest extends BaseHTTPRequest {
assert(this.#allowInterception, 'Request Interception is not enabled!');
assert(!this.#interceptionHandled, 'Request is already handled!');
if (priority === undefined) {
return this.#abort(errorReason);
return await this.#abort(errorReason);
}
this.#abortErrorReason = errorReason;
if (

View File

@ -493,7 +493,7 @@ export class CDPMouse extends Mouse {
await this.move(start.x, start.y);
await this.down();
await this.move(target.x, target.y);
return promise;
return await promise;
}
override async dragEnter(

View File

@ -164,7 +164,7 @@ export class IsolatedWorld extends Realm {
pageFunction
);
const context = await this.executionContext();
return context.evaluateHandle(pageFunction, ...args);
return await context.evaluateHandle(pageFunction, ...args);
}
async evaluate<
@ -179,7 +179,7 @@ export class IsolatedWorld extends Realm {
pageFunction
);
const context = await this.executionContext();
return context.evaluate(pageFunction, ...args);
return await context.evaluate(pageFunction, ...args);
}
async setContent(

View File

@ -104,7 +104,7 @@ export class CDPJSHandle<T = unknown> extends JSHandle<T> {
override async getProperty<K extends keyof T>(
propertyName: HandleOr<K>
): Promise<HandleFor<T[K]>> {
return this.evaluateHandle((object, propertyName) => {
return await this.evaluateHandle((object, propertyName) => {
return object[propertyName as K];
}, propertyName);
}

View File

@ -42,6 +42,6 @@ export class LazyArg<T, Context = PuppeteerUtilWrapper> {
}
async get(context: Context): Promise<T> {
return this.#get(context);
return await this.#get(context);
}
}

View File

@ -483,17 +483,19 @@ export class CDPPage extends Page {
}
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> {
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> {
this.#userDragInterceptionEnabled = enabled;
return this.#client.send('Input.setInterceptDrags', {enabled});
return await this.#client.send('Input.setInterceptDrags', {enabled});
}
override setOfflineMode(enabled: boolean): Promise<void> {
@ -532,7 +534,7 @@ export class CDPPage extends Page {
pageFunction
);
const context = await this.mainFrame().executionContext();
return context.evaluateHandle(pageFunction, ...args);
return await context.evaluateHandle(pageFunction, ...args);
}
override async queryObjects<Prototype>(
@ -684,20 +686,20 @@ export class CDPPage extends Page {
}
override async authenticate(credentials: Credentials): Promise<void> {
return this.#frameManager.networkManager.authenticate(credentials);
return await this.#frameManager.networkManager.authenticate(credentials);
}
override async setExtraHTTPHeaders(
headers: Record<string, string>
): Promise<void> {
return this.#frameManager.networkManager.setExtraHTTPHeaders(headers);
return await this.#frameManager.networkManager.setExtraHTTPHeaders(headers);
}
override async setUserAgent(
userAgent: string,
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata
): Promise<void> {
return this.#frameManager.networkManager.setUserAgent(
return await this.#frameManager.networkManager.setUserAgent(
userAgent,
userAgentMetadata
);
@ -896,7 +898,7 @@ export class CDPPage extends Page {
options: {timeout?: number} = {}
): Promise<HTTPRequest> {
const {timeout = this.#timeoutSettings.timeout()} = options;
return waitForEvent(
return await waitForEvent(
this.#frameManager.networkManager,
NetworkManagerEmittedEvents.Request,
async request => {
@ -920,7 +922,7 @@ export class CDPPage extends Page {
options: {timeout?: number} = {}
): Promise<HTTPResponse> {
const {timeout = this.#timeoutSettings.timeout()} = options;
return waitForEvent(
return await waitForEvent(
this.#frameManager.networkManager,
NetworkManagerEmittedEvents.Response,
async response => {
@ -953,13 +955,13 @@ export class CDPPage extends Page {
override async goBack(
options: WaitForOptions = {}
): Promise<HTTPResponse | null> {
return this.#go(-1, options);
return await this.#go(-1, options);
}
override async goForward(
options: WaitForOptions = {}
): Promise<HTTPResponse | null> {
return this.#go(+1, options);
return await this.#go(+1, options);
}
async #go(
@ -1044,7 +1046,7 @@ export class CDPPage extends Page {
this.evaluate.name,
pageFunction
);
return this.mainFrame().evaluate(pageFunction, ...args);
return await this.mainFrame().evaluate(pageFunction, ...args);
}
override async evaluateOnNewDocument<
@ -1173,7 +1175,7 @@ export class CDPPage extends Page {
'Expected options.clip.height not to be 0.'
);
}
return this.#screenshotTaskQueue.postTask(() => {
return await this.#screenshotTaskQueue.postTask(() => {
return this.#screenshotTask(screenshotType, options);
});
}
@ -1311,7 +1313,7 @@ export class CDPPage extends Page {
}
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> {
@ -1323,7 +1325,7 @@ export class CDPPage extends Page {
}
override async title(): Promise<string> {
return this.mainFrame().title();
return await this.mainFrame().title();
}
override async close(

View File

@ -291,7 +291,7 @@ export class WorkerTarget extends CDPTarget {
);
});
}
return this.#workerPromise;
return await this.#workerPromise;
}
}

View File

@ -142,6 +142,6 @@ export class Tracing {
});
await this.#client.send('Tracing.end');
this.#recording = false;
return contentDeferred.valueOrThrow();
return await contentDeferred.valueOrThrow();
}
}

View File

@ -113,7 +113,7 @@ export class WebWorker extends EventEmitter {
* @internal
*/
async executionContext(): Promise<ExecutionContext> {
return this.#executionContext.valueOrThrow();
return await this.#executionContext.valueOrThrow();
}
/**
@ -156,7 +156,7 @@ export class WebWorker extends EventEmitter {
pageFunction
);
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
);
const context = await this.#executionContext.valueOrThrow();
return context.evaluateHandle(pageFunction, ...args);
return await context.evaluateHandle(pageFunction, ...args);
}
}

View File

@ -281,7 +281,7 @@ export class BrowsingContext extends Realm {
method: T,
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']> {
return this.#cdpSession.send(method, ...paramArgs);
return await this.#cdpSession.send(method, ...paramArgs);
}
title(): Promise<string> {

View File

@ -70,7 +70,7 @@ export class BidiJSHandle<T = unknown> extends JSHandle<T> {
this.evaluateHandle.name,
pageFunction
);
return this.context().evaluateHandle(pageFunction, this, ...args);
return await this.context().evaluateHandle(pageFunction, this, ...args);
}
override async getProperty<K extends keyof T>(

View File

@ -437,7 +437,7 @@ export class BidiPage extends Page {
this.evaluateHandle.name,
pageFunction
);
return this.mainFrame().evaluateHandle(pageFunction, ...args);
return await this.mainFrame().evaluateHandle(pageFunction, ...args);
}
override async evaluate<
@ -451,7 +451,7 @@ export class BidiPage extends Page {
this.evaluate.name,
pageFunction
);
return this.mainFrame().evaluate(pageFunction, ...args);
return await this.mainFrame().evaluate(pageFunction, ...args);
}
override async goto(
@ -461,7 +461,7 @@ export class BidiPage extends Page {
referrerPolicy?: string | undefined;
}
): Promise<HTTPResponse | null> {
return this.mainFrame().goto(url, options);
return await this.mainFrame().goto(url, options);
}
override async reload(
@ -510,7 +510,7 @@ export class BidiPage extends Page {
}
override async content(): Promise<string> {
return this.mainFrame().content();
return await this.mainFrame().content();
}
override isJavaScriptEnabled(): boolean {

View File

@ -89,7 +89,7 @@ export class Realm extends EventEmitter {
pageFunction: Func | string,
...args: Params
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
return this.#evaluate(false, pageFunction, ...args);
return await this.#evaluate(false, pageFunction, ...args);
}
async evaluate<
@ -99,7 +99,7 @@ export class Realm extends EventEmitter {
pageFunction: Func | string,
...args: Params
): Promise<Awaited<ReturnType<Func>>> {
return this.#evaluate(true, pageFunction, ...args);
return await this.#evaluate(true, pageFunction, ...args);
}
async #evaluate<

View File

@ -83,7 +83,7 @@ export class Sandbox extends Realm {
this.evaluateHandle.name,
pageFunction
);
return this.#realm.evaluateHandle(pageFunction, ...args);
return await this.#realm.evaluateHandle(pageFunction, ...args);
}
async evaluate<
@ -97,7 +97,7 @@ export class Sandbox extends Realm {
this.evaluate.name,
pageFunction
);
return this.#realm.evaluate(pageFunction, ...args);
return await this.#realm.evaluate(pageFunction, ...args);
}
async adoptHandle<T extends JSHandle<Node>>(handle: T): Promise<T> {

View File

@ -623,7 +623,7 @@ export async function setPageContent(
): Promise<void> {
// We rely upon the fact that document.open() will reset frame lifecycle with "init"
// lifecycle event. @see https://crrev.com/608658
return page.evaluate(html => {
return await page.evaluate(html => {
document.open();
document.write(html);
document.close();

View File

@ -674,7 +674,7 @@ describe('AriaQueryHandler', () => {
return state;
}
const getIds = async (elements: ElementHandle[]) => {
return Promise.all(
return await Promise.all(
elements.map(element => {
return element.evaluate((element: Element) => {
return element.id;

View File

@ -341,7 +341,7 @@ describe('ElementHandle specs', function () {
`;
});
await page.evaluate(async () => {
return new Promise(resolve => {
return await new Promise(resolve => {
return window.requestAnimationFrame(resolve);
});
});
@ -423,7 +423,7 @@ describe('ElementHandle specs', function () {
`;
});
await page.evaluate(async () => {
return new Promise(resolve => {
return await new Promise(resolve => {
return window.requestAnimationFrame(resolve);
});
});

View File

@ -195,7 +195,7 @@ describe('Evaluation specs', 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);
});

View File

@ -202,7 +202,7 @@ describe('input tests', function () {
return (reader.onload = fulfill);
});
reader.readAsText(pick.files![0]!);
return promise.then(() => {
return await promise.then(() => {
return reader.result;
});
})
@ -294,7 +294,7 @@ describe('input tests', function () {
return (reader.onerror = fulfill);
});
reader.readAsText(pick.files![0]!);
return promise.then(() => {
return await promise.then(() => {
return false;
});
})

View File

@ -231,7 +231,7 @@ describe('network', function () {
waitUntil: 'networkidle2',
});
await page.evaluate(async () => {
return await (globalThis as any).activationPromise;
return (globalThis as any).activationPromise;
});
await page.reload();
@ -871,7 +871,7 @@ describe('network', function () {
waitUntil: 'networkidle2',
});
await page.evaluate(async () => {
return await (globalThis as any).activationPromise;
return (globalThis as any).activationPromise;
});
await page.reload({
waitUntil: 'networkidle2',

View File

@ -732,7 +732,7 @@ describe('Page', function () {
const [message] = await Promise.all([
waitEvent(page, 'console'),
page.evaluate(async (url: string) => {
return fetch(url).catch(() => {});
return await fetch(url).catch(() => {});
}, server.EMPTY_PAGE),
]);
expect(message.text()).toContain('Access-Control-Allow-Origin');
@ -1181,7 +1181,7 @@ describe('Page', function () {
return a * b;
});
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);
});
@ -1193,7 +1193,9 @@ describe('Page', function () {
});
const {message, stack} = await page.evaluate(async () => {
try {
return await (globalThis as any).woof();
return await (
globalThis as unknown as {woof(): Promise<never>}
).woof();
} catch (error) {
return {
message: (error as Error).message,
@ -1242,7 +1244,7 @@ describe('Page', function () {
await page.goto(server.EMPTY_PAGE);
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);
});
@ -1254,7 +1256,7 @@ describe('Page', 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);
});
@ -1268,7 +1270,7 @@ describe('Page', function () {
await page.goto(server.PREFIX + '/frames/nested-frames.html');
const frame = page.frames()[1]!;
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);
});
@ -1282,7 +1284,7 @@ describe('Page', function () {
const frame = page.frames()[1]!;
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);
});
@ -1298,7 +1300,7 @@ describe('Page', function () {
await expect(
page.evaluate(async function () {
return await (globalThis as any).compute(3, 5);
return (globalThis as any).compute(3, 5);
})
).resolves.toEqual(15);
});
@ -1326,7 +1328,7 @@ describe('Page', function () {
await page.goto(server.EMPTY_PAGE);
await page.exposeFunction('compute', moduleObject);
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);
});
@ -1340,7 +1342,7 @@ describe('Page', function () {
return a * b;
});
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);
await page.removeExposedFunction('compute');

View File

@ -62,28 +62,28 @@ class JobBuilder {
console.log(`Running job ${this.#name}...`);
// For debugging.
if (this.#force) {
return this.#run();
return await this.#run();
}
// In case we deleted an output file on purpose.
if (!this.getOutputStats()) {
return this.#run();
return await this.#run();
}
// Run if the job has a value, but it changes.
if (this.#value) {
if (!(await this.isValueDifferent())) {
return;
}
return this.#run();
return await this.#run();
}
// Always run when there is no output.
if (!this.#outputs.length) {
return this.#run();
return await this.#run();
}
// Make-like comparator.
if (!(await this.areInputsNewer())) {
return;
}
return this.#run();
return await this.#run();
}
async isValueDifferent(): Promise<boolean> {