From 8324c1634883d97ed83f32a1e62acc9b5e64e0bd Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Mon, 9 Oct 2023 13:49:27 +0200 Subject: [PATCH] feat: enable tab targets (#11099) --- .github/workflows/ci.yml | 5 ---- package.json | 4 --- packages/browsers/test/src/versions.ts | 2 +- packages/puppeteer-core/src/cdp/Browser.ts | 13 +++------ .../src/cdp/ChromeTargetManager.ts | 27 +++++++------------ packages/puppeteer-core/src/environment.ts | 10 ------- .../puppeteer-core/src/node/ChromeLauncher.ts | 5 ---- test/TestSuites.json | 11 +------- 8 files changed, 15 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 918e4142b6c..f8bca7f9982 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,6 @@ jobs: - chrome-headful - chrome-new-headless - chrome-bidi - - chrome-new-headless-tab shard: - 1/2 - 2/2 @@ -159,10 +158,6 @@ jobs: suite: chrome-bidi - os: macos-latest suite: chrome-headful - - os: windows-latest - suite: chrome-new-headless-tab - - os: macos-latest - suite: chrome-new-headless-tab steps: - name: Check out repository uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 diff --git a/package.json b/package.json index f90df08aef7..6696c9da35c 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "test-types": "tsd -t packages/puppeteer", "test:chrome:headful": "wireit", "test:chrome:new-headless": "wireit", - "test:chrome:new-headless-tab": "wireit", "test:chrome:headless": "wireit", "test:chrome:bidi": "wireit", "test:chrome:bidi-local": "wireit", @@ -76,9 +75,6 @@ "test:chrome:new-headless": { "command": "npm test -- --test-suite chrome-new-headless" }, - "test:chrome:new-headless-tab": { - "command": "npm test -- --test-suite chrome-new-headless-tab" - }, "test:chrome:bidi": { "command": "npm test -- --test-suite chrome-bidi" }, diff --git a/packages/browsers/test/src/versions.ts b/packages/browsers/test/src/versions.ts index 867af04eba8..37d9340d1b9 100644 --- a/packages/browsers/test/src/versions.ts +++ b/packages/browsers/test/src/versions.ts @@ -16,6 +16,6 @@ export const testChromeBuildId = '113.0.5672.0'; export const testChromiumBuildId = '1083080'; -export const testFirefoxBuildId = '119.0a1'; +export const testFirefoxBuildId = '120.0a1'; export const testChromeDriverBuildId = '115.0.5763.0'; export const testChromeHeadlessShellBuildId = '118.0.5950.0'; diff --git a/packages/puppeteer-core/src/cdp/Browser.ts b/packages/puppeteer-core/src/cdp/Browser.ts index e881370eb36..6074d2b1baa 100644 --- a/packages/puppeteer-core/src/cdp/Browser.ts +++ b/packages/puppeteer-core/src/cdp/Browser.ts @@ -33,7 +33,6 @@ import {CDPSessionEvent, type CDPSession} from '../api/CDPSession.js'; import type {Page} from '../api/Page.js'; import type {Target} from '../api/Target.js'; import type {Viewport} from '../common/Viewport.js'; -import {USE_TAB_TARGET} from '../environment.js'; import {assert} from '../util/assert.js'; import {ChromeTargetManager} from './ChromeTargetManager.js'; @@ -63,8 +62,7 @@ export class CdpBrowser extends BrowserBase { closeCallback?: BrowserCloseCallback, targetFilterCallback?: TargetFilterCallback, isPageTargetCallback?: IsPageTargetCallback, - waitForInitiallyDiscoveredTargets = true, - useTabTarget = USE_TAB_TARGET + waitForInitiallyDiscoveredTargets = true ): Promise { const browser = new CdpBrowser( product, @@ -76,8 +74,7 @@ export class CdpBrowser extends BrowserBase { closeCallback, targetFilterCallback, isPageTargetCallback, - waitForInitiallyDiscoveredTargets, - useTabTarget + waitForInitiallyDiscoveredTargets ); await browser._attach(); return browser; @@ -107,8 +104,7 @@ export class CdpBrowser extends BrowserBase { closeCallback?: BrowserCloseCallback, targetFilterCallback?: TargetFilterCallback, isPageTargetCallback?: IsPageTargetCallback, - waitForInitiallyDiscoveredTargets = true, - useTabTarget = USE_TAB_TARGET + waitForInitiallyDiscoveredTargets = true ) { super(); product = product || 'chrome'; @@ -134,8 +130,7 @@ export class CdpBrowser extends BrowserBase { connection, this.#createTarget, this.#targetFilterCallback, - waitForInitiallyDiscoveredTargets, - useTabTarget + waitForInitiallyDiscoveredTargets ); } this.#defaultContext = new CdpBrowserContext(this.#connection, this); diff --git a/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts b/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts index 97a72a947f4..5f8843c2f96 100644 --- a/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts +++ b/packages/puppeteer-core/src/cdp/ChromeTargetManager.ts @@ -98,22 +98,15 @@ export class ChromeTargetManager #targetsIdsForInit = new Set(); #waitForInitiallyDiscoveredTargets = true; - // TODO: remove the flag once the testing/rollout is done. - #tabMode: boolean; - #discoveryFilter: Protocol.Target.FilterEntry[]; + #discoveryFilter: Protocol.Target.FilterEntry[] = [{}]; constructor( connection: Connection, targetFactory: TargetFactory, targetFilterCallback?: TargetFilterCallback, - waitForInitiallyDiscoveredTargets = true, - useTabTarget = false + waitForInitiallyDiscoveredTargets = true ) { super(); - this.#tabMode = useTabTarget; - this.#discoveryFilter = this.#tabMode - ? [{}] - : [{type: 'tab', exclude: true}, {}]; this.#connection = connection; this.#targetFilterCallback = targetFilterCallback; this.#targetFactory = targetFactory; @@ -166,15 +159,13 @@ export class ChromeTargetManager waitForDebuggerOnStart: true, flatten: true, autoAttach: true, - filter: this.#tabMode - ? [ - { - type: 'page', - exclude: true, - }, - ...this.#discoveryFilter, - ] - : this.#discoveryFilter, + filter: [ + { + type: 'page', + exclude: true, + }, + ...this.#discoveryFilter, + ], }); this.#finishInitializationIfReady(); await this.#initializeDeferred.valueOrThrow(); diff --git a/packages/puppeteer-core/src/environment.ts b/packages/puppeteer-core/src/environment.ts index 5ad5298fe5e..80258c67fed 100644 --- a/packages/puppeteer-core/src/environment.ts +++ b/packages/puppeteer-core/src/environment.ts @@ -27,13 +27,3 @@ export const DEFERRED_PROMISE_DEBUG_TIMEOUT = typeof process.env['PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT'] !== 'undefined' ? Number(process.env['PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT']) : -1; - -/** - * Only used for internal testing. - * - * @internal - */ -export const USE_TAB_TARGET = - typeof process !== 'undefined' - ? process.env['PUPPETEER_INTERNAL_TAB_TARGET'] === 'true' - : false; diff --git a/packages/puppeteer-core/src/node/ChromeLauncher.ts b/packages/puppeteer-core/src/node/ChromeLauncher.ts index bb4f94fdd47..4201087b17e 100644 --- a/packages/puppeteer-core/src/node/ChromeLauncher.ts +++ b/packages/puppeteer-core/src/node/ChromeLauncher.ts @@ -25,7 +25,6 @@ import { import type {Browser} from '../api/Browser.js'; import {debugError} from '../common/util.js'; -import {USE_TAB_TARGET} from '../environment.js'; import {assert} from '../util/assert.js'; import type { @@ -175,10 +174,6 @@ export class ChromeLauncher extends ProductLauncher { 'OptimizationHints', ]; - if (!USE_TAB_TARGET) { - disabledFeatures.push('Prerender2'); - } - const chromeArguments = [ '--allow-pre-commit-input', '--disable-background-networking', diff --git a/test/TestSuites.json b/test/TestSuites.json index 4055a2790e8..75fcc1dd0d9 100644 --- a/test/TestSuites.json +++ b/test/TestSuites.json @@ -18,12 +18,6 @@ "parameters": ["chrome", "new-headless", "cdp"], "expectedLineCoverage": 93 }, - { - "id": "chrome-new-headless-tab", - "platforms": ["linux"], - "parameters": ["chrome", "new-headless", "cdp", "tabTarget"], - "expectedLineCoverage": 93 - }, { "id": "firefox-headless", "platforms": ["linux", "darwin"], @@ -69,9 +63,6 @@ "webDriverBiDi": { "PUPPETEER_PROTOCOL": "webDriverBiDi" }, - "cdp": {}, - "tabTarget": { - "PUPPETEER_INTERNAL_TAB_TARGET": "true" - } + "cdp": {} } }