mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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-new-headless
|
||||
- chrome-bidi
|
||||
- chrome-new-headless-tab
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
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@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
@ -32,6 +32,7 @@ import {
|
||||
import {BrowserContext} from '../api/BrowserContext.js';
|
||||
import {Page} from '../api/Page.js';
|
||||
import {Target} from '../api/Target.js';
|
||||
import {USE_TAB_TARGET} from '../environment.js';
|
||||
import {assert} from '../util/assert.js';
|
||||
|
||||
import {ChromeTargetManager} from './ChromeTargetManager.js';
|
||||
@ -65,7 +66,8 @@ export class CDPBrowser extends BrowserBase {
|
||||
closeCallback?: BrowserCloseCallback,
|
||||
targetFilterCallback?: TargetFilterCallback,
|
||||
isPageTargetCallback?: IsPageTargetCallback,
|
||||
waitForInitiallyDiscoveredTargets = true
|
||||
waitForInitiallyDiscoveredTargets = true,
|
||||
useTabTarget = USE_TAB_TARGET
|
||||
): Promise<CDPBrowser> {
|
||||
const browser = new CDPBrowser(
|
||||
product,
|
||||
@ -77,7 +79,8 @@ export class CDPBrowser extends BrowserBase {
|
||||
closeCallback,
|
||||
targetFilterCallback,
|
||||
isPageTargetCallback,
|
||||
waitForInitiallyDiscoveredTargets
|
||||
waitForInitiallyDiscoveredTargets,
|
||||
useTabTarget
|
||||
);
|
||||
await browser._attach();
|
||||
return browser;
|
||||
@ -114,7 +117,8 @@ export class CDPBrowser extends BrowserBase {
|
||||
closeCallback?: BrowserCloseCallback,
|
||||
targetFilterCallback?: TargetFilterCallback,
|
||||
isPageTargetCallback?: IsPageTargetCallback,
|
||||
waitForInitiallyDiscoveredTargets = true
|
||||
waitForInitiallyDiscoveredTargets = true,
|
||||
useTabTarget = USE_TAB_TARGET
|
||||
) {
|
||||
super();
|
||||
product = product || 'chrome';
|
||||
@ -141,7 +145,8 @@ export class CDPBrowser extends BrowserBase {
|
||||
connection,
|
||||
this.#createTarget,
|
||||
this.#targetFilterCallback,
|
||||
waitForInitiallyDiscoveredTargets
|
||||
waitForInitiallyDiscoveredTargets,
|
||||
useTabTarget
|
||||
);
|
||||
}
|
||||
this.#defaultContext = new CDPBrowserContext(this.#connection, this);
|
||||
|
@ -99,16 +99,21 @@ export class ChromeTargetManager extends EventEmitter implements TargetManager {
|
||||
#waitForInitiallyDiscoveredTargets = true;
|
||||
|
||||
// TODO: remove the flag once the testing/rollout is done.
|
||||
#tabMode = false;
|
||||
#discoveryFilter = this.#tabMode ? [{}] : [{type: 'tab', exclude: true}, {}];
|
||||
#tabMode: boolean;
|
||||
#discoveryFilter: Protocol.Target.FilterEntry[];
|
||||
|
||||
constructor(
|
||||
connection: Connection,
|
||||
targetFactory: TargetFactory,
|
||||
targetFilterCallback?: TargetFilterCallback,
|
||||
waitForInitiallyDiscoveredTargets = true
|
||||
waitForInitiallyDiscoveredTargets = true,
|
||||
useTabTarget = false
|
||||
) {
|
||||
super();
|
||||
this.#tabMode = useTabTarget;
|
||||
this.#discoveryFilter = this.#tabMode
|
||||
? [{}]
|
||||
: [{type: 'tab', exclude: true}, {}];
|
||||
this.#connection = connection;
|
||||
this.#targetFilterCallback = targetFilterCallback;
|
||||
this.#targetFactory = targetFactory;
|
||||
|
@ -27,3 +27,13 @@ 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;
|
||||
|
@ -25,6 +25,7 @@ import {
|
||||
|
||||
import {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 {
|
||||
@ -178,7 +179,8 @@ export class ChromeLauncher extends ProductLauncher {
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-extensions',
|
||||
// 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-ipc-flooding-protection',
|
||||
'--disable-popup-blocking',
|
||||
|
@ -18,6 +18,12 @@
|
||||
"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"],
|
||||
@ -63,6 +69,9 @@
|
||||
"webDriverBiDi": {
|
||||
"PUPPETEER_PROTOCOL": "webDriverBiDi"
|
||||
},
|
||||
"cdp": {}
|
||||
"cdp": {},
|
||||
"tabTarget": {
|
||||
"PUPPETEER_INTERNAL_TAB_TARGET": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user