Skip to content

Commit 80f9e3b

Browse files
committed
newwin: document-start event
1 parent 537637b commit 80f9e3b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/resources/api_nw_newwin.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ var appWinEventsMap = {
6262

6363
var nwWinEventsMap = {
6464
'zoom': 'onZoom',
65-
'close': 'onClose',
66-
'document-start': 'onDocumentStart'
65+
'close': 'onClose'
6766
};
6867

6968
var nwWrapEventsMap = {
@@ -126,7 +125,7 @@ forEach(currentNWWindowInternal, function(key, value) {
126125
NWWindow.prototype.onNewWinPolicy = new Event();
127126
NWWindow.prototype.onNavigation = new Event();
128127
NWWindow.prototype.LoadingStateChanged = new Event();
129-
NWWindow.prototype.onDocumentStart = new Event();
128+
NWWindow.prototype.onDocumentStart = new Event("nw.Window.onDocumentStart");
130129
NWWindow.prototype.onDocumentEnd = new Event("nw.Window.onDocumentEnd");
131130
NWWindow.prototype.onZoom = new Event();
132131
NWWindow.prototype.onClose = new Event("nw.Window.onClose", undefined, {supportsFilters: true});
@@ -179,6 +178,15 @@ NWWindow.prototype.on = function (event, callback, record) {
179178
});
180179
chrome.tabs.onUpdated.addListener(g);
181180
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;
182190
case 'document-end':
183191
var cb0 = wrap(function(frame, top_routing_id) {
184192
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) {
705713
function onDocumentStartEnd(start, frame, top_routing_id) {
706714
console.log("--> onDocumentStartEnd: " + start + "; currentNWWindow: " + currentNWWindow);
707715
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]);
711718
}
712719
else
713720
dispatchEventNW("nw.Window.onDocumentEnd", [frame, top_routing_id]);

0 commit comments

Comments
 (0)