@@ -26,14 +26,14 @@ import { CRExecutionContext } from './crExecutionContext';
26
26
const targetSymbol = Symbol ( 'target' ) ;
27
27
28
28
export class CRTarget {
29
- private _targetInfo : Protocol . Target . TargetInfo ;
29
+ private readonly _targetInfo : Protocol . Target . TargetInfo ;
30
30
private readonly _browser : CRBrowser ;
31
31
private readonly _browserContext : CRBrowserContext ;
32
32
readonly _targetId : string ;
33
33
readonly sessionFactory : ( ) => Promise < CRSession > ;
34
- private _pagePromiseCallback : ( ( pageOrError : Page | Error ) => void ) | null = null ;
35
- private _pagePromise : Promise < Page | Error > | null = null ;
36
- _crPage : CRPage | null = null ;
34
+ private readonly _pagePromise : Promise < Page | Error > | null = null ;
35
+ readonly _crPage : CRPage | null = null ;
36
+ _initializedPage : Page | null = null ;
37
37
private _workerPromise : Promise < Worker > | null = null ;
38
38
39
39
static fromPage ( page : Page ) : CRTarget {
@@ -61,7 +61,7 @@ export class CRTarget {
61
61
const page = this . _crPage . page ( ) ;
62
62
( page as any ) [ targetSymbol ] = this ;
63
63
session . once ( CRSessionEvents . Disconnected , ( ) => page . _didDisconnect ( ) ) ;
64
- this . _pagePromise = this . _crPage . initialize ( ) . then ( ( ) => page ) . catch ( e => e ) ;
64
+ this . _pagePromise = this . _crPage . initialize ( ) . then ( ( ) => this . _initializedPage = page ) . catch ( e => e ) ;
65
65
}
66
66
}
67
67
@@ -70,12 +70,6 @@ export class CRTarget {
70
70
this . _crPage . didClose ( ) ;
71
71
}
72
72
73
- _initializedPage ( ) : Page | null {
74
- if ( this . _crPage && this . _crPage . _initialized )
75
- return this . _crPage . page ( ) ;
76
- return null ;
77
- }
78
-
79
73
async pageOrError ( ) : Promise < Page | Error > {
80
74
if ( CRTarget . isPageType ( this . type ( ) ) )
81
75
return this . _pagePromise ! ;
@@ -100,10 +94,6 @@ export class CRTarget {
100
94
return this . _workerPromise ;
101
95
}
102
96
103
- url ( ) : string {
104
- return this . _targetInfo . url ;
105
- }
106
-
107
97
type ( ) : 'page' | 'background_page' | 'service_worker' | 'shared_worker' | 'other' | 'browser' {
108
98
const type = this . _targetInfo . type ;
109
99
if ( type === 'page' || type === 'background_page' || type === 'service_worker' || type === 'shared_worker' || type === 'browser' )
@@ -121,8 +111,4 @@ export class CRTarget {
121
111
return null ;
122
112
return this . _browser . _targets . get ( openerId ) ! ;
123
113
}
124
-
125
- _targetInfoChanged ( targetInfo : Protocol . Target . TargetInfo ) {
126
- this . _targetInfo = targetInfo ;
127
- }
128
114
}
0 commit comments