Bug 1639165 - Add an isFowardedFromContentProcess flag to nsIScriptError. r=baku.
authornchevobbe <nchevobbe@mozilla.com>
Fri, 05 Jun 2020 14:53:26 +0000
changeset 598234 fd256d1ad3419d1ddec19043f91578cbe7ae6085
parent 598233 91fff3143be70425023fb59192ac9d63c3bec492
child 598235 ad832014f2d291af829bf3c0d1c646387efce805
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1639165
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1639165 - Add an isFowardedFromContentProcess flag to nsIScriptError. r=baku. This will be useful in DevTools land to discriminate those messages that we might also get directly by directly connecting to content processes. Differential Revision: https://phabricator.services.mozilla.com/D76792
dom/bindings/nsIScriptError.idl
dom/bindings/nsScriptError.cpp
dom/bindings/nsScriptError.h
dom/ipc/ContentParent.cpp
--- a/dom/bindings/nsIScriptError.idl
+++ b/dom/bindings/nsIScriptError.idl
@@ -83,16 +83,18 @@ interface nsIScriptError : nsIConsoleMes
     /* Get the inner window id this was initialized with.  Zero will be
        returned if init() was used instead of initWithWindowID(). */
     readonly attribute unsigned long long innerWindowID;
 
     readonly attribute boolean isFromPrivateWindow;
 
     readonly attribute boolean isFromChromeContext;
 
+    attribute boolean isForwardedFromContentProcess;
+
     // Error created from a Promise rejection.
     readonly attribute boolean isPromiseRejection;
 
     [noscript] void initIsPromiseRejection(in bool isPromiseRejection);
 
     // The "exception" value generated when an uncaught exception is thrown
     // by JavaScript. This can be any value, e.g.
     // - an Error object (`throw new Error("foobar"`)
--- a/dom/bindings/nsScriptError.cpp
+++ b/dom/bindings/nsScriptError.cpp
@@ -32,17 +32,18 @@ nsScriptErrorBase::nsScriptErrorBase()
       mFlags(0),
       mCategory(),
       mOuterWindowID(0),
       mInnerWindowID(0),
       mTimeStamp(0),
       mInitializedOnMainThread(false),
       mIsFromPrivateWindow(false),
       mIsFromChromeContext(false),
-      mIsPromiseRejection(false) {}
+      mIsPromiseRejection(false),
+      mIsForwardedFromContentProcess(false) {}
 
 nsScriptErrorBase::~nsScriptErrorBase() = default;
 
 void nsScriptErrorBase::AddNote(nsIScriptErrorNote* note) {
   mNotes.AppendObject(note);
 }
 
 void nsScriptErrorBase::InitializeOnMainThread() {
@@ -417,16 +418,30 @@ nsScriptErrorBase::GetIsPromiseRejection
 
 NS_IMETHODIMP
 nsScriptErrorBase::InitIsPromiseRejection(bool aIsPromiseRejection) {
   mIsPromiseRejection = aIsPromiseRejection;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsScriptErrorBase::GetIsForwardedFromContentProcess(
+    bool* aIsForwardedFromContentProcess) {
+  *aIsForwardedFromContentProcess = mIsForwardedFromContentProcess;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsScriptErrorBase::SetIsForwardedFromContentProcess(
+    bool aIsForwardedFromContentProcess) {
+  mIsForwardedFromContentProcess = aIsForwardedFromContentProcess;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsScriptErrorBase::GetNotes(nsIArray** aNotes) {
   nsresult rv = NS_OK;
   nsCOMPtr<nsIMutableArray> array = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t len = mNotes.Length();
   for (uint32_t i = 0; i < len; i++) array->AppendElement(mNotes[i]);
   array.forget(aNotes);
--- a/dom/bindings/nsScriptError.h
+++ b/dom/bindings/nsScriptError.h
@@ -84,16 +84,17 @@ class nsScriptErrorBase : public nsIScri
   uint64_t mInnerWindowID;
   int64_t mTimeStamp;
   // mInitializedOnMainThread, mIsFromPrivateWindow and mIsFromChromeContext are
   // set on the main thread from InitializeOnMainThread().
   mozilla::Atomic<bool> mInitializedOnMainThread;
   bool mIsFromPrivateWindow;
   bool mIsFromChromeContext;
   bool mIsPromiseRejection;
+  bool mIsForwardedFromContentProcess;
 };
 
 class nsScriptError final : public nsScriptErrorBase {
  public:
   nsScriptError() = default;
   NS_DECL_THREADSAFE_ISUPPORTS
 
  private:
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4297,16 +4297,18 @@ mozilla::ipc::IPCResult ContentParent::R
     msg = new nsScriptError();
   }
 
   nsresult rv = msg->Init(aMessage, aSourceName, aSourceLine, aLineNumber,
                           aColNumber, aFlags, aCategory.get(),
                           aFromPrivateWindow, aFromChromeContext);
   if (NS_FAILED(rv)) return IPC_OK();
 
+  msg->SetIsForwardedFromContentProcess(true);
+
   consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentParent::RecvPrivateDocShellsExist(
     const bool& aExist) {
   if (!sPrivateContent) {
     sPrivateContent = new nsTArray<ContentParent*>();