From 639615d8c2a80d55aa1bcb7d6fa16e89cc367d6b Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 30 May 2020 10:44:34 -0700 Subject: [PATCH 1/3] fix(chrome): new debug url with latest chrome 83+ versions closes https://github.com/NativeScript/NativeScript/issues/8605 --- lib/controllers/debug-controller.ts | 4 +- lib/declarations.d.ts | 1 + lib/definitions/debug.d.ts | 1 + lib/services/android-device-debug-service.ts | 1 + lib/services/debug-service-base.ts | 12 +++--- lib/services/ios-device-debug-service.ts | 16 +++---- test/services/android-device-debug-service.ts | 40 ++++++++++------- test/services/ios-device-debug-service.ts | 43 +++++++++++-------- 8 files changed, 71 insertions(+), 47 deletions(-) diff --git a/lib/controllers/debug-controller.ts b/lib/controllers/debug-controller.ts index 0b86d66c2b..9c59638a0b 100644 --- a/lib/controllers/debug-controller.ts +++ b/lib/controllers/debug-controller.ts @@ -157,7 +157,9 @@ export class DebugController extends EventEmitter implements IDebugController { this.emit(DEBUGGER_ATTACHED_EVENT_NAME, debugInformation); } - this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${debugInformation.url}${EOL}`.cyan); + this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${debugInformation.url}${EOL}`.green); + + this.$logger.info(`If you're using an older Chrome version 82 and below, use this instead:${EOL}${debugInformation.legacyUrl}${EOL}`.cyan); } return debugInformation; diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index 47b945d5e4..0bc7ced77e 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -494,6 +494,7 @@ interface IGenerateOptions { interface IDebugInformation extends IPort, Mobile.IDeviceIdentifier { url: string; + legacyUrl?: string; } interface IPort { diff --git a/lib/definitions/debug.d.ts b/lib/definitions/debug.d.ts index b835ab261b..589b8b9bc7 100644 --- a/lib/definitions/debug.d.ts +++ b/lib/definitions/debug.d.ts @@ -116,6 +116,7 @@ interface IDeviceDebugService extends IPlatform, NodeJS.EventEmitter { interface IDebugResultInfo { debugUrl: string; + legacyDebugUrl?: string; } interface IAppDebugData extends IProjectDir { diff --git a/lib/services/android-device-debug-service.ts b/lib/services/android-device-debug-service.ts index 4c52c56291..672c66d1fc 100644 --- a/lib/services/android-device-debug-service.ts +++ b/lib/services/android-device-debug-service.ts @@ -99,6 +99,7 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi await this.printDebugPort(this.deviceIdentifier, debugPort); result.debugUrl = this.getChromeDebugUrl(debugOptions, debugPort); + result.legacyDebugUrl = this.getChromeDebugUrl(debugOptions, debugPort, true); return result; } diff --git a/lib/services/debug-service-base.ts b/lib/services/debug-service-base.ts index 4b6a9ea097..97c964cb97 100644 --- a/lib/services/debug-service-base.ts +++ b/lib/services/debug-service-base.ts @@ -28,9 +28,9 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe return true; } }; - } + } - protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { + protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number, legacy?: boolean): string { // corresponds to 55.0.2883 Chrome version // SHA is taken from https://chromium.googlesource.com/chromium/src/+/55.0.2883.100 // This SHA is old and does not support debugging with HMR. @@ -39,17 +39,19 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe // Using the actual commit will result in 404 error in the remote serve. const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024"; - let chromeDevToolsPrefix = `chrome-devtools://devtools/remote/serve_file/@${commitSHA}`; + const devToolsProtocol = `${legacy ? 'chrome-' : ''}devtools`; + + let chromeDevToolsPrefix = `${devToolsProtocol}://devtools/remote/serve_file/@${commitSHA}`; if (debugOptions.useBundledDevTools === undefined || debugOptions.useBundledDevTools) { - chromeDevToolsPrefix = "chrome-devtools://devtools/bundled"; + chromeDevToolsPrefix = `${devToolsProtocol}://devtools/bundled`; } if (debugOptions.useHttpUrl) { chromeDevToolsPrefix = `https://chrome-devtools-frontend.appspot.com/serve_file/@${commitSHA}`; } - const chromeUrl = `${chromeDevToolsPrefix}/inspector.html?experiments=true&ws=localhost:${port}`; + const chromeUrl = `${chromeDevToolsPrefix}/inspector.html?ws=localhost:${port}${legacy ? '&experiments=true' : ''}`; return chromeUrl; } } diff --git a/lib/services/ios-device-debug-service.ts b/lib/services/ios-device-debug-service.ts index 81a3bd3f88..3b3a341aa6 100644 --- a/lib/services/ios-device-debug-service.ts +++ b/lib/services/ios-device-debug-service.ts @@ -32,12 +32,9 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe @performanceLog() public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise { - const result: IDebugResultInfo = { debugUrl: null }; await this.validateOptions(debugOptions); - result.debugUrl = await this.wireDebuggerClient(debugData, debugOptions); - - return result; + return await this.wireDebuggerClient(debugData, debugOptions); } public async debugStop(): Promise { @@ -84,7 +81,7 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe } @performanceLog() - private async wireDebuggerClient(debugData: IDebugData, debugOptions: IDebugOptions): Promise { + private async wireDebuggerClient(debugData: IDebugData, debugOptions: IDebugOptions): Promise { if ((debugOptions.inspector || !debugOptions.client) && this.$hostInfo.isDarwin) { return await this.setupTcpAppDebugProxy(debugData, debugOptions); } else { @@ -92,17 +89,20 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe } } - private async setupWebAppDebugProxy(debugOptions: IDebugOptions, debugData: IDebugData): Promise { + private async setupWebAppDebugProxy(debugOptions: IDebugOptions, debugData: IDebugData): Promise { if (debugOptions.chrome) { this.$logger.info("'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector."); } const projectName = this.getProjectName(debugData); const webSocketProxy = await this.$appDebugSocketProxyFactory.ensureWebSocketProxy(this.device, debugData.applicationIdentifier, projectName, debugData.projectDir); - return this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port); + return { + debugUrl: this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port), + legacyDebugUrl: this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port, true) + }; } - private async setupTcpAppDebugProxy(debugData: IDebugData, debugOptions: IDebugOptions): Promise { + private async setupTcpAppDebugProxy(debugData: IDebugData, debugOptions: IDebugOptions): Promise { const projectName = this.getProjectName(debugData); const existingTcpProxy = this.$appDebugSocketProxyFactory.getTCPSocketProxy(this.deviceIdentifier, debugData.applicationIdentifier); const tcpSocketProxy = existingTcpProxy || await this.$appDebugSocketProxyFactory.addTCPSocketProxy(this.device, debugData.applicationIdentifier, projectName, debugData.projectDir); diff --git a/test/services/android-device-debug-service.ts b/test/services/android-device-debug-service.ts index 438fa77c5e..9829b56baf 100644 --- a/test/services/android-device-debug-service.ts +++ b/test/services/android-device-debug-service.ts @@ -17,8 +17,8 @@ class AndroidDeviceDebugServiceInheritor extends AndroidDeviceDebugService { super({ deviceInfo: { identifier: "123" } }, $devicesService, $cleanupService, $errors, $logger, $androidProcessService, $staticConfig, $net, $deviceLogProvider); } - public getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { - return super.getChromeDebugUrl(debugOptions, port); + public getChromeDebugUrl(debugOptions: IDebugOptions, port: number, legacy?: boolean): string { + return super.getChromeDebugUrl(debugOptions, port, legacy); } } @@ -43,6 +43,7 @@ interface IChromeUrlTestCase { debugOptions: IDebugOptions; expectedChromeUrl: string; scenarioName: string; + legacy?: boolean; } describe("androidDeviceDebugService", () => { @@ -55,7 +56,14 @@ describe("androidDeviceDebugService", () => { { scenarioName: "useBundledDevTools and useHttpUrl are not passed", debugOptions: {}, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, + }, + // legacy chrome debug url + { + scenarioName: "useBundledDevTools and useHttpUrl are not passed and using legacy chrome debug url", + debugOptions: {}, + expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}&experiments=true`, + legacy: true }, // When useBundledDevTools is true @@ -64,7 +72,7 @@ describe("androidDeviceDebugService", () => { debugOptions: { useBundledDevTools: true }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is true and useHttpUrl is false", @@ -72,7 +80,7 @@ describe("androidDeviceDebugService", () => { useBundledDevTools: true, useHttpUrl: false }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is true and useHttpUrl is true", @@ -80,7 +88,7 @@ describe("androidDeviceDebugService", () => { useBundledDevTools: true, useHttpUrl: true }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, // When useBundledDevTools is false @@ -89,7 +97,7 @@ describe("androidDeviceDebugService", () => { debugOptions: { useBundledDevTools: false }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is false and useHttpUrl is false", @@ -97,7 +105,7 @@ describe("androidDeviceDebugService", () => { useBundledDevTools: false, useHttpUrl: false }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is false and useHttpUrl is true", @@ -105,7 +113,7 @@ describe("androidDeviceDebugService", () => { useBundledDevTools: false, useHttpUrl: true }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, // When useBundledDevTools is not passed @@ -114,14 +122,14 @@ describe("androidDeviceDebugService", () => { debugOptions: { useHttpUrl: false }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is not passed and useHttpUrl is true", debugOptions: { useHttpUrl: true }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, // devToolsCommit tests @@ -130,12 +138,12 @@ describe("androidDeviceDebugService", () => { debugOptions: { useBundledDevTools: false }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is disregarded when useBundledDevTools is not passed", debugOptions: {}, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false", @@ -143,7 +151,7 @@ describe("androidDeviceDebugService", () => { useBundledDevTools: false, devToolsCommit: customDevToolsCommit }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is set to passed value when useHttpUrl is set to true", @@ -151,7 +159,7 @@ describe("androidDeviceDebugService", () => { useHttpUrl: true, devToolsCommit: customDevToolsCommit }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?ws=localhost:${expectedPort}`, } ]; @@ -159,7 +167,7 @@ describe("androidDeviceDebugService", () => { it(`returns correct url when ${testCase.scenarioName}`, () => { const testInjector = createTestInjector(); const androidDeviceDebugService = testInjector.resolve(AndroidDeviceDebugServiceInheritor); - const actualChromeUrl = androidDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort); + const actualChromeUrl = androidDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort, testCase.legacy); assert.equal(actualChromeUrl, testCase.expectedChromeUrl); }); } diff --git a/test/services/ios-device-debug-service.ts b/test/services/ios-device-debug-service.ts index cff0409d54..7859e66bd1 100644 --- a/test/services/ios-device-debug-service.ts +++ b/test/services/ios-device-debug-service.ts @@ -18,8 +18,8 @@ class IOSDeviceDebugServiceInheritor extends IOSDeviceDebugService { $packageInstallationManager, $appDebugSocketProxyFactory, $projectDataService); } - public getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { - return super.getChromeDebugUrl(debugOptions, port); + public getChromeDebugUrl(debugOptions: IDebugOptions, port: number, legacy?: boolean): string { + return super.getChromeDebugUrl(debugOptions, port, legacy); } } @@ -55,6 +55,7 @@ interface IChromeUrlTestCase { debugOptions: IDebugOptions; expectedChromeUrl: string; scenarioName: string; + legacy?: boolean; } describe("iOSDeviceDebugService", () => { @@ -67,7 +68,15 @@ describe("iOSDeviceDebugService", () => { { scenarioName: "useBundledDevTools and useHttpUrl are not passed", debugOptions: {}, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, + }, + + // legacy chrome debug url + { + scenarioName: "useBundledDevTools and useHttpUrl are not passed and using legacy chrome debug url", + debugOptions: {}, + expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}&experiments=true`, + legacy: true }, // When useBundledDevTools is true @@ -76,7 +85,7 @@ describe("iOSDeviceDebugService", () => { debugOptions: { useBundledDevTools: true }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is true and useHttpUrl is false", @@ -84,7 +93,7 @@ describe("iOSDeviceDebugService", () => { useBundledDevTools: true, useHttpUrl: false }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is true and useHttpUrl is true", @@ -92,7 +101,7 @@ describe("iOSDeviceDebugService", () => { useBundledDevTools: true, useHttpUrl: true }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, // When useBundledDevTools is false @@ -101,7 +110,7 @@ describe("iOSDeviceDebugService", () => { debugOptions: { useBundledDevTools: false }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is false and useHttpUrl is false", @@ -109,7 +118,7 @@ describe("iOSDeviceDebugService", () => { useBundledDevTools: false, useHttpUrl: false }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is false and useHttpUrl is true", @@ -117,7 +126,7 @@ describe("iOSDeviceDebugService", () => { useBundledDevTools: false, useHttpUrl: true }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, // When useBundledDevTools is not passed @@ -126,14 +135,14 @@ describe("iOSDeviceDebugService", () => { debugOptions: { useHttpUrl: false }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "useBundledDevTools is not passed and useHttpUrl is true", debugOptions: { useHttpUrl: true }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, // devToolsCommit tests @@ -142,14 +151,14 @@ describe("iOSDeviceDebugService", () => { debugOptions: { useBundledDevTools: false }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is disregarded when useBundledDevTools is not passed", debugOptions: { devToolsCommit: customDevToolsCommit }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false", @@ -157,7 +166,7 @@ describe("iOSDeviceDebugService", () => { useBundledDevTools: false, devToolsCommit: customDevToolsCommit }, - expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is set to passed value when useHttpUrl is set to true", @@ -165,7 +174,7 @@ describe("iOSDeviceDebugService", () => { useHttpUrl: true, devToolsCommit: customDevToolsCommit }, - expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `https://chrome-devtools-frontend.appspot.com/serve_file/@${customDevToolsCommit}/inspector.html?ws=localhost:${expectedPort}`, }, { scenarioName: "devToolsCommit is disregarded when useBundledDevTools is set to true", @@ -173,7 +182,7 @@ describe("iOSDeviceDebugService", () => { useBundledDevTools: true, devToolsCommit: customDevToolsCommit }, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`, + expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, } ]; @@ -182,7 +191,7 @@ describe("iOSDeviceDebugService", () => { it(`returns correct url when ${testCase.scenarioName}`, () => { const testInjector = createTestInjector(); const iOSDeviceDebugService = testInjector.resolve(IOSDeviceDebugServiceInheritor); - const actualChromeUrl = iOSDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort); + const actualChromeUrl = iOSDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort, testCase.legacy); assert.equal(actualChromeUrl, testCase.expectedChromeUrl); }); } From 184ae11b4728590271f4ba9f260531afa9a422e8 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 30 May 2020 11:58:17 -0700 Subject: [PATCH 2/3] chore: cleanup --- lib/controllers/debug-controller.ts | 2 -- lib/declarations.d.ts | 1 - lib/definitions/debug.d.ts | 1 - lib/services/android-device-debug-service.ts | 1 - lib/services/debug-service-base.ts | 10 ++++------ lib/services/ios-device-debug-service.ts | 16 ++++++++-------- test/services/android-device-debug-service.ts | 14 +++----------- test/services/ios-device-debug-service.ts | 15 +++------------ 8 files changed, 18 insertions(+), 42 deletions(-) diff --git a/lib/controllers/debug-controller.ts b/lib/controllers/debug-controller.ts index 9c59638a0b..3292870853 100644 --- a/lib/controllers/debug-controller.ts +++ b/lib/controllers/debug-controller.ts @@ -158,8 +158,6 @@ export class DebugController extends EventEmitter implements IDebugController { } this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${debugInformation.url}${EOL}`.green); - - this.$logger.info(`If you're using an older Chrome version 82 and below, use this instead:${EOL}${debugInformation.legacyUrl}${EOL}`.cyan); } return debugInformation; diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index 0bc7ced77e..47b945d5e4 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -494,7 +494,6 @@ interface IGenerateOptions { interface IDebugInformation extends IPort, Mobile.IDeviceIdentifier { url: string; - legacyUrl?: string; } interface IPort { diff --git a/lib/definitions/debug.d.ts b/lib/definitions/debug.d.ts index 589b8b9bc7..b835ab261b 100644 --- a/lib/definitions/debug.d.ts +++ b/lib/definitions/debug.d.ts @@ -116,7 +116,6 @@ interface IDeviceDebugService extends IPlatform, NodeJS.EventEmitter { interface IDebugResultInfo { debugUrl: string; - legacyDebugUrl?: string; } interface IAppDebugData extends IProjectDir { diff --git a/lib/services/android-device-debug-service.ts b/lib/services/android-device-debug-service.ts index 672c66d1fc..4c52c56291 100644 --- a/lib/services/android-device-debug-service.ts +++ b/lib/services/android-device-debug-service.ts @@ -99,7 +99,6 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi await this.printDebugPort(this.deviceIdentifier, debugPort); result.debugUrl = this.getChromeDebugUrl(debugOptions, debugPort); - result.legacyDebugUrl = this.getChromeDebugUrl(debugOptions, debugPort, true); return result; } diff --git a/lib/services/debug-service-base.ts b/lib/services/debug-service-base.ts index 97c964cb97..aec3c195f3 100644 --- a/lib/services/debug-service-base.ts +++ b/lib/services/debug-service-base.ts @@ -30,7 +30,7 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe }; } - protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number, legacy?: boolean): string { + protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { // corresponds to 55.0.2883 Chrome version // SHA is taken from https://chromium.googlesource.com/chromium/src/+/55.0.2883.100 // This SHA is old and does not support debugging with HMR. @@ -39,19 +39,17 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe // Using the actual commit will result in 404 error in the remote serve. const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024"; - const devToolsProtocol = `${legacy ? 'chrome-' : ''}devtools`; - - let chromeDevToolsPrefix = `${devToolsProtocol}://devtools/remote/serve_file/@${commitSHA}`; + let chromeDevToolsPrefix = `devtools://devtools/remote/serve_file/@${commitSHA}`; if (debugOptions.useBundledDevTools === undefined || debugOptions.useBundledDevTools) { - chromeDevToolsPrefix = `${devToolsProtocol}://devtools/bundled`; + chromeDevToolsPrefix = `devtools://devtools/bundled`; } if (debugOptions.useHttpUrl) { chromeDevToolsPrefix = `https://chrome-devtools-frontend.appspot.com/serve_file/@${commitSHA}`; } - const chromeUrl = `${chromeDevToolsPrefix}/inspector.html?ws=localhost:${port}${legacy ? '&experiments=true' : ''}`; + const chromeUrl = `${chromeDevToolsPrefix}/inspector.html?ws=localhost:${port}`; return chromeUrl; } } diff --git a/lib/services/ios-device-debug-service.ts b/lib/services/ios-device-debug-service.ts index 3b3a341aa6..6a455c6d82 100644 --- a/lib/services/ios-device-debug-service.ts +++ b/lib/services/ios-device-debug-service.ts @@ -33,8 +33,11 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe @performanceLog() public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise { await this.validateOptions(debugOptions); + const result: IDebugResultInfo = { debugUrl: null }; - return await this.wireDebuggerClient(debugData, debugOptions); + result.debugUrl = await this.wireDebuggerClient(debugData, debugOptions); + + return result; } public async debugStop(): Promise { @@ -81,7 +84,7 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe } @performanceLog() - private async wireDebuggerClient(debugData: IDebugData, debugOptions: IDebugOptions): Promise { + private async wireDebuggerClient(debugData: IDebugData, debugOptions: IDebugOptions): Promise { if ((debugOptions.inspector || !debugOptions.client) && this.$hostInfo.isDarwin) { return await this.setupTcpAppDebugProxy(debugData, debugOptions); } else { @@ -89,20 +92,17 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe } } - private async setupWebAppDebugProxy(debugOptions: IDebugOptions, debugData: IDebugData): Promise { + private async setupWebAppDebugProxy(debugOptions: IDebugOptions, debugData: IDebugData): Promise { if (debugOptions.chrome) { this.$logger.info("'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector."); } const projectName = this.getProjectName(debugData); const webSocketProxy = await this.$appDebugSocketProxyFactory.ensureWebSocketProxy(this.device, debugData.applicationIdentifier, projectName, debugData.projectDir); - return { - debugUrl: this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port), - legacyDebugUrl: this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port, true) - }; + return this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port); } - private async setupTcpAppDebugProxy(debugData: IDebugData, debugOptions: IDebugOptions): Promise { + private async setupTcpAppDebugProxy(debugData: IDebugData, debugOptions: IDebugOptions): Promise { const projectName = this.getProjectName(debugData); const existingTcpProxy = this.$appDebugSocketProxyFactory.getTCPSocketProxy(this.deviceIdentifier, debugData.applicationIdentifier); const tcpSocketProxy = existingTcpProxy || await this.$appDebugSocketProxyFactory.addTCPSocketProxy(this.device, debugData.applicationIdentifier, projectName, debugData.projectDir); diff --git a/test/services/android-device-debug-service.ts b/test/services/android-device-debug-service.ts index 9829b56baf..1bb12b73aa 100644 --- a/test/services/android-device-debug-service.ts +++ b/test/services/android-device-debug-service.ts @@ -17,8 +17,8 @@ class AndroidDeviceDebugServiceInheritor extends AndroidDeviceDebugService { super({ deviceInfo: { identifier: "123" } }, $devicesService, $cleanupService, $errors, $logger, $androidProcessService, $staticConfig, $net, $deviceLogProvider); } - public getChromeDebugUrl(debugOptions: IDebugOptions, port: number, legacy?: boolean): string { - return super.getChromeDebugUrl(debugOptions, port, legacy); + public getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { + return super.getChromeDebugUrl(debugOptions, port); } } @@ -43,7 +43,6 @@ interface IChromeUrlTestCase { debugOptions: IDebugOptions; expectedChromeUrl: string; scenarioName: string; - legacy?: boolean; } describe("androidDeviceDebugService", () => { @@ -58,13 +57,6 @@ describe("androidDeviceDebugService", () => { debugOptions: {}, expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, - // legacy chrome debug url - { - scenarioName: "useBundledDevTools and useHttpUrl are not passed and using legacy chrome debug url", - debugOptions: {}, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}&experiments=true`, - legacy: true - }, // When useBundledDevTools is true { @@ -167,7 +159,7 @@ describe("androidDeviceDebugService", () => { it(`returns correct url when ${testCase.scenarioName}`, () => { const testInjector = createTestInjector(); const androidDeviceDebugService = testInjector.resolve(AndroidDeviceDebugServiceInheritor); - const actualChromeUrl = androidDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort, testCase.legacy); + const actualChromeUrl = androidDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort); assert.equal(actualChromeUrl, testCase.expectedChromeUrl); }); } diff --git a/test/services/ios-device-debug-service.ts b/test/services/ios-device-debug-service.ts index 7859e66bd1..ea8818d3d0 100644 --- a/test/services/ios-device-debug-service.ts +++ b/test/services/ios-device-debug-service.ts @@ -18,8 +18,8 @@ class IOSDeviceDebugServiceInheritor extends IOSDeviceDebugService { $packageInstallationManager, $appDebugSocketProxyFactory, $projectDataService); } - public getChromeDebugUrl(debugOptions: IDebugOptions, port: number, legacy?: boolean): string { - return super.getChromeDebugUrl(debugOptions, port, legacy); + public getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { + return super.getChromeDebugUrl(debugOptions, port); } } @@ -55,7 +55,6 @@ interface IChromeUrlTestCase { debugOptions: IDebugOptions; expectedChromeUrl: string; scenarioName: string; - legacy?: boolean; } describe("iOSDeviceDebugService", () => { @@ -71,14 +70,6 @@ describe("iOSDeviceDebugService", () => { expectedChromeUrl: `devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}`, }, - // legacy chrome debug url - { - scenarioName: "useBundledDevTools and useHttpUrl are not passed and using legacy chrome debug url", - debugOptions: {}, - expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?ws=localhost:${expectedPort}&experiments=true`, - legacy: true - }, - // When useBundledDevTools is true { scenarioName: "useBundledDevTools is true and useHttpUrl is not passed", @@ -191,7 +182,7 @@ describe("iOSDeviceDebugService", () => { it(`returns correct url when ${testCase.scenarioName}`, () => { const testInjector = createTestInjector(); const iOSDeviceDebugService = testInjector.resolve(IOSDeviceDebugServiceInheritor); - const actualChromeUrl = iOSDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort, testCase.legacy); + const actualChromeUrl = iOSDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort); assert.equal(actualChromeUrl, testCase.expectedChromeUrl); }); } From a823fc0f92bf9b338b8a096ded3af806ab79f3ea Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 30 May 2020 12:01:05 -0700 Subject: [PATCH 3/3] chore: cleanup --- lib/services/debug-service-base.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/services/debug-service-base.ts b/lib/services/debug-service-base.ts index aec3c195f3..48e0eadc98 100644 --- a/lib/services/debug-service-base.ts +++ b/lib/services/debug-service-base.ts @@ -28,7 +28,7 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe return true; } }; - } + } protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string { // corresponds to 55.0.2883 Chrome version @@ -39,10 +39,11 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe // Using the actual commit will result in 404 error in the remote serve. const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024"; - let chromeDevToolsPrefix = `devtools://devtools/remote/serve_file/@${commitSHA}`; + const devToolsProtocol = `devtools`; + let chromeDevToolsPrefix = `${devToolsProtocol}://devtools/remote/serve_file/@${commitSHA}`; if (debugOptions.useBundledDevTools === undefined || debugOptions.useBundledDevTools) { - chromeDevToolsPrefix = `devtools://devtools/bundled`; + chromeDevToolsPrefix = `${devToolsProtocol}://devtools/bundled`; } if (debugOptions.useHttpUrl) {