Bug 1479058 Part 8 - Store time warp target on nsIScriptError, r=smaug.

--HG--
extra : rebase_source : 1faf5a0c0ead57f5dfb24c7450873977bf41a022
This commit is contained in:
Brian Hackett 2018-08-02 23:31:29 +00:00
parent 49770ee0cf
commit 8eb62dd065
6 changed files with 30 additions and 4 deletions

View File

@ -485,7 +485,7 @@ public:
JS::Rooted<JSObject*> stackGlobal(rootingCx);
xpc::FindExceptionStackForConsoleReport(win, mError,
&stack, &stackGlobal);
mReport->LogToConsoleWithStack(stack, stackGlobal);
mReport->LogToConsoleWithStack(stack, stackGlobal, JS::ExceptionTimeWarpTarget(mError));
}
return NS_OK;

View File

@ -98,6 +98,12 @@ interface nsIScriptError : nsIConsoleMessage
readonly attribute nsIArray notes;
/**
* If we are recording or replaying, this value may identify the point
* where the error was generated, otherwise zero.
*/
attribute unsigned long long timeWarpTarget;
void init(in AString message,
in AString sourceName,
in AString sourceLine,

View File

@ -41,6 +41,7 @@ nsScriptErrorBase::nsScriptErrorBase()
mOuterWindowID(0),
mInnerWindowID(0),
mTimeStamp(0),
mTimeWarpTarget(0),
mInitializedOnMainThread(false),
mIsFromPrivateWindow(false)
{
@ -434,6 +435,20 @@ nsScriptErrorBase::GetIsFromPrivateWindow(bool* aIsFromPrivateWindow)
return NS_OK;
}
NS_IMETHODIMP
nsScriptErrorBase::SetTimeWarpTarget(uint64_t aTarget)
{
mTimeWarpTarget = aTarget;
return NS_OK;
}
NS_IMETHODIMP
nsScriptErrorBase::GetTimeWarpTarget(uint64_t* aTarget)
{
*aTarget = mTimeWarpTarget;
return NS_OK;
}
NS_IMETHODIMP
nsScriptErrorBase::GetNotes(nsIArray** aNotes)
{

View File

@ -74,6 +74,7 @@ protected:
uint64_t mOuterWindowID;
uint64_t mInnerWindowID;
int64_t mTimeStamp;
uint64_t mTimeWarpTarget;
// mInitializedOnMainThread and mIsFromPrivateWindow are set on the main
// thread from InitializeOnMainThread().
mozilla::Atomic<bool> mInitializedOnMainThread;

View File

@ -324,7 +324,8 @@ xpc::ErrorReport::LogToConsole()
void
xpc::ErrorReport::LogToConsoleWithStack(JS::HandleObject aStack,
JS::HandleObject aStackGlobal)
JS::HandleObject aStackGlobal,
uint64_t aTimeWarpTarget /* = 0 */)
{
// Don't log failures after diverging from a recording during replay, as
// this will cause the associated debugger operation to fail.
@ -364,6 +365,7 @@ xpc::ErrorReport::LogToConsoleWithStack(JS::HandleObject aStack,
errorObject = new nsScriptError();
}
errorObject->SetErrorMessageName(mErrorMsgName);
errorObject->SetTimeWarpTarget(aTimeWarpTarget);
nsresult rv = errorObject->InitWithWindowID(mErrorMsg, mFileName, mSourceLine,
mLineNumber, mColumn, mFlags,

View File

@ -613,8 +613,10 @@ class ErrorReport : public ErrorBase {
// the sort that JS::CaptureCurrentStack produces). aStack is allowed to be
// null. If aStack is non-null, aStackGlobal must be a non-null global
// object that's same-compartment with aStack. Note that aStack might be a
// CCW.
void LogToConsoleWithStack(JS::HandleObject aStack, JS::HandleObject aStackGlobal);
// CCW. When recording/replaying, aTimeWarpTarget optionally indicates
// where the error occurred in the process' execution.
void LogToConsoleWithStack(JS::HandleObject aStack, JS::HandleObject aStackGlobal,
uint64_t aTimeWarpTarget = 0);
// Produce an error event message string from the given JSErrorReport. Note
// that this may produce an empty string if aReport doesn't have a