public launch()

in src/chromeDebugAdapter.ts [60:162]


    public launch(args: ILaunchRequestArgs, telemetryPropertyCollector: ITelemetryPropertyCollector, seq?: number): Promise<void> {
        if ((args.breakOnLoad || typeof args.breakOnLoad === 'undefined') && !args.breakOnLoadStrategy) {
            args.breakOnLoadStrategy = 'instrument';
        }

        return super.launch(args, telemetryPropertyCollector).then(async () => {
            let runtimeExecutable: string;
            if (args.shouldLaunchEdgeUnelevated !== undefined) {
                telemetryPropertyCollector.addTelemetryProperty('shouldLaunchEdgeUnelevated', args.shouldLaunchEdgeUnelevated.toString());
            }
            if (this._doesHostSupportLaunchUnelevatedProcessRequest) {
                telemetryPropertyCollector.addTelemetryProperty('doesHostSupportLaunchUnelevated', 'true');
            }
            if (args.runtimeExecutable) {
                // users should not be setting version flag if they are using runtimeExecutable
                if (args['version']) {
                    return errors.incorrectFlagMessage('version', 'Not to be used with \'runtimeExecutable\'');
                }
                const re = findExecutable(args.runtimeExecutable);
                if (!re) {
                    return errors.getNotExistErrorResponse('runtimeExecutable', args.runtimeExecutable);
                }
                runtimeExecutable = re;
            } else if (args['version']) {
                runtimeExecutable = utils.getBrowserPath(args['version']);
            }

            runtimeExecutable = runtimeExecutable || utils.getBrowserPath('stable');
            if (!runtimeExecutable) {
                return coreUtils.errP(localize('attribute.edge.missing', "Can't find Microsoft Edge - install it or set the \"runtimeExecutable\" field in the launch config."));
            }

            // Start with remote debugging enabled
            const port = args.port || 2015;
            const chromeArgs: string[] = [];
            const chromeEnv: coreUtils.IStringDictionary<string> = args.env || null;
            const chromeWorkingDir: string = args.cwd || null;

            if (!args.useWebView && !args.noDebug) {
                chromeArgs.push('--remote-debugging-port=' + port);
            }

            // Also start with extra stuff disabled
            if (!args.useWebView) {
                chromeArgs.push(...['--no-first-run', '--no-default-browser-check']);
            }

            if (args.runtimeArgs) {
                telemetryPropertyCollector.addTelemetryProperty('numberOfEdgeCmdLineSwitchesBeingUsed', String(args.runtimeArgs.length));
                chromeArgs.push(...args.runtimeArgs);
            } else {
                telemetryPropertyCollector.addTelemetryProperty('numberOfEdgeCmdLineSwitchesBeingUsed', '0');
            }

            // Set a default userDataDir, if the user opted in explicitly with 'true' or if args.userDataDir is not set (only when runtimeExecutable is not set).
            // Can't set it automatically with runtimeExecutable because it may not be desired with Electron, other runtimes, random scripts.
            if (
                args.userDataDir === true ||
                (typeof args.userDataDir === 'undefined' && !args.runtimeExecutable)
            ) {
                args.userDataDir = path.join(os.tmpdir(), `vscode-edge-debug-userdatadir_${port}`);
            }

            if (!args.useWebView && args.userDataDir) {
                chromeArgs.push('--user-data-dir=' + args.userDataDir);
            }

            if (args._clientOverlayPausedMessage) {
                this._pagePauseMessage = args._clientOverlayPausedMessage;
            }

            let launchUrl: string;
            if (args.file) {
                launchUrl = coreUtils.pathToFileURL(args.file);
            } else if (args.url) {
                launchUrl = args.url;
            }

            if (launchUrl && !args.noDebug) {
                // We store the launch file/url provided and temporarily launch and attach to about:blank page. Once we receive configurationDone() event, we redirect the page to this file/url
                // This is done to facilitate hitting breakpoints on load
                this._userRequestedUrl = launchUrl;
                launchUrl = 'about:blank';
            }

            if (!args.useWebView && launchUrl) {
                chromeArgs.push(launchUrl);
            }

            this._chromeProc = await this.spawnChrome(runtimeExecutable, chromeArgs, chromeEnv, chromeWorkingDir, !!args.runtimeExecutable,
                 args.shouldLaunchEdgeUnelevated);
            if (this._chromeProc) {
                this._chromeProc.on('error', (err) => {
                    const errMsg = 'Edge error: ' + err;
                    logger.error(errMsg);
                    this.terminateSession(errMsg);
                });
            }

            return args.noDebug ? undefined :
                this.doAttach(port, launchUrl || args.urlFilter, args.address, args.timeout, undefined, args.extraCRDPChannelPort);
        });
    }