1
- var tabInfo = { } ;
1
+ var sessions = { } ;
2
2
var ports = { } ;
3
3
4
4
initPanelMessage ( ) ;
@@ -14,8 +14,8 @@ function panelMessage(tabId, type, msg) {
14
14
}
15
15
}
16
16
17
- function sendSessionId ( tabId ) {
18
- panelMessage ( tabId , 'session-id ' , { sessionId : tabInfo [ tabId ] . sessionId } ) ;
17
+ function sendSession ( tabId ) {
18
+ panelMessage ( tabId , 'update-session ' , sessions [ tabId ] ) ;
19
19
}
20
20
21
21
function removeConsole ( tabId ) {
@@ -26,8 +26,8 @@ function initPanelMessage() {
26
26
chrome . runtime . onConnect . addListener ( onConnect ) ;
27
27
28
28
function handleMessage ( msg ) {
29
- if ( msg . type === 'session-id ' ) {
30
- sendSessionId ( msg . tabId ) ;
29
+ if ( msg . type === 'session' ) {
30
+ sendSession ( msg . tabId ) ;
31
31
}
32
32
}
33
33
@@ -52,7 +52,7 @@ function initReqRes() {
52
52
53
53
function handleMessage ( req , sender , sendResponse ) {
54
54
if ( req . type === 'request' ) {
55
- var url = tabInfo [ req . tabId ] . remoteHost + '/' + req . url ;
55
+ var url = sessions [ req . tabId ] . remoteHost + '/' + req . url ;
56
56
REPLConsole . request ( req . method , url , req . params , function ( xhr ) {
57
57
sendResponse ( extractProps ( xhr ) ) ;
58
58
} ) ;
@@ -85,8 +85,9 @@ function initHttpListener() {
85
85
var headers = getHeaders ( details ) ;
86
86
var sessionId ;
87
87
if ( sessionId = headers [ 'X-Web-Console-Session-Id' ] ) {
88
- tabInfo [ details . tabId ] = {
88
+ sessions [ details . tabId ] = {
89
89
sessionId : sessionId ,
90
+ mountPoint : headers [ 'X-Web-Console-Mount-Point' ] ,
90
91
remoteHost : details . url . match ( / ( [ ^ : ] + : \/ \/ [ ^ \/ ] + ) \/ ? / ) [ 1 ]
91
92
} ;
92
93
}
@@ -97,12 +98,12 @@ function initNavListener() {
97
98
// Fired when a document is completely loaded and initialized.
98
99
chrome . webNavigation . onCompleted . addListener ( function ( details ) {
99
100
if ( filter ( details ) ) {
100
- sendSessionId ( details . tabId ) ;
101
+ sendSession ( details . tabId ) ;
101
102
removeConsole ( details . tabId ) ;
102
103
}
103
104
} ) ;
104
105
105
106
function filter ( details ) {
106
- return details . frameId === 0 && tabInfo [ details . tabId ] ;
107
+ return details . frameId === 0 && sessions [ details . tabId ] ;
107
108
}
108
109
}
0 commit comments