diff --git a/src/chromium/crPage.ts b/src/chromium/crPage.ts index 0014db703a..de04ad6874 100644 --- a/src/chromium/crPage.ts +++ b/src/chromium/crPage.ts @@ -483,7 +483,7 @@ export class CRPage implements PageDelegate { }); const frameId = nodeInfo && typeof nodeInfo.node.frameId === 'string' ? nodeInfo.node.frameId : null; - await documentElement.dispose(); + documentElement.dispose(); return frameId; } diff --git a/src/chromium/crProtocolHelper.ts b/src/chromium/crProtocolHelper.ts index 4fbef2d7e7..d49d312364 100644 --- a/src/chromium/crProtocolHelper.ts +++ b/src/chromium/crProtocolHelper.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { assert, debugError } from '../helper'; +import { assert } from '../helper'; import { CRSession } from './crConnection'; import { Protocol } from './protocol'; import * as platform from '../platform'; @@ -58,11 +58,7 @@ export function valueFromRemoteObject(remoteObject: Protocol.Runtime.RemoteObjec export async function releaseObject(client: CRSession, remoteObject: Protocol.Runtime.RemoteObject) { if (!remoteObject.objectId) return; - await client.send('Runtime.releaseObject', {objectId: remoteObject.objectId}).catch(error => { - // Exceptions might happen in case of a page been navigated or closed. - // Swallow these since they are harmless and we don't leak anything in this case. - debugError(error); - }); + await client.send('Runtime.releaseObject', {objectId: remoteObject.objectId}).catch(error => {}); } export async function readProtocolStream(client: CRSession, handle: string, path: string | null): Promise { diff --git a/src/dom.ts b/src/dom.ts index 3e415a8d4e..e0c17abc73 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -67,7 +67,7 @@ export class FrameExecutionContext extends js.ExecutionContext { try { result = await this._delegate.evaluate(this, returnByValue, pageFunction, ...adopted); } finally { - await Promise.all(toDispose.map(handlePromise => handlePromise.then(handle => handle.dispose()))); + toDispose.map(handlePromise => handlePromise.then(handle => handle.dispose())); } return result; } @@ -105,7 +105,7 @@ export class FrameExecutionContext extends js.ExecutionContext { await this._injected(), selector, scope ); if (!handle.asElement()) - await handle.dispose(); + handle.dispose(); return handle.asElement() as ElementHandle; } @@ -120,14 +120,14 @@ export class FrameExecutionContext extends js.ExecutionContext { async _$$(selector: string, scope?: ElementHandle): Promise[]> { const arrayHandle = await this._$array(selector, scope); const properties = await arrayHandle.getProperties(); - await arrayHandle.dispose(); + arrayHandle.dispose(); const result: ElementHandle[] = []; for (const property of properties.values()) { const elementHandle = property.asElement() as ElementHandle; if (elementHandle) result.push(elementHandle); else - await property.dispose(); + property.dispose(); } return result; } @@ -378,14 +378,14 @@ export class ElementHandle extends js.JSHandle { if (!elementHandle) throw new Error(`Error: failed to find element matching selector "${selector}"`); const result = await elementHandle.evaluate(pageFunction, ...args as any); - await elementHandle.dispose(); + elementHandle.dispose(); return result; } $$eval: types.$$Eval = async (selector, pageFunction, ...args) => { const arrayHandle = await this._context._$array(selector, this); const result = await arrayHandle.evaluate(pageFunction, ...args as any); - await arrayHandle.dispose(); + arrayHandle.dispose(); return result; } diff --git a/src/firefox/ffExecutionContext.ts b/src/firefox/ffExecutionContext.ts index 24c9e28b92..c7db7ca2fa 100644 --- a/src/firefox/ffExecutionContext.ts +++ b/src/firefox/ffExecutionContext.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import {helper, debugError} from '../helper'; +import { helper } from '../helper'; import * as js from '../javascript'; import { FFSession } from './ffConnection'; import { Protocol } from './protocol'; @@ -122,11 +122,7 @@ export class FFExecutionContext implements js.ExecutionContextDelegate { await this._session.send('Runtime.disposeObject', { executionContextId: this._executionContextId, objectId: handle._remoteObject.objectId, - }).catch(error => { - // Exceptions might happen in case of a page been navigated or closed. - // Swallow these since they are harmless and we don't leak anything in this case. - debugError(error); - }); + }).catch(error => {}); } async handleJSONValue(handle: js.JSHandle): Promise { diff --git a/src/firefox/ffPage.ts b/src/firefox/ffPage.ts index ea9a271f09..d2882997b1 100644 --- a/src/firefox/ffPage.ts +++ b/src/firefox/ffPage.ts @@ -447,7 +447,7 @@ export class FFPage implements PageDelegate { return { handle, frame }; })); const result = items.find(item => item.frame === frame); - await Promise.all(items.map(item => item === result ? Promise.resolve() : item.handle.dispose())); + items.map(item => item === result ? Promise.resolve() : item.handle.dispose()); if (!result) throw new Error('Frame has been detached.'); return result.handle; diff --git a/src/frames.ts b/src/frames.ts index 99918b2812..117e9b5939 100644 --- a/src/frames.ts +++ b/src/frames.ts @@ -549,7 +549,7 @@ export class Frame { const handle = await utilityContext._$(selector); if (handle && handle._context !== mainContext) { const adopted = this._page._delegate.adoptElementHandle(handle, mainContext); - await handle.dispose(); + handle.dispose(); return adopted; } return handle; @@ -561,7 +561,7 @@ export class Frame { const mainContext = await this._mainContext(); if (handle && handle._context !== mainContext) { const adopted = this._page._delegate.adoptElementHandle(handle, mainContext); - await handle.dispose(); + handle.dispose(); return adopted; } return handle; @@ -577,7 +577,7 @@ export class Frame { if (!elementHandle) throw new Error(`Error: failed to find element matching selector "${selector}"`); const result = await elementHandle.evaluate(pageFunction, ...args as any); - await elementHandle.dispose(); + elementHandle.dispose(); return result; } @@ -585,7 +585,7 @@ export class Frame { const context = await this._mainContext(); const arrayHandle = await context._$array(selector); const result = await arrayHandle.evaluate(pageFunction, ...args as any); - await arrayHandle.dispose(); + arrayHandle.dispose(); return result; } @@ -782,63 +782,63 @@ export class Frame { async click(selector: string, options?: dom.ClickOptions & types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.click(options); - await handle.dispose(); + handle.dispose(); } async dblclick(selector: string, options?: dom.MultiClickOptions & types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.dblclick(options); - await handle.dispose(); + handle.dispose(); } async tripleclick(selector: string, options?: dom.MultiClickOptions & types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.tripleclick(options); - await handle.dispose(); + handle.dispose(); } async fill(selector: string, value: string, options?: types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.fill(value); - await handle.dispose(); + handle.dispose(); } async focus(selector: string, options?: types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.focus(); - await handle.dispose(); + handle.dispose(); } async hover(selector: string, options?: dom.PointerActionOptions & types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.hover(options); - await handle.dispose(); + handle.dispose(); } async select(selector: string, value: string | dom.ElementHandle | types.SelectOption | string[] | dom.ElementHandle[] | types.SelectOption[], options?: types.WaitForOptions): Promise { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); const values = Array.isArray(value) ? value : [value]; const result = await handle.select(...values); - await handle.dispose(); + handle.dispose(); return result; } async type(selector: string, text: string, options?: { delay?: number } & types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.type(text, options); - await handle.dispose(); + handle.dispose(); } async check(selector: string, options?: types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.check(options); - await handle.dispose(); + handle.dispose(); } async uncheck(selector: string, options?: types.WaitForOptions) { const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options); await handle.uncheck(options); - await handle.dispose(); + handle.dispose(); } async waitFor(selectorOrFunctionOrTimeout: (string | number | Function), options: types.WaitForFunctionOptions & { visibility?: types.Visibility } = {}, ...args: any[]): Promise { @@ -879,7 +879,7 @@ export class Frame { const task = dom.waitForSelectorTask(selector, visibility, timeout); const result = await this._scheduleRerunnableTask(task, 'utility', timeout, `selector "${selectorToString(selector, visibility)}"`); if (!result.asElement()) { - await result.dispose(); + result.dispose(); return null; } return result.asElement() as dom.ElementHandle; @@ -993,7 +993,7 @@ class RerunnableTask { if (this._terminated || runCount !== this._runCount) { if (success) - await success.dispose(); + success.dispose(); return; } @@ -1001,7 +1001,7 @@ class RerunnableTask { // If execution context has been already destroyed, `context.evaluate` will // throw an error - ignore this predicate run altogether. if (!error && await context.evaluate(s => !s, success).catch(e => true)) { - await success!.dispose(); + success!.dispose(); return; } diff --git a/src/javascript.ts b/src/javascript.ts index 0b25f68607..73add31a0b 100644 --- a/src/javascript.ts +++ b/src/javascript.ts @@ -75,7 +75,7 @@ export class JSHandle { }, propertyName); const properties = await objectHandle.getProperties(); const result = properties.get(propertyName) || null; - await objectHandle.dispose(); + objectHandle.dispose(); return result; } diff --git a/src/page.ts b/src/page.ts index d56045e2ce..9ed872f01e 100644 --- a/src/page.ts +++ b/src/page.ts @@ -187,7 +187,7 @@ export class Page extends platform.EventEmitter { async _onFileChooserOpened(handle: dom.ElementHandle) { const multiple = await handle.evaluate(element => !!(element as HTMLInputElement).multiple); if (!this.listenerCount(Events.Page.FileChooser)) { - await handle.dispose(); + handle.dispose(); return; } const fileChooser: FileChooser = { element: handle, multiple }; diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.ts index de923b1881..95c4e0d2f2 100644 --- a/src/webkit/wkPage.ts +++ b/src/webkit/wkPage.ts @@ -630,7 +630,7 @@ export class WKPage implements PageDelegate { return { handle, frame }; })); const result = items.find(item => item.frame === frame); - await Promise.all(items.map(item => item === result ? Promise.resolve() : item.handle.dispose())); + items.map(item => item === result ? Promise.resolve() : item.handle.dispose()); if (!result) throw new Error('Frame has been detached.'); return result.handle; diff --git a/src/webkit/wkProtocolHelper.ts b/src/webkit/wkProtocolHelper.ts index 8d8bcee838..ff19da907b 100644 --- a/src/webkit/wkProtocolHelper.ts +++ b/src/webkit/wkProtocolHelper.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { assert, debugError } from '../helper'; +import { assert } from '../helper'; import { WKSession } from './wkConnection'; import { Protocol } from './protocol'; @@ -46,10 +46,6 @@ export function valueFromRemoteObject(remoteObject: Protocol.Runtime.RemoteObjec export async function releaseObject(client: WKSession, remoteObject: Protocol.Runtime.RemoteObject) { if (!remoteObject.objectId) return; - await client.send('Runtime.releaseObject', {objectId: remoteObject.objectId}).catch(error => { - // Exceptions might happen in case of a page been navigated or closed. - // Swallow these since they are harmless and we don't leak anything in this case. - debugError(error); - }); + await client.send('Runtime.releaseObject', {objectId: remoteObject.objectId}).catch(error => {}); }