From 019bc82192190993887e636fbf1a275bfc04f512 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 31 Oct 2023 16:23:29 +0100 Subject: [PATCH] chore: update expected bidi errors (#11022) --- .../puppeteer-core/src/common/WaitTask.ts | 20 ++++++++++++++++--- test/TestExpectations.json | 6 +++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/puppeteer-core/src/common/WaitTask.ts b/packages/puppeteer-core/src/common/WaitTask.ts index 604f3156e30..9392d05f68a 100644 --- a/packages/puppeteer-core/src/common/WaitTask.ts +++ b/packages/puppeteer-core/src/common/WaitTask.ts @@ -53,6 +53,7 @@ export class WaitTask { #poller?: JSHandle>; #signal?: AbortSignal; + #reruns: AbortController[] = []; constructor( world: Realm, @@ -102,6 +103,12 @@ export class WaitTask { } async rerun(): Promise { + for (const prev of this.#reruns) { + prev.abort(); + } + this.#reruns.length = 0; + const controller = new AbortController(); + this.#reruns.push(controller); try { switch (this.#polling) { case 'raf': @@ -164,6 +171,9 @@ export class WaitTask { await this.terminate(); } catch (error) { + if (controller.signal.aborted) { + return; + } const badError = this.getBadError(error); if (badError) { await this.terminate(badError); @@ -221,11 +231,15 @@ export class WaitTask { // We could have tried to evaluate in a context which was already // destroyed. + if (error.message.includes('Cannot find context with specified id')) { + return; + } + + // Errors coming from WebDriver BiDi. TODO: Adjust messages after + // https://github.com/w3c/webdriver-bidi/issues/540 is resolved. if ( - error.message.includes('Cannot find context with specified id') || - // Firefox BiDi Error, update one https://github.com/w3c/webdriver-bidi/issues/540 is resolved error.message.includes( - "destroyed before query 'MessageHandlerFrameParent:sendCommand'" + "AbortError: Actor 'MessageHandlerFrame' destroyed" ) ) { return; diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 11c0a201ba6..39eabc7a54d 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -3699,7 +3699,7 @@ "testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should survive cross-process navigation", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] + "expectations": ["PASS"] }, { "testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should survive cross-process navigation", @@ -3711,7 +3711,7 @@ "testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should survive navigations", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] + "expectations": ["PASS"] }, { "testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should work when resolved right before execution context disposal", @@ -3765,7 +3765,7 @@ "testIdPattern": "[waittask.spec] waittask specs Frame.waitForSelector should survive cross-process navigation", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] + "expectations": ["PASS"] }, { "testIdPattern": "[waittask.spec] waittask specs Frame.waitForSelector should survive cross-process navigation",