@@ -70,59 +70,69 @@ cls.ResourceManagerService = function(view, network_logger)
7070
7171 // get all the resources
7272 ctx . resourceList = [ ] ;
73- ctx . windowList .
74- forEach ( function ( w ) {
73+ ctx . windowList . forEach ( function ( w )
74+ {
7575 var wr = w . get_resources ( ) ;
7676 ctx . resourceList = ctx . resourceList . concat ( wr ) ;
7777 } ) ;
7878
79- ctx . resourceHash_id = { } ;
79+ ctx . documentResourceHash = { } ;
8080
8181 // filter the documentId that belong in the windowIdList
82- ctx . documentList = this . _documentList .
83- filter ( function ( d ) {
84- var inTheContext = ctx . windowList .
85- some ( function ( w ) {
82+ ctx . documentList = this . _documentList . filter ( function ( d )
83+ {
84+ var inWindowContext = ctx . windowList . some ( function ( w )
85+ {
8686 return w . id == d . windowID ;
8787 } ) ;
8888
89- if ( inTheContext && d . resourceID != null )
90- ctx . resourceHash_id [ d . resourceID ] = d . documentID ;
89+ if ( inWindowContext && d . resourceID != null )
90+ ctx . documentResourceHash [ d . resourceID ] = d . documentID ;
9191
92- return inTheContext ;
92+ return inWindowContext ;
9393 } , this ) ;
9494
95+ // assign top resource to the right document
9596 // add group to each resource
9697 // sameOrigin flag to each resource
97- ctx . _resourceHash = { } ;
98- ctx . resourceList .
99- forEach ( function ( r , i ) {
100- var tmp = ctx . resourceHash_id [ r . resource_id ] ;
101- if ( tmp != null )
102- {
103- console . log ( r . id + ' aka ' + r . resource_id + ' from d.' + r . document_id + ' to d.' + tmp + ' // ' + r . url ) ;
104- r . document_id = tmp ;
105- }
98+ ctx . resourceList . forEach ( function ( r , i )
99+ {
100+ var documentID = ctx . documentResourceHash [ r . id ] ;
101+ if ( documentID != null && documentID != r . document_id )
102+ r . document_id = documentID ;
106103
107- ctx . _resourceHash [ r . id ] = i ;
108104 r . group = typeGroupMapping [ r . type ] || typeGroupMapping [ '*' ] ;
109105 r . sameOrigin = cls . ResourceUtil . sameOrigin ( this . _documentURLHash [ r . document_id ] , r ) ;
110106 } , this ) ;
111107
112108 // filter the list of window. Purge the ones with no documents
113- ctx . windowList = ctx . windowList .
114- filter ( function ( v ) {
115- return ctx . documentList .
116- some ( function ( w ) { return v . id == w . windowID ; } ) ;
109+ ctx . windowList = ctx . windowList . filter ( function ( v )
110+ {
111+ return ctx . documentList . some ( function ( w )
112+ {
113+ return v . id == w . windowID ;
114+ } ) ;
117115 } ) ;
118116
119117 // request the list of documents if we have
120118 // an empty documentList
121119 // or a resource pointing to an unknown document
122120 // or a document does not have a documentID yet
123- if ( ctx . documentList . length == 0
124- || ctx . resourceList . some ( function ( v ) { return v . document_id && ! this . _documentURLHash [ v . document_id ] ; } , this )
125- || ctx . documentList . some ( function ( v ) { return v . documentID == null ; } ) )
121+ if (
122+ ctx . documentList . length == 0
123+ ||
124+ ctx . resourceList . some (
125+ function ( v )
126+ {
127+ return v . document_id && ! this . _documentURLHash [ v . document_id ] ;
128+ } , this )
129+ ||
130+ ctx . documentList . some (
131+ function ( v )
132+ {
133+ return v . documentID == null ;
134+ } )
135+ )
126136 this . _listDocuments ( ) ;
127137
128138 ctx . collapsed = this . _collapsedHash ;
@@ -138,6 +148,7 @@ cls.ResourceManagerService = function(view, network_logger)
138148
139149 this . _update_bound = this . _update . bind ( this ) ;
140150
151+
141152 this . _on_debug_context_selected_bound = function ( )
142153 {
143154 this . _documentList = [ ] ;
0 commit comments