Bug 793082 - Allow sendChromeEvent to queue the events until window.onload fires, r=fabrice

This commit is contained in:
Timothy Guan-tin Chien 2012-09-29 10:57:18 -07:00
Родитель f558586922
Коммит 9779c20ced
1 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -187,6 +187,7 @@ var shell = {
});
this.contentBrowser.src = homeURL;
this.isHomeLoaded = false;
ppmm.addMessageListener("content-handler", this);
},
@ -312,6 +313,17 @@ var shell = {
DOMApplicationRegistry.allAppsLaunchable = true;
this.sendEvent(window, 'ContentStart');
content.addEventListener('load', function shell_homeLoaded() {
content.removeEventListener('load', shell_homeLoaded);
shell.isHomeLoaded = true;
if ('pendingChromeEvents' in shell) {
shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell));
}
delete shell.pendingChromeEvents;
});
break;
case 'MozApplicationManifest':
try {
@ -357,6 +369,15 @@ var shell = {
},
sendChromeEvent: function shell_sendChromeEvent(details) {
if (!this.isHomeLoaded) {
if (!('pendingChromeEvents' in this)) {
this.pendingChromeEvents = [];
}
this.pendingChromeEvents.push(details);
return;
}
this.sendEvent(getContentWindow(), "mozChromeEvent",
ObjectWrapper.wrap(details, getContentWindow()));
},