@@ -62,8 +62,7 @@ var appWinEventsMap = {
62
62
63
63
var nwWinEventsMap = {
64
64
'zoom' : 'onZoom' ,
65
- 'close' : 'onClose' ,
66
- 'document-start' : 'onDocumentStart'
65
+ 'close' : 'onClose'
67
66
} ;
68
67
69
68
var nwWrapEventsMap = {
@@ -126,7 +125,7 @@ forEach(currentNWWindowInternal, function(key, value) {
126
125
NWWindow . prototype . onNewWinPolicy = new Event ( ) ;
127
126
NWWindow . prototype . onNavigation = new Event ( ) ;
128
127
NWWindow . prototype . LoadingStateChanged = new Event ( ) ;
129
- NWWindow . prototype . onDocumentStart = new Event ( ) ;
128
+ NWWindow . prototype . onDocumentStart = new Event ( "nw.Window.onDocumentStart" ) ;
130
129
NWWindow . prototype . onDocumentEnd = new Event ( "nw.Window.onDocumentEnd" ) ;
131
130
NWWindow . prototype . onZoom = new Event ( ) ;
132
131
NWWindow . prototype . onClose = new Event ( "nw.Window.onClose" , undefined , { supportsFilters : true } ) ;
@@ -179,6 +178,15 @@ NWWindow.prototype.on = function (event, callback, record) {
179
178
} ) ;
180
179
chrome . tabs . onUpdated . addListener ( g ) ;
181
180
break ;
181
+ case 'document-start' :
182
+ var cb1 = wrap ( function ( frame , top_routing_id ) {
183
+ console . log ( "document-start: cWindow: " + self . cWindow . id + "; top routing id: " + top_routing_id + "; main frame id: " + self . cWindow . tabs [ 0 ] . mainFrameId ) ;
184
+ if ( top_routing_id !== self . cWindow . tabs [ 0 ] . mainFrameId )
185
+ return ;
186
+ callback . call ( self , frame ) ;
187
+ } ) ;
188
+ this . onDocumentStart . addListener ( cb1 ) ;
189
+ break ;
182
190
case 'document-end' :
183
191
var cb0 = wrap ( function ( frame , top_routing_id ) {
184
192
console . log ( "document-end: cWindow: " + self . cWindow . id + "; top routing id: " + top_routing_id + "; main frame id: " + self . cWindow . tabs [ 0 ] . mainFrameId ) ;
@@ -705,9 +713,8 @@ function onLoadingStateChanged(status) {
705
713
function onDocumentStartEnd ( start , frame , top_routing_id ) {
706
714
console . log ( "--> onDocumentStartEnd: " + start + "; currentNWWindow: " + currentNWWindow ) ;
707
715
if ( start ) {
708
- if ( ! currentNWWindow )
709
- return ;
710
- dispatchEventIfExists ( currentNWWindow , "onDocumentStart" , [ frame ] ) ;
716
+ //could use the non-NW version?
717
+ dispatchEventNW ( "nw.Window.onDocumentStart" , [ frame , top_routing_id ] ) ;
711
718
}
712
719
else
713
720
dispatchEventNW ( "nw.Window.onDocumentEnd" , [ frame , top_routing_id ] ) ;
0 commit comments