@@ -149,17 +149,19 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
149149 }
150150
151151 protected onFrameNavigated ( params : Crdp . Page . FrameNavigatedEvent ) : void {
152- const url = params . frame . url ;
153- const requestedUrlNoAnchor = this . _userRequestedUrl . split ( '#' ) [ 0 ] ; // Frame navigated url doesn't include the anchor
154- if ( url === requestedUrlNoAnchor || decodeURI ( url ) === requestedUrlNoAnchor ) { // 'http://localhost:1234/test%20page' will use the not decoded version, 'http://localhost:1234/test page' will use the decoded version
155- // Chrome started to navigate to the user's requested url
156- this . events . emit ( ChromeDebugSession . FinishedStartingUpEventName , { requestedContentWasDetected : true } as FinishedStartingUpEventArguments ) ;
157- } else if ( url === 'chrome-error://chromewebdata/' ) {
158- // Chrome couldn't retrieve the web-page in the requested url
159- this . events . emit ( ChromeDebugSession . FinishedStartingUpEventName , { requestedContentWasDetected : false , reasonForNotDetected : 'UnreachableURL' } as FinishedStartingUpEventArguments ) ;
160- } else if ( url . startsWith ( 'chrome-error://' ) ) {
161- // Uknown chrome error
162- this . events . emit ( ChromeDebugSession . FinishedStartingUpEventName , { requestedContentWasDetected : false , reasonForNotDetected : 'UnknownChromeError' } as FinishedStartingUpEventArguments ) ;
152+ if ( this . _userRequestedUrl ) {
153+ const url = params . frame . url ;
154+ const requestedUrlNoAnchor = this . _userRequestedUrl . split ( '#' ) [ 0 ] ; // Frame navigated url doesn't include the anchor
155+ if ( url === requestedUrlNoAnchor || decodeURI ( url ) === requestedUrlNoAnchor ) { // 'http://localhost:1234/test%20page' will use the not decoded version, 'http://localhost:1234/test page' will use the decoded version
156+ // Chrome started to navigate to the user's requested url
157+ this . events . emit ( ChromeDebugSession . FinishedStartingUpEventName , { requestedContentWasDetected : true } as FinishedStartingUpEventArguments ) ;
158+ } else if ( url === 'chrome-error://chromewebdata/' ) {
159+ // Chrome couldn't retrieve the web-page in the requested url
160+ this . events . emit ( ChromeDebugSession . FinishedStartingUpEventName , { requestedContentWasDetected : false , reasonForNotDetected : 'UnreachableURL' } as FinishedStartingUpEventArguments ) ;
161+ } else if ( url . startsWith ( 'chrome-error://' ) ) {
162+ // Uknown chrome error
163+ this . events . emit ( ChromeDebugSession . FinishedStartingUpEventName , { requestedContentWasDetected : false , reasonForNotDetected : 'UnknownChromeError' } as FinishedStartingUpEventArguments ) ;
164+ }
163165 }
164166 }
165167
@@ -198,23 +200,30 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
198200 this . chrome . Network . setCacheDisabled ( { cacheDisabled } ) ;
199201 } ) ;
200202
201- const versionInformationPromise = this . chrome . Browser . getVersion ( ) . then ( response => {
202- const properties = {
203- 'Versions.Target.CRDPVersion' : response . protocolVersion ,
204- 'Versions.Target.Revision' : response . revision ,
205- 'Versions.Target.UserAgent' : response . userAgent ,
206- 'Versions.Target.V8' : response . jsVersion
207- } ;
208-
209- const parts = ( response . product || '' ) . split ( '/' ) ;
210- if ( parts . length === 2 ) { // Currently response.product looks like "Chrome/65.0.3325.162" so we split the project and the actual version number
211- properties [ 'Versions.Target.Project' ] = parts [ 0 ] ;
212- properties [ 'Versions.Target.Version' ] = parts [ 1 ] ;
213- } else { // If for any reason that changes, we submit the entire product as-is
214- properties [ 'Versions.Target.Product' ] = response . product ;
215- }
216- return properties ;
217- } ) ;
203+ const versionInformationPromise = this . chrome . Browser . getVersion ( ) . then (
204+ response => {
205+ const properties = {
206+ 'Versions.Target.CRDPVersion' : response . protocolVersion ,
207+ 'Versions.Target.Revision' : response . revision ,
208+ 'Versions.Target.UserAgent' : response . userAgent ,
209+ 'Versions.Target.V8' : response . jsVersion
210+ } ;
211+
212+ const parts = ( response . product || '' ) . split ( '/' ) ;
213+ if ( parts . length === 2 ) { // Currently response.product looks like "Chrome/65.0.3325.162" so we split the project and the actual version number
214+ properties [ 'Versions.Target.Project' ] = parts [ 0 ] ;
215+ properties [ 'Versions.Target.Version' ] = parts [ 1 ] ;
216+ } else { // If for any reason that changes, we submit the entire product as-is
217+ properties [ 'Versions.Target.Product' ] = response . product ;
218+ }
219+ return properties ;
220+ } ,
221+ err => {
222+ logger . log ( 'Getting userAgent failed: ' + err . message ) ;
223+ const properties = { 'Versions.Target.NoUserAgentReason' : 'Error while retriving target user agent' } as telemetry . IExecutionResultTelemetryProperties ;
224+ coreUtils . fillErrorDetails ( properties , err ) ;
225+ return properties ;
226+ } ) ;
218227
219228 // Send the versions information as it's own event so we can easily backfill other events in the user session if needed
220229 versionInformationPromise . then ( versionInformation => telemetry . telemetry . reportEvent ( 'target-version' , versionInformation ) ) ;
0 commit comments