зеркало из https://github.com/mozilla/gecko-dev.git
Bug 989528 - Introduce AutoJSAPIWithErrorsReportedToWindow as a replacement for AutoPushJSContextForErrorReporting. r=bz
This commit is contained in:
Родитель
b0d1248d3b
Коммит
04b22e3936
|
@ -232,6 +232,11 @@ AutoJSAPI::AutoJSAPI(JSContext *aCx, bool aIsMainThread, bool aSkipNullAc)
|
|||
}
|
||||
}
|
||||
|
||||
AutoJSAPIWithErrorsReportedToWindow::AutoJSAPIWithErrorsReportedToWindow(nsIScriptContext* aScx)
|
||||
: AutoJSAPI(aScx->GetNativeContext(), /* aIsMainThread = */ true)
|
||||
{
|
||||
}
|
||||
|
||||
AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
bool aIsMainThread,
|
||||
JSContext* aCx)
|
||||
|
|
|
@ -148,6 +148,18 @@ private:
|
|||
JSContext *mCx;
|
||||
};
|
||||
|
||||
// Note - the ideal way to implement this is with an accessor on AutoJSAPI
|
||||
// that lets us select the error reporting target. But at present,
|
||||
// implementing it that way would require us to destroy and reconstruct
|
||||
// mCxPusher, which is pretty wasteful. So we do this for now, since it should
|
||||
// be pretty easy to switch things over later.
|
||||
//
|
||||
// This should only be used on the main thread.
|
||||
class AutoJSAPIWithErrorsReportedToWindow : public AutoJSAPI {
|
||||
public:
|
||||
AutoJSAPIWithErrorsReportedToWindow(nsIScriptContext* aScx);
|
||||
};
|
||||
|
||||
/*
|
||||
* A class that represents a new script entry point.
|
||||
*/
|
||||
|
|
|
@ -791,8 +791,10 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||
nsIScriptContext* context = global->GetScriptContext();
|
||||
NS_ENSURE_STATE(context);
|
||||
|
||||
// Push a context to make sure exceptions are reported in the right place.
|
||||
AutoPushJSContextForErrorReporting cx(context->GetNativeContext());
|
||||
// Activate JSAPI, and make sure that exceptions are reported on the right
|
||||
// Window.
|
||||
AutoJSAPIWithErrorsReportedToWindow jsapi(context);
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
nsCOMPtr<nsIAtom> typeAtom = aListener->mTypeAtom;
|
||||
nsIAtom* attrName = typeAtom;
|
||||
|
|
|
@ -175,16 +175,6 @@ public:
|
|||
operator JSContext*() { return mCx; }
|
||||
};
|
||||
|
||||
/**
|
||||
* AutoPushJSContextForErrorReporting has been defined for work being carried
|
||||
* out for bug 951991. It is to be used where an AutoPushJSContext is only
|
||||
* being used to make sure errors are reported using the error reporter for the
|
||||
* appropriate DOM Window and we don't want to replace it with AutoEntryScript.
|
||||
* This will make it easy to find these cases once the JSContext is no longer
|
||||
* required for error reporting.
|
||||
*/
|
||||
typedef AutoPushJSContext AutoPushJSContextForErrorReporting;
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* nsCxPusher_h */
|
||||
|
|
Загрузка…
Ссылка в новой задаче