From 24a357dbdb313e21646cefe30cfa17120304d4f5 Mon Sep 17 00:00:00 2001 From: jrandolf <101637635+jrandolf@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:51:44 +0200 Subject: [PATCH] chore: update chromium-bidi (#10862) --- package-lock.json | 16 +++--- packages/puppeteer-core/package.json | 2 +- .../puppeteer-core/src/common/bidi/Browser.ts | 4 -- .../src/common/bidi/BrowsingContext.ts | 11 +--- .../puppeteer-core/src/common/bidi/Page.ts | 55 ++++--------------- test/TestExpectations.json | 32 +---------- 6 files changed, 24 insertions(+), 96 deletions(-) diff --git a/package-lock.json b/package-lock.json index b60429ee1f9..690c4e598f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3434,9 +3434,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.4.22", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.22.tgz", - "integrity": "sha512-wR7Y9Ioez+cNXT4ZP7VNM1HRTljpNnMSLw4/RnwhhZUP4yCU7kIQND00YiktuHekch68jklGPK1q9Jkb29+fQg==", + "version": "0.4.25", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.25.tgz", + "integrity": "sha512-wQOIgYulshTLpZtuDO/eKFfKqVtpS2UwFVVqi/9q5rX/VXVkYNb/0mZ5l479W24A5ogYKBKEIb6BxMlhMcpXFw==", "dependencies": { "mitt": "3.0.1" }, @@ -11115,7 +11115,7 @@ "license": "Apache-2.0", "dependencies": { "@puppeteer/browsers": "1.7.0", - "chromium-bidi": "0.4.22", + "chromium-bidi": "0.4.25", "cross-fetch": "4.0.0", "debug": "4.3.4", "devtools-protocol": "0.0.1159816", @@ -13466,9 +13466,9 @@ "dev": true }, "chromium-bidi": { - "version": "0.4.22", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.22.tgz", - "integrity": "sha512-wR7Y9Ioez+cNXT4ZP7VNM1HRTljpNnMSLw4/RnwhhZUP4yCU7kIQND00YiktuHekch68jklGPK1q9Jkb29+fQg==", + "version": "0.4.25", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.25.tgz", + "integrity": "sha512-wQOIgYulshTLpZtuDO/eKFfKqVtpS2UwFVVqi/9q5rX/VXVkYNb/0mZ5l479W24A5ogYKBKEIb6BxMlhMcpXFw==", "requires": { "mitt": "3.0.1" } @@ -17257,7 +17257,7 @@ "version": "file:packages/puppeteer-core", "requires": { "@puppeteer/browsers": "1.7.0", - "chromium-bidi": "0.4.22", + "chromium-bidi": "0.4.25", "cross-fetch": "4.0.0", "debug": "4.3.4", "devtools-protocol": "0.0.1159816", diff --git a/packages/puppeteer-core/package.json b/packages/puppeteer-core/package.json index edfae82ebe6..a419b869cf3 100644 --- a/packages/puppeteer-core/package.json +++ b/packages/puppeteer-core/package.json @@ -141,7 +141,7 @@ "license": "Apache-2.0", "dependencies": { "@puppeteer/browsers": "1.7.0", - "chromium-bidi": "0.4.22", + "chromium-bidi": "0.4.25", "cross-fetch": "4.0.0", "debug": "4.3.4", "devtools-protocol": "0.0.1159816", diff --git a/packages/puppeteer-core/src/common/bidi/Browser.ts b/packages/puppeteer-core/src/common/bidi/Browser.ts index 46b5ac30b1f..9465df0448e 100644 --- a/packages/puppeteer-core/src/common/bidi/Browser.ts +++ b/packages/puppeteer-core/src/common/bidi/Browser.ts @@ -157,8 +157,6 @@ export class BidiBrowser extends Browser { } #onContextDomLoaded(event: Bidi.BrowsingContext.Info) { - const context = this.#connection.getBrowsingContext(event.context); - context.url = event.url; const target = this.#targets.get(event.context); if (target) { this.emit(BrowserEmittedEvents.TargetChanged, target); @@ -166,8 +164,6 @@ export class BidiBrowser extends Browser { } #onContextNavigation(event: Bidi.BrowsingContext.NavigationInfo) { - const context = this.#connection.getBrowsingContext(event.context); - context.url = event.url; const target = this.#targets.get(event.context); if (target) { this.emit(BrowserEmittedEvents.TargetChanged, target); diff --git a/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts b/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts index ab1bfa55981..9516f46b277 100644 --- a/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts +++ b/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts @@ -155,6 +155,7 @@ export class BrowsingContext extends Realm { this.#cdpSession = new CDPSessionWrapper(this, undefined); this.on('browsingContext.domContentLoaded', this.#updateUrl.bind(this)); + this.on('browsingContext.fragmentNavigated', this.#updateUrl.bind(this)); this.on('browsingContext.load', this.#updateUrl.bind(this)); } @@ -163,7 +164,7 @@ export class BrowsingContext extends Realm { } #updateUrl(info: Bidi.BrowsingContext.NavigationInfo) { - this.url = info.url; + this.#url = info.url; } createRealmForSandbox(): Realm { @@ -174,10 +175,6 @@ export class BrowsingContext extends Realm { return this.#url; } - set url(value: string) { - this.#url = value; - } - get id(): string { return this.#id; } @@ -190,10 +187,6 @@ export class BrowsingContext extends Realm { return this.#cdpSession; } - navigated(url: string): void { - this.#url = url; - } - async goto( url: string, options: { diff --git a/packages/puppeteer-core/src/common/bidi/Page.ts b/packages/puppeteer-core/src/common/bidi/Page.ts index 5a7c8dca471..b1d3a4d4769 100644 --- a/packages/puppeteer-core/src/common/bidi/Page.ts +++ b/packages/puppeteer-core/src/common/bidi/Page.ts @@ -85,12 +85,12 @@ export class BidiPage extends Page { ['log.entryAdded', this.#onLogEntryAdded.bind(this)], ['browsingContext.load', this.#onFrameLoaded.bind(this)], [ - 'browsingContext.domContentLoaded', - this.#onFrameDOMContentLoaded.bind(this), + 'browsingContext.fragmentNavigated', + this.#onFrameFragmentNavigated.bind(this), ], [ - 'browsingContext.navigationStarted', - this.#onFrameNavigationStarted.bind(this), + 'browsingContext.domContentLoaded', + this.#onFrameDOMContentLoaded.bind(this), ], ['browsingContext.userPromptOpened', this.#onDialog.bind(this)], ]); @@ -246,6 +246,13 @@ export class BidiPage extends Page { } } + #onFrameFragmentNavigated(info: Bidi.BrowsingContext.NavigationInfo): void { + const frame = this.frame(info.context); + if (frame) { + this.emit(PageEmittedEvents.FrameNavigated, frame); + } + } + #onFrameDOMContentLoaded(info: Bidi.BrowsingContext.NavigationInfo): void { const frame = this.frame(info.context); if (frame) { @@ -253,6 +260,7 @@ export class BidiPage extends Page { if (this.mainFrame() === frame) { this.emit(PageEmittedEvents.DOMContentLoaded); } + this.emit(PageEmittedEvents.FrameNavigated, frame); } } @@ -274,45 +282,6 @@ export class BidiPage extends Page { } } - async #onFrameNavigationStarted( - info: Bidi.BrowsingContext.NavigationInfo - ): Promise { - const frameId = info.context; - - const frame = this.frame(frameId); - - if (frame) { - // TODO: Investigate if a navigationCompleted event should be in Spec - const predicate = ( - event: Bidi.BrowsingContext.DomContentLoaded['params'] - ) => { - if (event.context === frame?._id) { - return true; - } - return false; - }; - - await Deferred.race([ - waitForEvent( - this.#connection, - 'browsingContext.domContentLoaded', - predicate, - 0, - this.#closedDeferred.valueOrThrow() - ).catch(debugError), - waitForEvent( - this.#connection, - 'browsingContext.fragmentNavigated', - predicate, - 0, - this.#closedDeferred.valueOrThrow() - ).catch(debugError), - ]); - - this.emit(PageEmittedEvents.FrameNavigated, frame); - } - } - #onContextDestroyed(context: BrowsingContext): void { const frame = this.frame(context.id); diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 2577962cac6..fde2cf1b2bf 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -2291,18 +2291,6 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, - { - "testIdPattern": "[evaluation.spec] Evaluation specs Page.evaluate should work right after framenavigated", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] - }, - { - "testIdPattern": "[evaluation.spec] Evaluation specs Page.evaluate should work right after framenavigated", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["chrome", "webDriverBiDi"], - "expectations": ["PASS"] - }, { "testIdPattern": "[fixtures.spec] Fixtures should close the browser when the node process closes", "platforms": ["darwin", "linux", "win32"], @@ -2991,7 +2979,7 @@ "testIdPattern": "[navigation.spec] navigation Page.goto should return response when page changes its URL after load", "platforms": ["darwin", "linux", "win32"], "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] + "expectations": ["PASS"] }, { "testIdPattern": "[navigation.spec] navigation Page.goto should send referer", @@ -3035,24 +3023,12 @@ "parameters": ["chrome", "headless"], "expectations": ["PASS", "TIMEOUT"] }, - { - "testIdPattern": "[navigation.spec] navigation Page.goto should work with redirects", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["chrome", "webDriverBiDi"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[navigation.spec] navigation Page.goto should work with subframes return 204", "platforms": ["darwin", "linux", "win32"], "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, - { - "testIdPattern": "[navigation.spec] navigation Page.reload should work", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[navigation.spec] navigation Page.waitForNavigation should work", "platforms": ["darwin", "linux", "win32"], @@ -3353,12 +3329,6 @@ "parameters": ["cdp", "firefox"], "expectations": ["SKIP"] }, - { - "testIdPattern": "[network.spec] network Response.fromCache should work", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["firefox", "webDriverBiDi"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[network.spec] network Response.fromCache should work", "platforms": ["darwin", "linux", "win32"],