Skip to content

Commit 9fa0f47

Browse files
Add devToolsCommit to debug options (and public API)
Currently CLI uses specific SHA of dev tools, that corresponds to Chrome 55. However, we may need different version for Android or iOS, so add new option. This will also allow specifying it from public API, so external calls may pass the commit SHA.
1 parent aaa7e56 commit 9fa0f47

File tree

5 files changed

+90
-2
lines changed

5 files changed

+90
-2
lines changed

PublicAPI.md

+8
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ interface IDebugOptions {
507507
* Default value is false.
508508
*/
509509
useHttpUrl?: boolean;
510+
511+
/**
512+
* Defines the commit that will be used in cases where remote protocol is required.
513+
* For Android this is the case when useHttpUrl is set to true or useBundledDevTools is set to false.
514+
* For iOS the value is used by default and when useHttpUrl is set to true.
515+
* Default value is 02e6bde1bbe34e43b309d4ef774b1168d25fd024 which corresponds to 55.0.2883 Chrome version
516+
*/
517+
devToolsCommit?: string;
510518
}
511519
```
512520

lib/definitions/debug.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ interface IDebugOptions {
7979
* Default value is false.
8080
*/
8181
useHttpUrl?: boolean;
82+
83+
/**
84+
* Defines the commit that will be used in cases where remote protocol is required.
85+
* For Android this is the case when useHttpUrl is set to true or useBundledDevTools is set to false.
86+
* For iOS the value is used by default and when useHttpUrl is set to true.
87+
* Default value is 02e6bde1bbe34e43b309d4ef774b1168d25fd024 which corresponds to 55.0.2883 Chrome version
88+
*/
89+
devToolsCommit?: string;
8290
}
8391

8492
/**

lib/services/debug-service-base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export abstract class DebugServiceBase extends EventEmitter implements IPlatform
2929

3030
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
3131
// corresponds to 55.0.2883 Chrome version
32-
const commitSHA = "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
32+
const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
3333
let chromeDevToolsPrefix = `chrome-devtools://devtools/remote/serve_file/@${commitSHA}`;
3434

3535
if (debugOptions.useBundledDevTools) {

test/services/android-debug-service.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface IChromeUrlTestCase {
4141
describe("androidDebugService", () => {
4242
describe("getChromeDebugUrl", () => {
4343
const expectedPort = 12345;
44+
const customDevToolsCommit = "customDevToolsCommit";
45+
4446
const chromUrlTestCases: IChromeUrlTestCase[] = [
4547
// Default CLI behavior:
4648
{
@@ -113,8 +115,38 @@ describe("androidDebugService", () => {
113115
useHttpUrl: true
114116
},
115117
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
116-
}
118+
},
117119

120+
// devToolsCommit tests
121+
122+
{
123+
scenarioName: "devToolsCommit defaults to 02e6bde1bbe34e43b309d4ef774b1168d25fd024 when useBundledDevTools is set to false",
124+
debugOptions: {
125+
useBundledDevTools: false
126+
},
127+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
128+
},
129+
{
130+
scenarioName: "devToolsCommit is disregarded when useBundledDevTools is not passed",
131+
debugOptions: {},
132+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
133+
},
134+
{
135+
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false",
136+
debugOptions: {
137+
useBundledDevTools: false,
138+
devToolsCommit: customDevToolsCommit
139+
},
140+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
141+
},
142+
{
143+
scenarioName: "devToolsCommit is set to passed value when useHttpUrl is set to true",
144+
debugOptions: {
145+
useHttpUrl: true,
146+
devToolsCommit: customDevToolsCommit
147+
},
148+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
149+
}
118150
];
119151

120152
for (const testCase of chromUrlTestCases) {

test/services/ios-debug-service.ts

+40
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ interface IChromeUrlTestCase {
5656
describe("iOSDebugService", () => {
5757
describe("getChromeDebugUrl", () => {
5858
const expectedPort = 12345;
59+
const customDevToolsCommit = "customDevToolsCommit";
60+
5961
const chromUrlTestCases: IChromeUrlTestCase[] = [
6062
// Default CLI behavior:
6163
{
@@ -128,6 +130,44 @@ describe("iOSDebugService", () => {
128130
useHttpUrl: true
129131
},
130132
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
133+
},
134+
135+
// devToolsCommit tests
136+
{
137+
scenarioName: "devToolsCommit defaults to 02e6bde1bbe34e43b309d4ef774b1168d25fd024 and is used in result when useBundledDevTools is not passed",
138+
debugOptions: {},
139+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
140+
},
141+
{
142+
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is not passed",
143+
debugOptions: {
144+
devToolsCommit: customDevToolsCommit
145+
},
146+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
147+
},
148+
{
149+
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false",
150+
debugOptions: {
151+
useBundledDevTools: false,
152+
devToolsCommit: customDevToolsCommit
153+
},
154+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
155+
},
156+
{
157+
scenarioName: "devToolsCommit is set to passed value when useHttpUrl is set to true",
158+
debugOptions: {
159+
useHttpUrl: true,
160+
devToolsCommit: customDevToolsCommit
161+
},
162+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
163+
},
164+
{
165+
scenarioName: "devToolsCommit is disregarded when useBundledDevTools is set to true",
166+
debugOptions: {
167+
useBundledDevTools: true,
168+
devToolsCommit: customDevToolsCommit
169+
},
170+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
131171
}
132172

133173
];

0 commit comments

Comments
 (0)