Bug 288544 an asynchronous "oom" loop in jsconsole's implementation of nsIConsoleListener.observe with nsIConsoleService and xpconnect

r=neil sr=neil
This commit is contained in:
timeless%mozdev.org 2005-04-01 08:47:17 +00:00
Родитель c7f18c5874
Коммит 3a3c8ef69a
1 изменённых файлов: 30 добавлений и 7 удалений

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

@ -124,14 +124,37 @@
<method name="observe"> <method name="observe">
<parameter name="aConsoleMessage"/> <parameter name="aConsoleMessage"/>
<body><![CDATA[ <body><![CDATA[
if (aConsoleMessage instanceof Components.interfaces.nsIScriptError) { /* This method may be called in cases where the code
// filter chrome urls * called by this method has thrown an exception because
if (!this.showChromeErrors && /^chrome:/.test(aConsoleMessage.sourceName)) * some resource ran OUT OF MEMORY (OOM).
return; *
* This method must not throw an exception, because
* an exception thrown by it could be asynchrounously
* dispatched back to this method resulting in an
* asynchronous loop - bug 288544.
*
* If you need any try/catch handling for code in this
* function, please stick it in its own try block inside
* the main try block. Do *NOT* use the main try block.
*/
try {
if (aConsoleMessage instanceof
Components.interfaces.nsIScriptError) {
// filter chrome urls
if (!this.showChromeErrors &&
/^chrome:/.test(aConsoleMessage.sourceName))
return;
this.appendError(aConsoleMessage); this.appendError(aConsoleMessage);
} else if (aConsoleMessage.message) { } else if (aConsoleMessage.message) {
this.appendMessage(aConsoleMessage.message); this.appendMessage(aConsoleMessage.message);
}
} catch (e) {
/* This catch block is for bug 288544,
* if you want to handle some edge case, please
* make your own inner try block inside preceding
* try block. Do *NOT* stick any code in here.
*/
} }
]]></body> ]]></body>
</method> </method>