chore: allow enabling the tab target for testing (#10790)
This commit is contained in:
parent
ad0c793662
commit
6f1dd09cca
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -128,11 +128,16 @@ jobs:
|
|||||||
- chrome-headful
|
- chrome-headful
|
||||||
- chrome-new-headless
|
- chrome-new-headless
|
||||||
- chrome-bidi
|
- chrome-bidi
|
||||||
|
- chrome-new-headless-tab
|
||||||
exclude:
|
exclude:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
suite: chrome-bidi
|
suite: chrome-bidi
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
suite: chrome-headful
|
suite: chrome-headful
|
||||||
|
- os: windows-latest
|
||||||
|
suite: chrome-new-headless-tab
|
||||||
|
- os: macos-latest
|
||||||
|
suite: chrome-new-headless-tab
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
|
@ -32,6 +32,7 @@ import {
|
|||||||
import {BrowserContext} from '../api/BrowserContext.js';
|
import {BrowserContext} from '../api/BrowserContext.js';
|
||||||
import {Page} from '../api/Page.js';
|
import {Page} from '../api/Page.js';
|
||||||
import {Target} from '../api/Target.js';
|
import {Target} from '../api/Target.js';
|
||||||
|
import {USE_TAB_TARGET} from '../environment.js';
|
||||||
import {assert} from '../util/assert.js';
|
import {assert} from '../util/assert.js';
|
||||||
|
|
||||||
import {ChromeTargetManager} from './ChromeTargetManager.js';
|
import {ChromeTargetManager} from './ChromeTargetManager.js';
|
||||||
@ -65,7 +66,8 @@ export class CDPBrowser extends BrowserBase {
|
|||||||
closeCallback?: BrowserCloseCallback,
|
closeCallback?: BrowserCloseCallback,
|
||||||
targetFilterCallback?: TargetFilterCallback,
|
targetFilterCallback?: TargetFilterCallback,
|
||||||
isPageTargetCallback?: IsPageTargetCallback,
|
isPageTargetCallback?: IsPageTargetCallback,
|
||||||
waitForInitiallyDiscoveredTargets = true
|
waitForInitiallyDiscoveredTargets = true,
|
||||||
|
useTabTarget = USE_TAB_TARGET
|
||||||
): Promise<CDPBrowser> {
|
): Promise<CDPBrowser> {
|
||||||
const browser = new CDPBrowser(
|
const browser = new CDPBrowser(
|
||||||
product,
|
product,
|
||||||
@ -77,7 +79,8 @@ export class CDPBrowser extends BrowserBase {
|
|||||||
closeCallback,
|
closeCallback,
|
||||||
targetFilterCallback,
|
targetFilterCallback,
|
||||||
isPageTargetCallback,
|
isPageTargetCallback,
|
||||||
waitForInitiallyDiscoveredTargets
|
waitForInitiallyDiscoveredTargets,
|
||||||
|
useTabTarget
|
||||||
);
|
);
|
||||||
await browser._attach();
|
await browser._attach();
|
||||||
return browser;
|
return browser;
|
||||||
@ -114,7 +117,8 @@ export class CDPBrowser extends BrowserBase {
|
|||||||
closeCallback?: BrowserCloseCallback,
|
closeCallback?: BrowserCloseCallback,
|
||||||
targetFilterCallback?: TargetFilterCallback,
|
targetFilterCallback?: TargetFilterCallback,
|
||||||
isPageTargetCallback?: IsPageTargetCallback,
|
isPageTargetCallback?: IsPageTargetCallback,
|
||||||
waitForInitiallyDiscoveredTargets = true
|
waitForInitiallyDiscoveredTargets = true,
|
||||||
|
useTabTarget = USE_TAB_TARGET
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
product = product || 'chrome';
|
product = product || 'chrome';
|
||||||
@ -141,7 +145,8 @@ export class CDPBrowser extends BrowserBase {
|
|||||||
connection,
|
connection,
|
||||||
this.#createTarget,
|
this.#createTarget,
|
||||||
this.#targetFilterCallback,
|
this.#targetFilterCallback,
|
||||||
waitForInitiallyDiscoveredTargets
|
waitForInitiallyDiscoveredTargets,
|
||||||
|
useTabTarget
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.#defaultContext = new CDPBrowserContext(this.#connection, this);
|
this.#defaultContext = new CDPBrowserContext(this.#connection, this);
|
||||||
|
@ -99,16 +99,21 @@ export class ChromeTargetManager extends EventEmitter implements TargetManager {
|
|||||||
#waitForInitiallyDiscoveredTargets = true;
|
#waitForInitiallyDiscoveredTargets = true;
|
||||||
|
|
||||||
// TODO: remove the flag once the testing/rollout is done.
|
// TODO: remove the flag once the testing/rollout is done.
|
||||||
#tabMode = false;
|
#tabMode: boolean;
|
||||||
#discoveryFilter = this.#tabMode ? [{}] : [{type: 'tab', exclude: true}, {}];
|
#discoveryFilter: Protocol.Target.FilterEntry[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
targetFactory: TargetFactory,
|
targetFactory: TargetFactory,
|
||||||
targetFilterCallback?: TargetFilterCallback,
|
targetFilterCallback?: TargetFilterCallback,
|
||||||
waitForInitiallyDiscoveredTargets = true
|
waitForInitiallyDiscoveredTargets = true,
|
||||||
|
useTabTarget = false
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
this.#tabMode = useTabTarget;
|
||||||
|
this.#discoveryFilter = this.#tabMode
|
||||||
|
? [{}]
|
||||||
|
: [{type: 'tab', exclude: true}, {}];
|
||||||
this.#connection = connection;
|
this.#connection = connection;
|
||||||
this.#targetFilterCallback = targetFilterCallback;
|
this.#targetFilterCallback = targetFilterCallback;
|
||||||
this.#targetFactory = targetFactory;
|
this.#targetFactory = targetFactory;
|
||||||
|
@ -27,3 +27,13 @@ export const DEFERRED_PROMISE_DEBUG_TIMEOUT =
|
|||||||
typeof process.env['PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT'] !== 'undefined'
|
typeof process.env['PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT'] !== 'undefined'
|
||||||
? Number(process.env['PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT'])
|
? Number(process.env['PUPPETEER_DEFERRED_PROMISE_DEBUG_TIMEOUT'])
|
||||||
: -1;
|
: -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used for internal testing.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const USE_TAB_TARGET =
|
||||||
|
typeof process !== 'undefined'
|
||||||
|
? process.env['PUPPETEER_INTERNAL_TAB_TARGET'] === 'true'
|
||||||
|
: false;
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
|
|
||||||
import {Browser} from '../api/Browser.js';
|
import {Browser} from '../api/Browser.js';
|
||||||
import {debugError} from '../common/util.js';
|
import {debugError} from '../common/util.js';
|
||||||
|
import {USE_TAB_TARGET} from '../environment.js';
|
||||||
import {assert} from '../util/assert.js';
|
import {assert} from '../util/assert.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -178,7 +179,8 @@ export class ChromeLauncher extends ProductLauncher {
|
|||||||
'--disable-dev-shm-usage',
|
'--disable-dev-shm-usage',
|
||||||
'--disable-extensions',
|
'--disable-extensions',
|
||||||
// AcceptCHFrame disabled because of crbug.com/1348106.
|
// AcceptCHFrame disabled because of crbug.com/1348106.
|
||||||
'--disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints,Prerender2',
|
'--disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints',
|
||||||
|
...(USE_TAB_TARGET ? [] : ['--disable-features=Prerender2']),
|
||||||
'--disable-hang-monitor',
|
'--disable-hang-monitor',
|
||||||
'--disable-ipc-flooding-protection',
|
'--disable-ipc-flooding-protection',
|
||||||
'--disable-popup-blocking',
|
'--disable-popup-blocking',
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
"parameters": ["chrome", "new-headless", "cdp"],
|
"parameters": ["chrome", "new-headless", "cdp"],
|
||||||
"expectedLineCoverage": 93
|
"expectedLineCoverage": 93
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "chrome-new-headless-tab",
|
||||||
|
"platforms": ["linux"],
|
||||||
|
"parameters": ["chrome", "new-headless", "cdp", "tabTarget"],
|
||||||
|
"expectedLineCoverage": 93
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "firefox-headless",
|
"id": "firefox-headless",
|
||||||
"platforms": ["linux", "darwin"],
|
"platforms": ["linux", "darwin"],
|
||||||
@ -63,6 +69,9 @@
|
|||||||
"webDriverBiDi": {
|
"webDriverBiDi": {
|
||||||
"PUPPETEER_PROTOCOL": "webDriverBiDi"
|
"PUPPETEER_PROTOCOL": "webDriverBiDi"
|
||||||
},
|
},
|
||||||
"cdp": {}
|
"cdp": {},
|
||||||
|
"tabTarget": {
|
||||||
|
"PUPPETEER_INTERNAL_TAB_TARGET": "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user