Skip to content

Commit 3690b2d

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 a7de6e3 commit 3690b2d

File tree

7 files changed

+107
-16
lines changed

7 files changed

+107
-16
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/android-debug-service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
5252
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
5353
const debugOpts = _.cloneDeep(debugOptions);
5454
debugOpts.useBundledDevTools = debugOpts.useBundledDevTools === undefined ? true : debugOpts.useBundledDevTools;
55-
debugOpts.useHttpUrl = debugOpts.useHttpUrl === undefined ? false : debugOpts.useHttpUrl;
5655

5756
const chromeDebugUrl = super.getChromeDebugUrl(debugOpts, port);
5857
return chromeDebugUrl;

lib/services/debug-service-base.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ 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";
33+
debugOptions.useHttpUrl = debugOptions.useHttpUrl === undefined ? false : debugOptions.useHttpUrl;
34+
3335
let chromeDevToolsPrefix = `chrome-devtools://devtools/remote/serve_file/@${commitSHA}`;
3436

3537
if (debugOptions.useBundledDevTools) {

lib/services/ios-debug-service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
9696
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
9797
const debugOpts = _.cloneDeep(debugOptions);
9898
debugOpts.useBundledDevTools = debugOpts.useBundledDevTools === undefined ? false : debugOpts.useBundledDevTools;
99-
debugOpts.useHttpUrl = debugOpts.useHttpUrl === undefined ? false : debugOpts.useHttpUrl;
10099

101100
const chromeDebugUrl = super.getChromeDebugUrl(debugOpts, port);
102101
return chromeDebugUrl;

test/services/android-debug-service.ts

+39-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Yok } from "../../lib/common/yok";
33
import * as stubs from "../stubs";
44
import { assert } from "chai";
55

6+
const expectedDevToolsCommitSha = "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
7+
68
class AndroidDebugServiceInheritor extends AndroidDebugService {
79
constructor(protected $devicesService: Mobile.IDevicesService,
810
$errors: IErrors,
@@ -41,6 +43,8 @@ interface IChromeUrlTestCase {
4143
describe("androidDebugService", () => {
4244
describe("getChromeDebugUrl", () => {
4345
const expectedPort = 12345;
46+
const customDevToolsCommit = "customDevToolsCommit";
47+
4448
const chromUrlTestCases: IChromeUrlTestCase[] = [
4549
// Default CLI behavior:
4650
{
@@ -71,7 +75,7 @@ describe("androidDebugService", () => {
7175
useBundledDevTools: true,
7276
useHttpUrl: true
7377
},
74-
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
78+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
7579
},
7680

7781
// When useBundledDevTools is false
@@ -80,23 +84,23 @@ describe("androidDebugService", () => {
8084
debugOptions: {
8185
useBundledDevTools: false
8286
},
83-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
87+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
8488
},
8589
{
8690
scenarioName: "useBundledDevTools is false and useHttpUrl is false",
8791
debugOptions: {
8892
useBundledDevTools: false,
8993
useHttpUrl: false
9094
},
91-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
95+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
9296
},
9397
{
9498
scenarioName: "useBundledDevTools is false and useHttpUrl is true",
9599
debugOptions: {
96100
useBundledDevTools: false,
97101
useHttpUrl: true
98102
},
99-
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
103+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
100104
},
101105

102106
// When useBundledDevTools is not passed
@@ -112,9 +116,38 @@ describe("androidDebugService", () => {
112116
debugOptions: {
113117
useHttpUrl: true
114118
},
115-
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
116-
}
119+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
120+
},
117121

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

120153
for (const testCase of chromUrlTestCases) {

test/services/ios-debug-service.ts

+49-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Yok } from "../../lib/common/yok";
33
import * as stubs from "../stubs";
44
import { assert } from "chai";
55

6+
const expectedDevToolsCommitSha = "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
7+
68
class IOSDebugServiceInheritor extends IOSDebugService {
79
constructor(protected $devicesService: Mobile.IDevicesService,
810
$platformService: IPlatformService,
@@ -56,12 +58,14 @@ interface IChromeUrlTestCase {
5658
describe("iOSDebugService", () => {
5759
describe("getChromeDebugUrl", () => {
5860
const expectedPort = 12345;
61+
const customDevToolsCommit = "customDevToolsCommit";
62+
5963
const chromUrlTestCases: IChromeUrlTestCase[] = [
6064
// Default CLI behavior:
6165
{
6266
scenarioName: "useBundledDevTools and useHttpUrl are not passed",
6367
debugOptions: {},
64-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
68+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
6569
},
6670

6771
// When useBundledDevTools is true
@@ -86,7 +90,7 @@ describe("iOSDebugService", () => {
8690
useBundledDevTools: true,
8791
useHttpUrl: true
8892
},
89-
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
93+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
9094
},
9195

9296
// When useBundledDevTools is false
@@ -95,23 +99,23 @@ describe("iOSDebugService", () => {
9599
debugOptions: {
96100
useBundledDevTools: false
97101
},
98-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
102+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
99103
},
100104
{
101105
scenarioName: "useBundledDevTools is false and useHttpUrl is false",
102106
debugOptions: {
103107
useBundledDevTools: false,
104108
useHttpUrl: false
105109
},
106-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
110+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
107111
},
108112
{
109113
scenarioName: "useBundledDevTools is false and useHttpUrl is true",
110114
debugOptions: {
111115
useBundledDevTools: false,
112116
useHttpUrl: true
113117
},
114-
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
118+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
115119
},
116120

117121
// When useBundledDevTools is not passed
@@ -120,14 +124,52 @@ describe("iOSDebugService", () => {
120124
debugOptions: {
121125
useHttpUrl: false
122126
},
123-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
127+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
124128
},
125129
{
126130
scenarioName: "useBundledDevTools is not passed and useHttpUrl is true",
127131
debugOptions: {
128132
useHttpUrl: true
129133
},
130-
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
134+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
135+
},
136+
137+
// devToolsCommit tests
138+
{
139+
scenarioName: "devToolsCommit defaults to ${expectedDevToolsCommitSha} and is used in result when useBundledDevTools is not passed",
140+
debugOptions: {},
141+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
142+
},
143+
{
144+
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is not passed",
145+
debugOptions: {
146+
devToolsCommit: customDevToolsCommit
147+
},
148+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
149+
},
150+
{
151+
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false",
152+
debugOptions: {
153+
useBundledDevTools: false,
154+
devToolsCommit: customDevToolsCommit
155+
},
156+
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
157+
},
158+
{
159+
scenarioName: "devToolsCommit is set to passed value when useHttpUrl is set to true",
160+
debugOptions: {
161+
useHttpUrl: true,
162+
devToolsCommit: customDevToolsCommit
163+
},
164+
expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
165+
},
166+
{
167+
scenarioName: "devToolsCommit is disregarded when useBundledDevTools is set to true",
168+
debugOptions: {
169+
useBundledDevTools: true,
170+
devToolsCommit: customDevToolsCommit
171+
},
172+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
131173
}
132174

133175
];

0 commit comments

Comments
 (0)