@@ -15,7 +15,6 @@ import * as CriClient from './cri-client'
1515import * as protocol from './protocol'
1616import utils from './utils'
1717import { Browser } from './types'
18- import errors from '../errors'
1918
2019// TODO: this is defined in `cypress-npm-api` but there is currently no way to get there
2120type CypressConfiguration = any
@@ -38,9 +37,6 @@ type ChromePreferences = {
3837 localState : object
3938}
4039
41- const staticCdpPort = Number ( process . env . CYPRESS_REMOTE_DEBUGGING_PORT )
42- const stdioTimeoutMs = Number ( process . env . CYPRESS_CDP_TARGET_TIMEOUT ) || 60000
43-
4440const pathToExtension = extension . getPathToExtension ( )
4541const pathToTheme = extension . getPathToTheme ( )
4642
@@ -177,7 +173,9 @@ const _writeChromePreferences = (userDir: string, originalPrefs: ChromePreferenc
177173}
178174
179175const getRemoteDebuggingPort = async ( ) => {
180- return staticCdpPort || utils . getPort ( )
176+ const port = Number ( process . env . CYPRESS_REMOTE_DEBUGGING_PORT )
177+
178+ return port || utils . getPort ( )
181179}
182180
183181/**
@@ -245,47 +243,19 @@ const _disableRestorePagesPrompt = function (userDir) {
245243 . catch ( ( ) => { } )
246244}
247245
248- const useStdioCdp = ( browser ) => {
249- return (
250- // CDP via stdio doesn't seem to work in browsers older than 72
251- // @see https://github.com/cyrus-and/chrome-remote-interface/issues/381#issuecomment-445277683
252- browser . majorVersion >= 72
253- // allow users to force TCP by specifying a port in environment
254- && ! staticCdpPort
255- )
256- }
257-
258246// After the browser has been opened, we can connect to
259247// its remote interface via a websocket.
260- const _connectToChromeRemoteInterface = function ( browser , process , port , onError ) {
261- const connectTcp = ( ) => {
262- // @ts -ignore
263- la ( check . userPort ( port ) , 'expected port number to connect CRI to' , port )
264-
265- debug ( 'connecting to Chrome remote interface at random port %d' , port )
266-
267- return protocol . getWsTargetFor ( port )
268- . then ( ( wsUrl ) => {
269- debug ( 'received wsUrl %s for port %d' , wsUrl , port )
270-
271- return CriClient . create ( { target : wsUrl } , onError )
272- } )
273- }
274-
275- if ( ! useStdioCdp ( browser ) ) {
276- return connectTcp ( )
277- }
278-
279- return CriClient . create ( { process } , onError )
280- . timeout ( stdioTimeoutMs )
281- . catch ( Bluebird . TimeoutError , async ( ) => {
282- errors . warning ( 'CDP_STDIO_TIMEOUT' , browser . displayName , stdioTimeoutMs )
248+ const _connectToChromeRemoteInterface = function ( port , onError ) {
249+ // @ts -ignore
250+ la ( check . userPort ( port ) , 'expected port number to connect CRI to' , port )
283251
284- const client = await connectTcp ( )
252+ debug ( 'connecting to Chrome remote interface at random port %d' , port )
285253
286- errors . warning ( 'CDP_FALLBACK_SUCCEEDED' , browser . displayName )
254+ return protocol . getWsTargetFor ( port )
255+ . then ( ( wsUrl ) => {
256+ debug ( 'received wsUrl %s for port %d' , wsUrl , port )
287257
288- return client
258+ return CriClient . create ( wsUrl , onError )
289259 } )
290260}
291261
@@ -465,10 +435,6 @@ export = {
465435 args . push ( `--remote-debugging-port=${ port } ` )
466436 args . push ( '--remote-debugging-address=127.0.0.1' )
467437
468- if ( useStdioCdp ( browser ) ) {
469- args . push ( '--remote-debugging-pipe' )
470- }
471-
472438 return args
473439 } ,
474440
@@ -524,16 +490,14 @@ export = {
524490 // first allows us to connect the remote interface,
525491 // start video recording and then
526492 // we will load the actual page
527- const launchedBrowser = await utils . launch ( browser , 'about:blank' , args , {
528- pipeStdio : useStdioCdp ( browser ) ,
529- } )
493+ const launchedBrowser = await utils . launch ( browser , 'about:blank' , args )
530494
531495 la ( launchedBrowser , 'did not get launched browser instance' )
532496
533497 // SECOND connect to the Chrome remote interface
534498 // and when the connection is ready
535499 // navigate to the actual url
536- const criClient = await this . _connectToChromeRemoteInterface ( browser , launchedBrowser , port , options . onError )
500+ const criClient = await this . _connectToChromeRemoteInterface ( port , options . onError )
537501
538502 la ( criClient , 'expected Chrome remote interface reference' , criClient )
539503
0 commit comments