Bug 1443079 - nsScriptError.isFromPrivateWindow must match the correct value also in e10s mode, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 13 Mar 2018 06:40:38 +0100
changeset 407785 47a89fa7cfd2f1628fa08dc69687eddfaf7f94bb
parent 407784 bae5dd6b9a2aff890d6f41ce3113546040b482b7
child 407786 905e2b3c7f40b5dcf68d16b2ddc72bbb14483e02
push id100779
push useramarchesini@mozilla.com
push dateTue, 13 Mar 2018 05:45:07 +0000
treeherdermozilla-inbound@47a89fa7cfd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1443079
milestone61.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 1443079 - nsScriptError.isFromPrivateWindow must match the correct value also in e10s mode, r=smaug
chrome/nsChromeRegistry.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsFrameMessageManager.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/bindings/nsIScriptError.idl
dom/bindings/nsScriptError.cpp
dom/bindings/nsScriptError.h
dom/bindings/nsScriptErrorWithStack.cpp
dom/html/HTMLFormElement.cpp
dom/indexedDB/ReportInternalError.cpp
dom/indexedDB/ScriptErrorHelper.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/quota/ActorsParent.cpp
dom/security/FramingChecker.cpp
dom/security/nsCSPContext.cpp
dom/security/nsCSPUtils.cpp
dom/security/nsCSPUtils.h
dom/security/nsMixedContentBlocker.cpp
dom/websocket/WebSocket.cpp
js/ipc/JavaScriptParent.cpp
js/xpconnect/src/XPCWrappedNativeInfo.cpp
netwerk/base/nsNetUtil.cpp
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/nsCORSListenerProxy.cpp
netwerk/protocol/http/nsCORSListenerProxy.h
security/manager/ssl/SSLServerCertVerification.cpp
security/manager/ssl/nsNSSCallbacks.cpp
security/manager/ssl/nsNSSIOLayer.cpp
toolkit/components/telemetry/TelemetryCommon.cpp
xpcom/components/ManifestParser.cpp
xpcom/ds/nsObserverService.cpp
--- a/chrome/nsChromeRegistry.cpp
+++ b/chrome/nsChromeRegistry.cpp
@@ -86,17 +86,18 @@ nsChromeRegistry::LogMessageWithContext(
 
   nsCString spec;
   if (aURL)
     aURL->GetSpec(spec);
 
   rv = error->Init(NS_ConvertUTF8toUTF16(formatted.get()),
                    NS_ConvertUTF8toUTF16(spec),
                    EmptyString(),
-                   aLineNumber, 0, flags, "chrome registration");
+                   aLineNumber, 0, flags, "chrome registration",
+                   false /* from private window */);
 
   if (NS_FAILED(rv))
     return;
 
   console->LogMessage(error);
 }
 
 nsChromeRegistry::~nsChromeRegistry()
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4141,27 +4141,29 @@ nsresult nsContentUtils::FormatLocalized
   }
   return FormatLocalizedString(aFile, aKey, params.get(), paramsLength,
                                aResult);
 }
 
 
 /* static */ void
 nsContentUtils::LogSimpleConsoleError(const nsAString& aErrorText,
-                                      const char * classification)
+                                      const char * classification,
+                                      bool aFromPrivateWindow)
 {
   nsCOMPtr<nsIScriptError> scriptError =
     do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
   if (scriptError) {
     nsCOMPtr<nsIConsoleService> console =
       do_GetService(NS_CONSOLESERVICE_CONTRACTID);
     if (console && NS_SUCCEEDED(scriptError->Init(aErrorText, EmptyString(),
                                                   EmptyString(), 0, 0,
                                                   nsIScriptError::errorFlag,
-                                                  classification))) {
+                                                  classification,
+                                                  aFromPrivateWindow))) {
       console->LogMessage(scriptError);
     }
   }
 }
 
 /* static */ nsresult
 nsContentUtils::ReportToConsole(uint32_t aErrorFlags,
                                 const nsACString& aCategory,
@@ -5829,17 +5831,18 @@ nsContentUtils::WarnScriptWasIgnored(nsI
     nsCOMPtr<nsIURI> uri = aDocument->GetDocumentURI();
     if (uri) {
       msg.Append(NS_ConvertUTF8toUTF16(uri->GetSpecOrDefault()));
       msg.AppendLiteral(" : ");
     }
   }
   msg.AppendLiteral("Unable to run script because scripts are blocked internally.");
 
-  LogSimpleConsoleError(msg, "DOM");
+  LogSimpleConsoleError(msg, "DOM",
+                        !!aDocument->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId);
 }
 
 /* static */
 void
 nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable)
 {
   nsCOMPtr<nsIRunnable> runnable = aRunnable;
   if (!runnable) {
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1003,17 +1003,18 @@ public:
   }
 
   /**
    * Report simple error message to the browser console
    *   @param aErrorText the error message
    *   @param classification Name of the module reporting error
    */
   static void LogSimpleConsoleError(const nsAString& aErrorText,
-                                    const char * classification);
+                                    const char * classification,
+                                    bool aFromPrivateWindow);
 
   /**
    * Report a non-localized error message to the error console.
    *   @param aErrorText the error message
    *   @param aErrorFlags See nsIScriptError.
    *   @param aCategory Name of module reporting error.
    *   @param aDocument Reference to the document which triggered the message.
    *   @param [aURI=nullptr] (Optional) URI of resource containing error.
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -510,17 +510,18 @@ GetParamsForMessage(JSContext* aCx,
   nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
   if (console) {
     nsAutoString filename;
     uint32_t lineno = 0, column = 0;
     nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column);
     nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
     error->Init(NS_LITERAL_STRING("Sending message that cannot be cloned. Are you trying to send an XPCOM object?"),
                 filename, EmptyString(), lineno, column,
-                nsIScriptError::warningFlag, "chrome javascript");
+                nsIScriptError::warningFlag, "chrome javascript",
+                false /* from private window */);
     console->LogMessage(error);
   }
 
   // Not clonable, try JSON
   //XXX This is ugly but currently structured cloning doesn't handle
   //    properly cases when interface is implemented in JS and used
   //    as a dictionary.
   nsAutoString json;
@@ -1106,17 +1107,18 @@ nsFrameMessageManager::ReceiveMessage(ns
           if (NS_WARN_IF(rv.Failed())) {
             aRetVal->RemoveElementAt(aRetVal->Length() - 1);
             nsString msg = aMessage + NS_LITERAL_STRING(": message reply cannot be cloned. Are you trying to send an XPCOM object?");
 
             nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
             if (console) {
               nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
               error->Init(msg, EmptyString(), EmptyString(),
-                          0, 0, nsIScriptError::warningFlag, "chrome javascript");
+                          0, 0, nsIScriptError::warningFlag, "chrome javascript",
+                          false /* from private window */);
               console->LogMessage(error);
             }
 
             JS_ClearPendingException(cx);
             continue;
           }
         }
       }
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -5821,17 +5821,18 @@ nsGlobalWindowOuter::PostMessageMozOuter
         }
 
         nsContentUtils::LogSimpleConsoleError(
           NS_ConvertUTF8toUTF16(nsPrintfCString(
             R"(Attempting to post a message to window with url "%s" and )"
             R"(origin "%s" from a system principal scope with mismatched )"
             R"(origin "%s".)",
             targetURL.get(), targetOrigin.get(), sourceOrigin.get())),
-          "DOM");
+          "DOM",
+          !!principal->PrivateBrowsingId());
 
         attrs = principal->OriginAttributesRef();
       }
     }
 
     // Create a nsIPrincipal inheriting the app/browser attributes from the
     // caller.
     providedPrincipal = BasePrincipal::CreateCodebasePrincipal(originURI, attrs);
--- a/dom/bindings/nsIScriptError.idl
+++ b/dom/bindings/nsIScriptError.idl
@@ -90,17 +90,18 @@ interface nsIScriptError : nsIConsoleMes
     readonly attribute nsIArray notes;
 
     void init(in AString message,
               in AString sourceName,
               in AString sourceLine,
               in uint32_t lineNumber,
               in uint32_t columnNumber,
               in uint32_t flags,
-              in string category);
+              in string category,
+              [optional] in bool fromPrivateWindow);
 
     /* This should be called instead of nsIScriptError.init to
      * initialize with a window id.  The window id should be for the
      * inner window associated with this error.
      *
      * This function will check whether sourceName is a uri and sanitize it if
      * needed. If you know the source name is sanitized already, use
      * initWithSanitizedSource.
--- a/dom/bindings/nsScriptError.cpp
+++ b/dom/bindings/nsScriptError.cpp
@@ -176,32 +176,16 @@ nsScriptErrorBase::GetErrorMessageName(n
 }
 
 NS_IMETHODIMP
 nsScriptErrorBase::SetErrorMessageName(const nsAString& aErrorMessageName) {
     mMessageName = aErrorMessageName;
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsScriptErrorBase::Init(const nsAString& message,
-                        const nsAString& sourceName,
-                        const nsAString& sourceLine,
-                        uint32_t lineNumber,
-                        uint32_t columnNumber,
-                        uint32_t flags,
-                        const char* category)
-{
-    return InitWithWindowID(message, sourceName, sourceLine, lineNumber,
-                            columnNumber, flags,
-                            category ? nsDependentCString(category)
-                                     : EmptyCString(),
-                            0);
-}
-
 static void
 AssignSourceNameHelper(nsString& aSourceNameDest, const nsAString& aSourceNameSrc)
 {
     if (aSourceNameSrc.IsEmpty())
         return;
 
     aSourceNameDest.Assign(aSourceNameSrc);
 
@@ -222,16 +206,36 @@ AssignSourceNameHelper(nsIURI* aSourceUR
         return;
 
     if (NS_FAILED(NS_GetSanitizedURIStringFromURI(aSourceURI,
                                                   aSourceNameDest))) {
         aSourceNameDest.AssignLiteral("[nsIURI::GetSpec failed]");
     }
 }
 
+NS_IMETHODIMP
+nsScriptErrorBase::Init(const nsAString& message,
+                        const nsAString& sourceName,
+                        const nsAString& sourceLine,
+                        uint32_t lineNumber,
+                        uint32_t columnNumber,
+                        uint32_t flags,
+                        const char* category,
+                        bool fromPrivateWindow)
+{
+    InitializationHelper(message, sourceLine, lineNumber, columnNumber, flags,
+                         category ? nsDependentCString(category)
+                                  : EmptyCString(),
+                         0 /* inner Window ID */);
+    AssignSourceNameHelper(mSourceName, sourceName);
+
+    mIsFromPrivateWindow = fromPrivateWindow;
+    return NS_OK;
+}
+
 void
 nsScriptErrorBase::InitializationHelper(const nsAString& message,
                                         const nsAString& sourceLine,
                                         uint32_t lineNumber,
                                         uint32_t columnNumber,
                                         uint32_t flags,
                                         const nsACString& category,
                                         uint64_t aInnerWindowID)
--- a/dom/bindings/nsScriptError.h
+++ b/dom/bindings/nsScriptError.h
@@ -91,24 +91,16 @@ private:
 
 class nsScriptErrorWithStack : public nsScriptErrorBase {
 public:
   explicit nsScriptErrorWithStack(JS::HandleObject);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsScriptErrorWithStack)
 
-  NS_IMETHOD Init(const nsAString& message,
-                  const nsAString& sourceName,
-                  const nsAString& sourceLine,
-                  uint32_t lineNumber,
-                  uint32_t columnNumber,
-                  uint32_t flags,
-                  const char* category) override;
-
   NS_IMETHOD GetStack(JS::MutableHandleValue) override;
   NS_IMETHOD ToString(nsACString& aResult) override;
 
 private:
   virtual ~nsScriptErrorWithStack();
   // Complete stackframe where the error happened.
   // Must be SavedFrame object.
   JS::Heap<JSObject*>  mStack;
--- a/dom/bindings/nsScriptErrorWithStack.cpp
+++ b/dom/bindings/nsScriptErrorWithStack.cpp
@@ -69,28 +69,16 @@ nsScriptErrorWithStack::nsScriptErrorWit
     mozilla::HoldJSObjects(this);
 }
 
 nsScriptErrorWithStack::~nsScriptErrorWithStack() {
     mozilla::DropJSObjects(this);
 }
 
 NS_IMETHODIMP
-nsScriptErrorWithStack::Init(const nsAString& message,
-                             const nsAString& sourceName,
-                             const nsAString& sourceLine,
-                             uint32_t lineNumber,
-                             uint32_t columnNumber,
-                             uint32_t flags,
-                             const char* category)
-{
-  MOZ_CRASH("nsScriptErrorWithStack requires to be initialized with a document, by using InitWithWindowID");
-}
-
-NS_IMETHODIMP
 nsScriptErrorWithStack::GetStack(JS::MutableHandleValue aStack) {
     aStack.setObjectOrNull(mStack);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScriptErrorWithStack::ToString(nsACString& /*UTF8*/ aResult)
 {
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -1745,17 +1745,18 @@ HTMLFormElement::GetActionURL(nsIURI** a
     const char16_t* params[] = { reportSpec.get(), reportScheme.get() };
     CSP_LogLocalizedStr("upgradeInsecureRequest",
                         params, ArrayLength(params),
                         EmptyString(), // aSourceFile
                         EmptyString(), // aScriptSample
                         0, // aLineNumber
                         0, // aColumnNumber
                         nsIScriptError::warningFlag, "CSP",
-                        document->InnerWindowID());
+                        document->InnerWindowID(),
+                        !!document->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId);
   }
 
   //
   // Assign to the output
   //
   actionURL.forget(aActionURL);
 
   return rv;
--- a/dom/indexedDB/ReportInternalError.cpp
+++ b/dom/indexedDB/ReportInternalError.cpp
@@ -23,14 +23,14 @@ ReportInternalError(const char* aFile, u
     if (*p == '/' && *(p + 1)) {
       aFile = p + 1;
     }
   }
 
   nsContentUtils::LogSimpleConsoleError(
     NS_ConvertUTF8toUTF16(nsPrintfCString(
                           "IndexedDB %s: %s:%" PRIu32, aStr, aFile, aLine)),
-    "indexedDB");
+    "indexedDB", false /* no IDB in private window */);
 }
 
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
--- a/dom/indexedDB/ScriptErrorHelper.cpp
+++ b/dom/indexedDB/ScriptErrorHelper.cpp
@@ -138,17 +138,18 @@ public:
     } else {
       MOZ_ALWAYS_SUCCEEDS(
         scriptError->Init(aMessage,
                           aFilename,
                           /* aSourceLine */ EmptyString(),
                           aLineNumber,
                           aColumnNumber,
                           aSeverityFlag,
-                          category.get()));
+                          category.get(),
+                          /* IDB doesn't run on Private browsing mode */ false));
     }
 
     MOZ_ALWAYS_SUCCEEDS(consoleService->LogMessage(scriptError));
   }
 
   NS_IMETHOD
   Run() override
   {
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -428,16 +428,17 @@ ConsoleListener::Observe(nsIConsoleMessa
     return NS_OK;
   }
 
   nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
   if (scriptError) {
     nsAutoString msg, sourceName, sourceLine;
     nsCString category;
     uint32_t lineNum, colNum, flags;
+    bool fromPrivateWindow;
 
     nsresult rv = scriptError->GetErrorMessage(msg);
     NS_ENSURE_SUCCESS(rv, rv);
     TruncateString(msg);
     rv = scriptError->GetSourceName(sourceName);
     NS_ENSURE_SUCCESS(rv, rv);
     TruncateString(sourceName);
     rv = scriptError->GetSourceLine(sourceLine);
@@ -447,16 +448,18 @@ ConsoleListener::Observe(nsIConsoleMessa
     rv = scriptError->GetCategory(getter_Copies(category));
     NS_ENSURE_SUCCESS(rv, rv);
     rv = scriptError->GetLineNumber(&lineNum);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = scriptError->GetColumnNumber(&colNum);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = scriptError->GetFlags(&flags);
     NS_ENSURE_SUCCESS(rv, rv);
+    rv = scriptError->GetIsFromPrivateWindow(&fromPrivateWindow);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     {
       AutoJSAPI jsapi;
       jsapi.Init();
       JSContext* cx = jsapi.cx();
 
       JS::RootedValue stack(cx);
       rv = scriptError->GetStack(&stack);
@@ -474,24 +477,25 @@ ConsoleListener::Observe(nsIConsoleMessa
 
         ClonedMessageData cloned;
         if (!data.BuildClonedMessageDataForChild(mChild, cloned)) {
           return NS_ERROR_FAILURE;
         }
 
         mChild->SendScriptErrorWithStack(msg, sourceName, sourceLine,
                                          lineNum, colNum, flags, category,
-                                         cloned);
+                                         fromPrivateWindow, cloned);
         return NS_OK;
       }
     }
 
 
     mChild->SendScriptError(msg, sourceName, sourceLine,
-                            lineNum, colNum, flags, category);
+                            lineNum, colNum, flags, category,
+                            fromPrivateWindow);
     return NS_OK;
   }
 
   nsString msg;
   nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
   NS_ENSURE_SUCCESS(rv, rv);
   mChild->SendConsoleMessage(msg);
   return NS_OK;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3887,46 +3887,49 @@ ContentParent::RecvConsoleMessage(const 
 
 mozilla::ipc::IPCResult
 ContentParent::RecvScriptError(const nsString& aMessage,
                                const nsString& aSourceName,
                                const nsString& aSourceLine,
                                const uint32_t& aLineNumber,
                                const uint32_t& aColNumber,
                                const uint32_t& aFlags,
-                               const nsCString& aCategory)
+                               const nsCString& aCategory,
+                               const bool& aFromPrivateWindow)
 {
   return RecvScriptErrorInternal(aMessage, aSourceName, aSourceLine,
                                  aLineNumber, aColNumber, aFlags,
-                                 aCategory);
+                                 aCategory, aFromPrivateWindow);
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvScriptErrorWithStack(const nsString& aMessage,
                                         const nsString& aSourceName,
                                         const nsString& aSourceLine,
                                         const uint32_t& aLineNumber,
                                         const uint32_t& aColNumber,
                                         const uint32_t& aFlags,
                                         const nsCString& aCategory,
+                                        const bool& aFromPrivateWindow,
                                         const ClonedMessageData& aFrame)
 {
   return RecvScriptErrorInternal(aMessage, aSourceName, aSourceLine,
                                  aLineNumber, aColNumber, aFlags,
-                                 aCategory, &aFrame);
+                                 aCategory, aFromPrivateWindow, &aFrame);
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvScriptErrorInternal(const nsString& aMessage,
                                        const nsString& aSourceName,
                                        const nsString& aSourceLine,
                                        const uint32_t& aLineNumber,
                                        const uint32_t& aColNumber,
                                        const uint32_t& aFlags,
                                        const nsCString& aCategory,
+                                       const bool& aFromPrivateWindow,
                                        const ClonedMessageData* aStack)
 {
   RefPtr<nsConsoleService> consoleService = GetConsoleService();
   if (!consoleService) {
     return IPC_OK();
   }
 
   nsCOMPtr<nsIScriptError> msg;
@@ -3950,19 +3953,19 @@ ContentParent::RecvScriptErrorInternal(c
     }
 
     JS::RootedObject stackObj(cx, &stack.toObject());
     msg = new nsScriptErrorWithStack(stackObj);
   } else {
     msg = new nsScriptError();
   }
 
-  nsresult rv = msg->InitWithWindowID(aMessage, aSourceName, aSourceLine,
-                                      aLineNumber, aColNumber, aFlags,
-                                      aCategory, 0);
+  nsresult rv = msg->Init(aMessage, aSourceName, aSourceLine,
+                          aLineNumber, aColNumber, aFlags,
+                          aCategory.get(), aFromPrivateWindow);
   if (NS_FAILED(rv))
     return IPC_OK();
 
   consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -1051,35 +1051,38 @@ private:
   virtual mozilla::ipc::IPCResult RecvConsoleMessage(const nsString& aMessage) override;
 
   virtual mozilla::ipc::IPCResult RecvScriptError(const nsString& aMessage,
                                                   const nsString& aSourceName,
                                                   const nsString& aSourceLine,
                                                   const uint32_t& aLineNumber,
                                                   const uint32_t& aColNumber,
                                                   const uint32_t& aFlags,
-                                                  const nsCString& aCategory) override;
+                                                  const nsCString& aCategory,
+                                                  const bool& aIsFromPrivateWindow) override;
 
   virtual mozilla::ipc::IPCResult RecvScriptErrorWithStack(const nsString& aMessage,
                                                            const nsString& aSourceName,
                                                            const nsString& aSourceLine,
                                                            const uint32_t& aLineNumber,
                                                            const uint32_t& aColNumber,
                                                            const uint32_t& aFlags,
                                                            const nsCString& aCategory,
+                                                           const bool& aIsFromPrivateWindow,
                                                            const ClonedMessageData& aStack) override;
 
 private:
   mozilla::ipc::IPCResult RecvScriptErrorInternal(const nsString& aMessage,
                                                   const nsString& aSourceName,
                                                   const nsString& aSourceLine,
                                                   const uint32_t& aLineNumber,
                                                   const uint32_t& aColNumber,
                                                   const uint32_t& aFlags,
                                                   const nsCString& aCategory,
+                                                  const bool& aIsFromPrivateWindow,
                                                   const ClonedMessageData* aStack = nullptr);
 
 public:
   virtual mozilla::ipc::IPCResult RecvPrivateDocShellsExist(const bool& aExist) override;
 
   virtual mozilla::ipc::IPCResult RecvFirstIdle() override;
 
   virtual mozilla::ipc::IPCResult RecvDeviceReset() override;
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -823,20 +823,21 @@ parent:
 
     async AddGeolocationListener(Principal principal, bool highAccuracy);
     async RemoveGeolocationListener();
     async SetGeolocationHigherAccuracy(bool enable);
 
     async ConsoleMessage(nsString message);
     async ScriptError(nsString message, nsString sourceName, nsString sourceLine,
                       uint32_t lineNumber, uint32_t colNumber, uint32_t flags,
-                      nsCString category);
+                      nsCString category, bool privateWindow);
     async ScriptErrorWithStack(nsString message, nsString sourceName, nsString sourceLine,
                                uint32_t lineNumber, uint32_t colNumber, uint32_t flags,
-                               nsCString category, ClonedMessageData stack);
+                               nsCString category, bool privateWindow,
+                               ClonedMessageData stack);
 
     // Places the items within dataTransfer on the clipboard.
     async SetClipboard(IPCDataTransfer aDataTransfer,
                        bool aIsPrivateData,
                        Principal aRequestingPrincipal,
                        int32_t aWhichClipboard);
 
     // Given a list of supported types, returns the clipboard data for the
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -1548,17 +1548,18 @@ ReportInternalError(const char* aFile, u
     if (*p == '/' && *(p + 1)) {
       aFile = p + 1;
     }
   }
 
   nsContentUtils::LogSimpleConsoleError(
     NS_ConvertUTF8toUTF16(nsPrintfCString(
                           "Quota %s: %s:%" PRIu32, aStr, aFile, aLine)),
-    "quota");
+    "quota",
+    false /* Quota Manager is not active in private browsing mode */);
 }
 
 namespace {
 
 StaticRefPtr<QuotaManager> gInstance;
 bool gCreateFailed = false;
 StaticRefPtr<QuotaManager::CreateRunnable> gCreateRunnable;
 mozilla::Atomic<bool> gShutdown(false);
--- a/dom/security/FramingChecker.cpp
+++ b/dom/security/FramingChecker.cpp
@@ -181,26 +181,28 @@ ShouldIgnoreFrameOptions(nsIChannel* aCh
     // if CSP does not contain frame-ancestors, then there
     // is nothing to do here.
     return false;
   }
 
   // log warning to console that xfo is ignored because of CSP
   nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
   uint64_t innerWindowID = loadInfo ? loadInfo->GetInnerWindowID() : 0;
+  bool privateWindow = loadInfo ?  !!loadInfo->GetOriginAttributes().mPrivateBrowsingId : false;
   const char16_t* params[] = { u"x-frame-options",
                                u"frame-ancestors" };
   CSP_LogLocalizedStr("IgnoringSrcBecauseOfDirective",
                       params, ArrayLength(params),
                       EmptyString(), // no sourcefile
                       EmptyString(), // no scriptsample
                       0,             // no linenumber
                       0,             // no columnnumber
                       nsIScriptError::warningFlag,
-                      "CSP", innerWindowID);
+                      "CSP", innerWindowID,
+                      privateWindow);
 
   return true;
 }
 
 // Check if X-Frame-Options permits this document to be loaded as a subdocument.
 // This will iterate through and check any number of X-Frame-Options policies
 // in the request (comma-separated in a header, multiple headers, etc).
 /* static */ bool
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -789,28 +789,33 @@ struct ConsoleMsgQueueElem {
   uint32_t      mLineNumber;
   uint32_t      mColumnNumber;
   uint32_t      mSeverityFlag;
 };
 
 void
 nsCSPContext::flushConsoleMessages()
 {
+  bool privateWindow = false;
+
   // should flush messages even if doc is not available
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mLoadingContext);
   if (doc) {
     mInnerWindowID = doc->InnerWindowID();
+    privateWindow = !!doc->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId;
   }
+
   mQueueUpMessages = false;
 
   for (uint32_t i = 0; i < mConsoleMsgQueue.Length(); i++) {
     ConsoleMsgQueueElem &elem = mConsoleMsgQueue[i];
     CSP_LogMessage(elem.mMsg, elem.mSourceName, elem.mSourceLine,
                    elem.mLineNumber, elem.mColumnNumber,
-                   elem.mSeverityFlag, "CSP", mInnerWindowID);
+                   elem.mSeverityFlag, "CSP", mInnerWindowID,
+                   privateWindow);
   }
   mConsoleMsgQueue.Clear();
 }
 
 void
 nsCSPContext::logToConsole(const char* aName,
                            const char16_t** aParams,
                            uint32_t aParamsLength,
@@ -828,19 +833,26 @@ nsCSPContext::logToConsole(const char* a
     elem.mMsg = msg;
     elem.mSourceName = PromiseFlatString(aSourceName);
     elem.mSourceLine = PromiseFlatString(aSourceLine);
     elem.mLineNumber = aLineNumber;
     elem.mColumnNumber = aColumnNumber;
     elem.mSeverityFlag = aSeverityFlag;
     return;
   }
+
+  bool privateWindow = false;
+  nsCOMPtr<nsIDocument> doc = do_QueryReferent(mLoadingContext);
+  if (doc) {
+    privateWindow = !!doc->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId;
+  }
+
   CSP_LogLocalizedStr(aName, aParams, aParamsLength, aSourceName,
                       aSourceLine, aLineNumber, aColumnNumber,
-                      aSeverityFlag, "CSP", mInnerWindowID);
+                      aSeverityFlag, "CSP", mInnerWindowID, privateWindow);
 }
 
 /**
  * Strip URI for reporting according to:
  * http://www.w3.org/TR/CSP/#violation-reports
  *
  * @param aURI
  *        The uri to be stripped for reporting
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -125,17 +125,18 @@ CSP_LogStrMessage(const nsAString& aMsg)
 void
 CSP_LogMessage(const nsAString& aMessage,
                const nsAString& aSourceName,
                const nsAString& aSourceLine,
                uint32_t aLineNumber,
                uint32_t aColumnNumber,
                uint32_t aFlags,
                const char *aCategory,
-               uint64_t aInnerWindowID)
+               uint64_t aInnerWindowID,
+               bool aFromPrivateWindow)
 {
   nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
 
   nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
 
   if (!console || !error) {
     return;
   }
@@ -165,17 +166,17 @@ CSP_LogMessage(const nsAString& aMessage
                                  aSourceLine, aLineNumber,
                                  aColumnNumber, aFlags,
                                  catStr, aInnerWindowID);
   }
   else {
     rv = error->Init(cspMsg, aSourceName,
                      aSourceLine, aLineNumber,
                      aColumnNumber, aFlags,
-                     aCategory);
+                     aCategory, aFromPrivateWindow);
   }
   if (NS_FAILED(rv)) {
     return;
   }
   console->LogMessage(error);
 }
 
 /**
@@ -186,23 +187,24 @@ CSP_LogLocalizedStr(const char* aName,
                     const char16_t** aParams,
                     uint32_t aLength,
                     const nsAString& aSourceName,
                     const nsAString& aSourceLine,
                     uint32_t aLineNumber,
                     uint32_t aColumnNumber,
                     uint32_t aFlags,
                     const char* aCategory,
-                    uint64_t aInnerWindowID)
+                    uint64_t aInnerWindowID,
+                    bool aFromPrivateWindow)
 {
   nsAutoString logMsg;
   CSP_GetLocalizedStr(aName, aParams, aLength, logMsg);
   CSP_LogMessage(logMsg, aSourceName, aSourceLine,
                  aLineNumber, aColumnNumber, aFlags,
-                 aCategory, aInnerWindowID);
+                 aCategory, aInnerWindowID, aFromPrivateWindow);
 }
 
 /* ===== Helpers ============================ */
 CSPDirective
 CSP_ContentTypeToDirective(nsContentPolicyType aType)
 {
   switch (aType) {
     case nsIContentPolicy::TYPE_IMAGE:
--- a/dom/security/nsCSPUtils.h
+++ b/dom/security/nsCSPUtils.h
@@ -29,33 +29,35 @@ void CSP_LogLocalizedStr(const char* aNa
                          const char16_t** aParams,
                          uint32_t aLength,
                          const nsAString& aSourceName,
                          const nsAString& aSourceLine,
                          uint32_t aLineNumber,
                          uint32_t aColumnNumber,
                          uint32_t aFlags,
                          const char* aCategory,
-                         uint64_t aInnerWindowID);
+                         uint64_t aInnerWindowID,
+                         bool aFromPrivateWindow);
 
 void CSP_GetLocalizedStr(const char* aName,
                          const char16_t** aParams,
                          uint32_t aLength,
                          nsAString& outResult);
 
 void CSP_LogStrMessage(const nsAString& aMsg);
 
 void CSP_LogMessage(const nsAString& aMessage,
                     const nsAString& aSourceName,
                     const nsAString& aSourceLine,
                     uint32_t aLineNumber,
                     uint32_t aColumnNumber,
                     uint32_t aFlags,
                     const char* aCategory,
-                    uint64_t aInnerWindowID);
+                    uint64_t aInnerWindowID,
+                    bool aFromPrivateWindow);
 
 
 /* =============== Constant and Type Definitions ================== */
 
 #define INLINE_STYLE_VIOLATION_OBSERVER_TOPIC        "violated base restriction: Inline Stylesheets will not apply"
 #define INLINE_SCRIPT_VIOLATION_OBSERVER_TOPIC       "violated base restriction: Inline Scripts will not execute"
 #define EVAL_VIOLATION_OBSERVER_TOPIC                "violated base restriction: Code will not be created from strings"
 #define SCRIPT_NONCE_VIOLATION_OBSERVER_TOPIC        "Inline Script had invalid nonce"
--- a/dom/security/nsMixedContentBlocker.cpp
+++ b/dom/security/nsMixedContentBlocker.cpp
@@ -799,17 +799,18 @@ nsMixedContentBlocker::ShouldLoad(bool a
     const char16_t* params[] = { reportSpec.get()};
     CSP_LogLocalizedStr("blockAllMixedContent",
                         params, ArrayLength(params),
                         EmptyString(), // aSourceFile
                         EmptyString(), // aScriptSample
                         0, // aLineNumber
                         0, // aColumnNumber
                         nsIScriptError::errorFlag, "CSP",
-                        document->InnerWindowID());
+                        document->InnerWindowID(),
+                        !!document->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId);
     *aDecision = REJECT_REQUEST;
     return NS_OK;
   }
 
   // Determine if the rootDoc is https and if the user decided to allow Mixed Content
   bool rootHasSecureConnection = false;
   bool allowMixedContent = false;
   bool isRootDocShell = false;
--- a/dom/websocket/WebSocket.cpp
+++ b/dom/websocket/WebSocket.cpp
@@ -94,16 +94,17 @@ public:
   , mOnCloseScheduled(false)
   , mFailed(false)
   , mDisconnectingOrDisconnected(false)
   , mCloseEventWasClean(false)
   , mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL)
   , mScriptLine(0)
   , mScriptColumn(0)
   , mInnerWindowID(0)
+  , mPrivateBrowsing(false)
   , mWorkerPrivate(nullptr)
 #ifdef DEBUG
   , mHasWorkerHolderRegistered(false)
 #endif
   , mIsMainThread(true)
   , mMutex("WebSocketImpl::mMutex")
   , mWorkerShuttingDown(false)
   {
@@ -206,16 +207,17 @@ public:
   //   was constructed.
   // - the ID of the inner window where the script lives. Note that this may not
   //   be the same as the Web Socket owner window.
   // These attributes are used for error reporting.
   nsCString mScriptFile;
   uint32_t mScriptLine;
   uint32_t mScriptColumn;
   uint64_t mInnerWindowID;
+  bool mPrivateBrowsing;
 
   WorkerPrivate* mWorkerPrivate;
   nsAutoPtr<WorkerHolder> mWorkerHolder;
 
 #ifdef DEBUG
   // This is protected by mutex.
   bool mHasWorkerHolderRegistered;
 
@@ -385,17 +387,18 @@ WebSocketImpl::PrintErrorOnConsole(const
                                        EmptyString(), mScriptLine,
                                        mScriptColumn,
                                        nsIScriptError::errorFlag, "Web Socket",
                                        mInnerWindowID);
   } else {
     rv = errorObject->Init(message,
                            NS_ConvertUTF8toUTF16(mScriptFile),
                            EmptyString(), mScriptLine, mScriptColumn,
-                           nsIScriptError::errorFlag, "Web Socket");
+                           nsIScriptError::errorFlag, "Web Socket",
+                           mPrivateBrowsing);
   }
 
   NS_ENSURE_SUCCESS_VOID(rv);
 
   // print the error message directly to the JS console
   rv = console->LogMessage(errorObject);
   NS_ENSURE_SUCCESS_VOID(rv);
 }
@@ -1563,16 +1566,18 @@ WebSocketImpl::Init(JSContext* aCx,
 
   // If we don't have aCx, we are window-less, so we don't have a
   // inner-windowID. This can happen in sharedWorkers and ServiceWorkers or in
   // DedicateWorkers created by JSM.
   if (aCx) {
     mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(aCx);
   }
 
+  mPrivateBrowsing = !!aPrincipal->OriginAttributesRef().mPrivateBrowsingId;
+
   // parses the url
   rv = ParseURL(PromiseFlatString(aURL));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDocument> originDoc = mWebSocket->GetDocumentIfCurrent();
   if (!originDoc) {
     rv = mWebSocket->CheckInnerWindowCorrectness();
     NS_ENSURE_SUCCESS(rv, rv);
@@ -1635,17 +1640,18 @@ WebSocketImpl::Init(JSContext* aCx,
     const char16_t* params[] = { reportSpec.get(), u"wss" };
     CSP_LogLocalizedStr("upgradeInsecureRequest",
                         params, ArrayLength(params),
                         EmptyString(), // aSourceFile
                         EmptyString(), // aScriptSample
                         0, // aLineNumber
                         0, // aColumnNumber
                         nsIScriptError::warningFlag, "CSP",
-                        mInnerWindowID);
+                        mInnerWindowID,
+                        mPrivateBrowsing);
   }
 
   // Don't allow https:// to open ws://
   if (!mIsServerSide && !mSecure &&
       !Preferences::GetBool("network.websocket.allowInsecureFromHTTPS",
                             false)) {
     // Confirmed we are opening plain ws:// and want to prevent this from a
     // secure context (e.g. https).
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -142,17 +142,18 @@ JavaScriptParent::allowMessage(JSContext
         nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
         if (console && cx) {
             nsAutoString filename;
             uint32_t lineno = 0, column = 0;
             nsJSUtils::GetCallingLocation(cx, filename, &lineno, &column);
             nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
             error->Init(NS_LITERAL_STRING("unsafe/forbidden CPOW usage"), filename,
                         EmptyString(), lineno, column,
-                        nsIScriptError::warningFlag, "chrome javascript");
+                        nsIScriptError::warningFlag, "chrome javascript",
+                        false /* from private window */);
             console->LogMessage(error);
         } else {
             NS_WARNING("Unsafe synchronous IPC message");
         }
     }
 
     return true;
 }
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -245,17 +245,18 @@ XPCNativeInterface::NewInstance(nsIInter
             nsPrintfCString errorMsg("Use of %s in content process is deprecated.", intfNameChars);
 
             nsAutoString filename;
             uint32_t lineno = 0, column = 0;
             nsJSUtils::GetCallingLocation(cx, filename, &lineno, &column);
             nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
             error->Init(NS_ConvertUTF8toUTF16(errorMsg),
                         filename, EmptyString(),
-                        lineno, column, nsIScriptError::warningFlag, "chrome javascript");
+                        lineno, column, nsIScriptError::warningFlag, "chrome javascript",
+                        false /* from private window */);
             console->LogMessage(error);
         }
     }
 
     if (NS_FAILED(aInfo->GetMethodCount(&methodCount)) ||
         NS_FAILED(aInfo->GetConstantCount(&constCount)))
         return nullptr;
 
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -3004,17 +3004,18 @@ NS_ShouldSecureUpgrade(nsIURI* aURI,
           uint32_t innerWindowId = aLoadInfo->GetInnerWindowID();
           CSP_LogLocalizedStr("upgradeInsecureRequest",
                               params, ArrayLength(params),
                               EmptyString(), // aSourceFile
                               EmptyString(), // aScriptSample
                               0, // aLineNumber
                               0, // aColumnNumber
                               nsIScriptError::warningFlag, "CSP",
-                              innerWindowId);
+                              innerWindowId,
+                              !!aLoadInfo->GetOriginAttributes().mPrivateBrowsingId);
           Telemetry::AccumulateCategorical(Telemetry::LABELS_HTTP_SCHEME_UPGRADE_TYPE::CSP);
         } else {
           nsCOMPtr<nsIDocument> doc;
           nsINode* node = aLoadInfo->LoadingNode();
           if (node) {
             doc = node->OwnerDoc();
           }
 
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -3982,17 +3982,19 @@ HttpChannelChild::RecvLogBlockedCORSRequ
   return IPC_OK();
 }
 
 NS_IMETHODIMP
 HttpChannelChild::LogBlockedCORSRequest(const nsAString & aMessage)
 {
   if (mLoadInfo) {
     uint64_t innerWindowID = mLoadInfo->GetInnerWindowID();
-    nsCORSListenerProxy::LogBlockedCORSRequest(innerWindowID, aMessage);
+    bool privateBrowsing = !!mLoadInfo->GetOriginAttributes().mPrivateBrowsingId;
+    nsCORSListenerProxy::LogBlockedCORSRequest(innerWindowID, privateBrowsing,
+                                               aMessage);
   }
   return NS_OK;
 }
 
 void
 HttpChannelChild::MaybeCallSynthesizedCallback()
 {
   if (!mSynthesizedCallback) {
--- a/netwerk/protocol/http/nsCORSListenerProxy.cpp
+++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp
@@ -92,19 +92,28 @@ LogBlockedRequest(nsIRequest* aRequest,
       rv = aCreatingChannel->LogBlockedCORSRequest(msg);
       if (NS_SUCCEEDED(rv)) {
         return;
       }
     }
     NS_WARNING("Failed to log blocked cross-site request to web console from parent->child, falling back to browser console");
   }
 
+  bool privateBrowsing = false;
+  if (aRequest) {
+    nsCOMPtr<nsILoadGroup> loadGroup;
+    rv = aRequest->GetLoadGroup(getter_AddRefs(loadGroup));
+    NS_ENSURE_SUCCESS_VOID(rv);
+    privateBrowsing = nsContentUtils::IsInPrivateBrowsing(loadGroup);
+  }
+
   // log message ourselves
   uint64_t innerWindowID = nsContentUtils::GetInnerWindowID(aRequest);
-  nsCORSListenerProxy::LogBlockedCORSRequest(innerWindowID, msg);
+  nsCORSListenerProxy::LogBlockedCORSRequest(innerWindowID, privateBrowsing,
+                                             msg);
 }
 
 //////////////////////////////////////////////////////////////////////////
 // Preflight cache
 
 class nsPreflightCache
 {
 public:
@@ -1562,16 +1571,17 @@ nsCORSListenerProxy::StartCORSPreflight(
   preflightChannel.forget(aPreflightChannel);
 
   return NS_OK;
 }
 
 // static
 void
 nsCORSListenerProxy::LogBlockedCORSRequest(uint64_t aInnerWindowID,
+                                           bool aPrivateBrowsing,
                                            const nsAString& aMessage)
 {
   nsresult rv = NS_OK;
 
   // Build the error object and log it to the console
   nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv));
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to log blocked cross-site request (no console)");
@@ -1599,16 +1609,17 @@ nsCORSListenerProxy::LogBlockedCORSReque
   }
   else {
     rv = scriptError->Init(aMessage,
                            EmptyString(), // sourceName
                            EmptyString(), // sourceLine
                            0,             // lineNumber
                            0,             // columnNumber
                            nsIScriptError::warningFlag,
-                           "CORS");
+                           "CORS",
+                           aPrivateBrowsing);
   }
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to log blocked cross-site request (scriptError init failed)");
     return;
   }
   console->LogMessage(scriptError);
 }
--- a/netwerk/protocol/http/nsCORSListenerProxy.h
+++ b/netwerk/protocol/http/nsCORSListenerProxy.h
@@ -70,16 +70,17 @@ public:
   MOZ_MUST_USE nsresult Init(nsIChannel* aChannel,
                              DataURIHandling aAllowDataURI);
 
   void SetInterceptController(nsINetworkInterceptController* aInterceptController);
 
   // When CORS blocks a request, log the message to the web console, or the
   // browser console if no valid inner window ID is found.
   static void LogBlockedCORSRequest(uint64_t aInnerWindowID,
+                                    bool aPrivateBrowsing,
                                     const nsAString& aMessage);
 private:
   // Only HttpChannelParent can call RemoveFromCorsPreflightCache
   friend class mozilla::net::HttpChannelParent;
   // Only nsHttpChannel can invoke CORS preflights
   friend class mozilla::net::nsHttpChannel;
 
   static void RemoveFromCorsPreflightCache(nsIURI* aURI,
--- a/security/manager/ssl/SSLServerCertVerification.cpp
+++ b/security/manager/ssl/SSLServerCertVerification.cpp
@@ -203,17 +203,18 @@ namespace {
 void
 LogInvalidCertError(nsNSSSocketInfo* socketInfo,
                     PRErrorCode errorCode,
                     ::mozilla::psm::SSLErrorMessageType errorMessageType)
 {
   nsString message;
   socketInfo->GetErrorLogMessage(errorCode, errorMessageType, message);
   if (!message.IsEmpty()) {
-    nsContentUtils::LogSimpleConsoleError(message, "SSL");
+    nsContentUtils::LogSimpleConsoleError(message, "SSL",
+                                          !!socketInfo->GetOriginAttributes().mPrivateBrowsingId);
   }
 }
 
 // Dispatched to the STS thread to notify the infoObject of the verification
 // result.
 //
 // This will cause the PR_Poll in the STS thread to return, so things work
 // correctly even if the STS thread is blocked polling (only) on the file
--- a/security/manager/ssl/nsNSSCallbacks.cpp
+++ b/security/manager/ssl/nsNSSCallbacks.cpp
@@ -1472,14 +1472,15 @@ void HandshakeCallback(PRFileDesc* fd, v
   // we should set a flag on the channel that higher (UI) level code can check
   // to log the warning. In particular, these warnings should go to the web
   // console instead of to the error console. Also, the warning is not
   // localized.
   if (!siteSupportsSafeRenego) {
     NS_ConvertASCIItoUTF16 msg(infoObject->GetHostName());
     msg.AppendLiteral(" : server does not support RFC 5746, see CVE-2009-3555");
 
-    nsContentUtils::LogSimpleConsoleError(msg, "SSL");
+    nsContentUtils::LogSimpleConsoleError(msg, "SSL",
+                                          !!infoObject->GetOriginAttributes().mPrivateBrowsingId);
   }
 
   infoObject->NoteTimeUntilReady();
   infoObject->SetHandshakeCompleted();
 }
--- a/security/manager/ssl/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/nsNSSIOLayer.cpp
@@ -738,17 +738,18 @@ nsHandleSSLError(nsNSSSocketInfo* socket
   }
 
   // We must cancel first, which sets the error code.
   socketInfo->SetCanceled(err, SSLErrorMessageType::Plain);
   nsAutoString errorString;
   socketInfo->GetErrorLogMessage(err, errtype, errorString);
 
   if (!errorString.IsEmpty()) {
-    nsContentUtils::LogSimpleConsoleError(errorString, "SSL");
+    nsContentUtils::LogSimpleConsoleError(errorString, "SSL",
+                                          !!socketInfo->GetOriginAttributes().mPrivateBrowsingId);
   }
 }
 
 namespace {
 
 enum Operation { reading, writing, not_reading_or_writing };
 
 int32_t checkHandshake(int32_t bytesTransfered, bool wasReading,
--- a/toolkit/components/telemetry/TelemetryCommon.cpp
+++ b/toolkit/components/telemetry/TelemetryCommon.cpp
@@ -111,17 +111,18 @@ LogToBrowserConsole(uint32_t aLogLevel, 
 
   nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
   if (!console) {
     NS_WARNING("Failed to log message to console.");
     return;
   }
 
   nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
-  error->Init(aMsg, EmptyString(), EmptyString(), 0, 0, aLogLevel, "chrome javascript");
+  error->Init(aMsg, EmptyString(), EmptyString(), 0, 0, aLogLevel,
+              "chrome javascript", false /* from private window */);
   console->LogMessage(error);
 }
 
 const char*
 GetNameForProcessID(ProcessID process)
 {
   MOZ_ASSERT(process < ProcessID::Count);
   return ProcessIDToString[static_cast<uint32_t>(process)];
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -187,17 +187,18 @@ LogMessageWithContext(FileLocation& aFil
     do_GetService(NS_CONSOLESERVICE_CONTRACTID);
   if (!console) {
     return;
   }
 
   nsresult rv = error->Init(NS_ConvertUTF8toUTF16(formatted.get()),
                             NS_ConvertUTF8toUTF16(file), EmptyString(),
                             aLineNumber, 0, nsIScriptError::warningFlag,
-                            "chrome registration");
+                            "chrome registration",
+                            false /* from private window */);
   if (NS_FAILED(rv)) {
     return;
   }
 
   console->LogMessage(error);
 }
 
 /**
--- a/xpcom/ds/nsObserverService.cpp
+++ b/xpcom/ds/nsObserverService.cpp
@@ -216,17 +216,18 @@ nsObserverService::AddObserver(nsIObserv
   // child process; see bug 1269765.
   if (mozilla::net::IsNeckoChild() && !strncmp(aTopic, "http-on-", 8) &&
       strcmp(aTopic, "http-on-opening-request") &&
       strcmp(aTopic, "http-on-stop-request")) {
     nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
     nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
     error->Init(NS_LITERAL_STRING("http-on-* observers only work in the parent process"),
                 EmptyString(), EmptyString(), 0, 0,
-                nsIScriptError::warningFlag, "chrome javascript");
+                nsIScriptError::warningFlag, "chrome javascript",
+                false /* from private window */);
     console->LogMessage(error);
 
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   nsObserverList* observerList = mObserverTopicTable.PutEntry(aTopic);
   if (!observerList) {
     return NS_ERROR_OUT_OF_MEMORY;