Skip to content

Commit 0fa4f1a

Browse files
Support all Chrome channels
Also add support for binary to point to executable of your choice. Bug: none Change-Id: I122ad4fd117241c0c0106e2896e4fca602791958 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6397059 Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]>
1 parent 5211c83 commit 0fa4f1a

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed

docs/get_the_code.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ gclient sync
115115
The revisions of git dependencies must always be in sync between the entry in DEPS and the git submodule. PRESUBMIT will
116116
reject CLs that try to submit changes to one but not the other.
117117
It can happen that dependencies go out of sync for three main reasons:
118+
118119
1. The developer attempted a manual roll by only updating the DEPS file (which was the process before migrating to git
119120
submodules, see [below](#Managing-dependencies)),
120121
1. after switching branches or checking out new commit the developer didn't run `gclient sync`, or
@@ -195,7 +196,7 @@ Note that `$(realpath out/Default/gen/front_end)` expands to the absolute path t
195196

196197
Open DevTools via F12 or Ctrl+Shift+J on Windows/Linux or Cmd+Option+I on Mac.
197198

198-
If you get errors along the line of `Uncaught TypeError: Cannot read property 'setInspectedTabId'` you probably specified an incorrect path - the path has to be absolute. On Mac and Linux, the file url will start with __three__ slashes: `file:///Users/...`.
199+
If you get errors along the line of `Uncaught TypeError: Cannot read property 'setInspectedTabId'` you probably specified an incorrect path - the path has to be absolute. On Mac and Linux, the file url will start with **three** slashes: `file:///Users/...`.
199200

200201
**Tip**: You can inspect DevTools with DevTools by undocking DevTools and then opening a second instance of DevTools (see keyboard shortcut above).
201202

@@ -226,6 +227,7 @@ Then start Chrome, allowing for accesses from the web server:
226227
```
227228

228229
Get the list of pages together with their DevTools frontend URLs:
230+
229231
```bash
230232
$ curl http://localhost:9222/json -s | grep '\(url\|devtoolsFrontend\)'
231233
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/BADADD4E55BADADD4E55BADADD4E5511",

scripts/run_start.mjs

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import {computeSystemExecutablePath} from '@puppeteer/browsers';
56
import childProcess from 'node:child_process';
67
import path from 'node:path';
78
import yargs from 'yargs';
89
import {hideBin} from 'yargs/helpers';
910

10-
import {downloadedChromeBinaryPath, isInChromiumDirectory, rootPath} from './devtools_paths.js';
11+
import {
12+
downloadedChromeBinaryPath,
13+
isInChromiumDirectory,
14+
rootPath,
15+
} from './devtools_paths.js';
1116

1217
// The list of features that are enabled by default.
1318
const ENABLE_FEATURES = [
@@ -29,9 +34,17 @@ if (process.platform === 'darwin') {
2934
const argv = yargs(hideBin(process.argv))
3035
.option('browser', {
3136
type: 'string',
32-
choices: ['cft', 'canary'],
37+
// CfT is not downloaded in Chromium checkout
3338
default: isInChromiumDirectory().isInChromium ? 'canary' : 'cft',
34-
description: 'Launch in the specified browser',
39+
description: 'Launch in specified Chrome channel, CfT or a custom binary',
40+
coerce(arg) {
41+
if (arg.includes(path.sep) || arg.includes(path.posix.sep) ||
42+
['cft', 'stable', 'beta', 'dev', 'canary'].includes(arg)) {
43+
return arg;
44+
}
45+
46+
throw new Error(`Unsupported channel "${arg}"`);
47+
},
3548
})
3649
.option('open', {
3750
type: 'boolean',
@@ -60,32 +73,38 @@ const {env} = process;
6073
const runBuildPath = path.join(import.meta.dirname, 'run_build.mjs');
6174

6275
function findBrowserBinary() {
63-
if (browser === 'canary') {
64-
const binary = ({
65-
linux: path.join('/usr', 'bin', 'google-chrome-unstable'),
66-
darwin: path.join('/Applications', 'Google Chrome Canary.app', 'Contents', 'MacOS', 'Google Chrome Canary'),
67-
})[process.platform];
76+
if (browser === 'cft') {
77+
const binary = downloadedChromeBinaryPath();
78+
if (verbose) {
79+
console.debug('Located Chrome for Testing binary at %s.', binary);
80+
}
81+
return binary;
82+
}
83+
84+
if (['stable', 'beta', 'dev', 'canary'].includes(browser)) {
85+
const binary = computeSystemExecutablePath({
86+
browser: 'chrome',
87+
channel: browser,
88+
});
89+
6890
if (verbose) {
69-
console.debug('Located Chrome Canary binary in %s.', binary);
91+
console.debug(`Located Chrome ${browser} binary at ${binary}.`);
7092
}
7193
return binary;
7294
}
73-
const binary = downloadedChromeBinaryPath();
95+
7496
if (verbose) {
75-
console.debug('Located Chrome for Testing binary in %s.', binary);
97+
console.debug(`Launching custom binary at ${binary}.`);
7698
}
77-
return binary;
99+
return browser;
78100
}
79101

80102
// Perform the initial build.
81-
childProcess.spawnSync(
82-
process.argv[0],
83-
[
84-
runBuildPath,
85-
`--target=${target}`,
86-
],
87-
{cwd, env, stdio: 'inherit'},
88-
);
103+
childProcess.spawnSync(process.argv[0], [runBuildPath, `--target=${target}`], {
104+
cwd,
105+
env,
106+
stdio: 'inherit',
107+
});
89108

90109
// Launch Chrome with our custom DevTools front-end.
91110
function start() {
@@ -130,13 +149,9 @@ function start() {
130149
// devtools-frontend whenever there are changes detected.
131150
const watcher = childProcess.spawn(
132151
process.argv[0],
133-
[
134-
runBuildPath,
135-
'--skip-initial-build',
136-
`--target=${target}`,
137-
'--watch',
138-
],
139-
{cwd, env, stdio: 'inherit'});
152+
[runBuildPath, '--skip-initial-build', `--target=${target}`, '--watch'],
153+
{cwd, env, stdio: 'inherit'},
154+
);
140155
try {
141156
// Launch chrome.
142157
start();

0 commit comments

Comments
 (0)