зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1070131 - Reduce the cases where we dispatch nsScriptErrorEvent. r=bz
This commit is contained in:
Родитель
15c04c8454
Коммит
c4922ac2f8
|
@ -354,11 +354,9 @@ public:
|
|||
ScriptErrorEvent(JSRuntime* aRuntime,
|
||||
xpc::ErrorReport* aReport,
|
||||
nsIPrincipal* aScriptOriginPrincipal,
|
||||
JS::Handle<JS::Value> aError,
|
||||
bool aDispatchEvent)
|
||||
JS::Handle<JS::Value> aError)
|
||||
: mReport(aReport)
|
||||
, mOriginPrincipal(aScriptOriginPrincipal)
|
||||
, mDispatchEvent(aDispatchEvent)
|
||||
, mError(aRuntime, aError)
|
||||
{}
|
||||
|
||||
|
@ -369,10 +367,7 @@ public:
|
|||
MOZ_ASSERT(win);
|
||||
// First, notify the DOM that we have a script error, but only if
|
||||
// our window is still the current inner.
|
||||
if (mDispatchEvent && win->IsCurrentInnerWindow() &&
|
||||
win->GetDocShell() && !JSREPORT_IS_WARNING(mReport->mFlags) &&
|
||||
!sHandlingScriptError)
|
||||
{
|
||||
if (win->IsCurrentInnerWindow() && win->GetDocShell() && !sHandlingScriptError) {
|
||||
AutoRestore<bool> recursionGuard(sHandlingScriptError);
|
||||
sHandlingScriptError = true;
|
||||
|
||||
|
@ -429,7 +424,6 @@ public:
|
|||
private:
|
||||
nsRefPtr<xpc::ErrorReport> mReport;
|
||||
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
|
||||
bool mDispatchEvent;
|
||||
JS::PersistentRootedValue mError;
|
||||
|
||||
static bool sHandlingScriptError;
|
||||
|
@ -491,9 +485,12 @@ SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
|||
nsRefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
xpcReport->Init(report, message, globalObject);
|
||||
|
||||
// If there's no window to fire an event at, report it to the console
|
||||
// directly.
|
||||
if (!xpcReport->mWindow) {
|
||||
// If we can't dispatch an event to a window, report it to the console
|
||||
// directly. This includes the case where the error was an OOM, because
|
||||
// triggering a scripted event handler is likely to generate further OOMs.
|
||||
if (!xpcReport->mWindow || JSREPORT_IS_WARNING(xpcReport->mFlags) ||
|
||||
report->errorNumber == JSMSG_OUT_OF_MEMORY)
|
||||
{
|
||||
xpcReport->LogToConsole();
|
||||
return;
|
||||
}
|
||||
|
@ -504,15 +501,7 @@ SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
|||
new ScriptErrorEvent(JS_GetRuntime(cx),
|
||||
xpcReport,
|
||||
nsJSPrincipals::get(report->originPrincipals),
|
||||
exception,
|
||||
/* We do not try to report Out Of Memory via a dom
|
||||
* event because the dom event handler would
|
||||
* encounter an OOM exception trying to process the
|
||||
* event, and then we'd need to generate a new OOM
|
||||
* event for that new OOM instance -- this isn't
|
||||
* pretty.
|
||||
*/
|
||||
report->errorNumber != JSMSG_OUT_OF_MEMORY));
|
||||
exception));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче