|
@@ -0,0 +1,1326 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Andrea Marchesini <amarchesini@mozilla.com>
|
|
|
+# Date 1520919638 -3600
|
|
|
+# Node ID 47a89fa7cfd2f1628fa08dc69687eddfaf7f94bb
|
|
|
+# Parent 80bf73c0191e02d275d56e92ff7e67fce3cb6605
|
|
|
+Bug 1443079 - nsScriptError.isFromPrivateWindow must match the correct value also in e10s mode, r=smaug
|
|
|
+
|
|
|
+diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp
|
|
|
+--- a/chrome/nsChromeRegistry.cpp
|
|
|
++++ b/chrome/nsChromeRegistry.cpp
|
|
|
+@@ -85,17 +85,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()
|
|
|
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
|
|
|
+--- a/dom/base/nsContentUtils.cpp
|
|
|
++++ b/dom/base/nsContentUtils.cpp
|
|
|
+@@ -4182,27 +4182,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,
|
|
|
+@@ -5864,17 +5866,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) {
|
|
|
+diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
|
|
|
+--- a/dom/base/nsContentUtils.h
|
|
|
++++ b/dom/base/nsContentUtils.h
|
|
|
+@@ -990,17 +990,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.
|
|
|
+diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
|
|
|
+--- a/dom/base/nsFrameMessageManager.cpp
|
|
|
++++ b/dom/base/nsFrameMessageManager.cpp
|
|
|
+@@ -509,17 +509,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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
|
|
|
+--- a/dom/base/nsGlobalWindow.cpp
|
|
|
++++ b/dom/base/nsGlobalWindow.cpp
|
|
|
+@@ -9127,17 +9127,18 @@ nsGlobalWindow::PostMessageMozOuter(JSCo
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+diff --git a/dom/bindings/nsIScriptError.idl b/dom/bindings/nsIScriptError.idl
|
|
|
+--- 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.
|
|
|
+diff --git a/dom/bindings/nsScriptError.cpp b/dom/bindings/nsScriptError.cpp
|
|
|
+--- 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)
|
|
|
+diff --git a/dom/bindings/nsScriptError.h b/dom/bindings/nsScriptError.h
|
|
|
+--- 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;
|
|
|
+diff --git a/dom/bindings/nsScriptErrorWithStack.cpp b/dom/bindings/nsScriptErrorWithStack.cpp
|
|
|
+--- 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)
|
|
|
+ {
|
|
|
+diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp
|
|
|
+--- a/dom/html/HTMLFormElement.cpp
|
|
|
++++ b/dom/html/HTMLFormElement.cpp
|
|
|
+@@ -1736,17 +1736,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;
|
|
|
+diff --git a/dom/indexedDB/ReportInternalError.cpp b/dom/indexedDB/ReportInternalError.cpp
|
|
|
+--- 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
|
|
|
+diff --git a/dom/indexedDB/ScriptErrorHelper.cpp b/dom/indexedDB/ScriptErrorHelper.cpp
|
|
|
+--- 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
|
|
|
+ {
|
|
|
+diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
|
|
|
+--- a/dom/ipc/ContentChild.cpp
|
|
|
++++ b/dom/ipc/ContentChild.cpp
|
|
|
+@@ -421,16 +421,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);
|
|
|
+@@ -440,16 +441,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);
|
|
|
+@@ -467,24 +470,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;
|
|
|
+diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
|
|
|
+--- a/dom/ipc/ContentParent.cpp
|
|
|
++++ b/dom/ipc/ContentParent.cpp
|
|
|
+@@ -3773,46 +3773,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;
|
|
|
+@@ -3836,19 +3839,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
|
|
|
+diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h
|
|
|
+--- a/dom/ipc/ContentParent.h
|
|
|
++++ b/dom/ipc/ContentParent.h
|
|
|
+@@ -1016,35 +1016,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;
|
|
|
+diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl
|
|
|
+--- a/dom/ipc/PContent.ipdl
|
|
|
++++ b/dom/ipc/PContent.ipdl
|
|
|
+@@ -757,20 +757,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
|
|
|
+diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp
|
|
|
+--- a/dom/quota/ActorsParent.cpp
|
|
|
++++ b/dom/quota/ActorsParent.cpp
|
|
|
+@@ -1546,17 +1546,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);
|
|
|
+diff --git a/dom/security/FramingChecker.cpp b/dom/security/FramingChecker.cpp
|
|
|
+--- a/dom/security/FramingChecker.cpp
|
|
|
++++ b/dom/security/FramingChecker.cpp
|
|
|
+@@ -176,26 +176,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
|
|
|
+diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp
|
|
|
+--- a/dom/security/nsCSPContext.cpp
|
|
|
++++ b/dom/security/nsCSPContext.cpp
|
|
|
+@@ -788,28 +788,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,
|
|
|
+@@ -827,19 +832,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
|
|
|
+diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp
|
|
|
+--- 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:
|
|
|
+diff --git a/dom/security/nsCSPUtils.h b/dom/security/nsCSPUtils.h
|
|
|
+--- 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"
|
|
|
+diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp
|
|
|
+--- a/dom/security/nsMixedContentBlocker.cpp
|
|
|
++++ b/dom/security/nsMixedContentBlocker.cpp
|
|
|
+@@ -747,17 +747,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;
|
|
|
+diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp
|
|
|
+--- a/dom/websocket/WebSocket.cpp
|
|
|
++++ b/dom/websocket/WebSocket.cpp
|
|
|
+@@ -95,16 +95,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)
|
|
|
+ {
|
|
|
+@@ -207,16 +208,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;
|
|
|
+
|
|
|
+@@ -386,17 +388,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);
|
|
|
+ }
|
|
|
+@@ -1566,16 +1569,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);
|
|
|
+@@ -1638,17 +1643,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).
|
|
|
+diff --git a/js/ipc/JavaScriptParent.cpp b/js/ipc/JavaScriptParent.cpp
|
|
|
+--- 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;
|
|
|
+ }
|
|
|
+diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
|
|
|
+--- 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;
|
|
|
+
|
|
|
+diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp
|
|
|
+--- a/netwerk/base/nsNetUtil.cpp
|
|
|
++++ b/netwerk/base/nsNetUtil.cpp
|
|
|
+@@ -2788,17 +2788,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);
|
|
|
+
|
|
|
+ aShouldUpgrade = true;
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // enforce Strict-Transport-Security
|
|
|
+ nsISiteSecurityService* sss = gHttpHandler->GetSSService();
|
|
|
+diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp
|
|
|
+--- a/netwerk/protocol/http/HttpChannelChild.cpp
|
|
|
++++ b/netwerk/protocol/http/HttpChannelChild.cpp
|
|
|
+@@ -3883,17 +3883,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) {
|
|
|
+diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp
|
|
|
+--- 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:
|
|
|
+@@ -1569,16 +1578,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)");
|
|
|
+@@ -1606,16 +1616,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);
|
|
|
+ }
|
|
|
+diff --git a/netwerk/protocol/http/nsCORSListenerProxy.h b/netwerk/protocol/http/nsCORSListenerProxy.h
|
|
|
+--- 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,
|
|
|
+diff --git a/security/manager/ssl/SSLServerCertVerification.cpp b/security/manager/ssl/SSLServerCertVerification.cpp
|
|
|
+--- a/security/manager/ssl/SSLServerCertVerification.cpp
|
|
|
++++ b/security/manager/ssl/SSLServerCertVerification.cpp
|
|
|
+@@ -202,17 +202,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
|
|
|
+diff --git a/security/manager/ssl/nsNSSCallbacks.cpp b/security/manager/ssl/nsNSSCallbacks.cpp
|
|
|
+--- a/security/manager/ssl/nsNSSCallbacks.cpp
|
|
|
++++ b/security/manager/ssl/nsNSSCallbacks.cpp
|
|
|
+@@ -1481,14 +1481,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();
|
|
|
+ }
|
|
|
+diff --git a/security/manager/ssl/nsNSSIOLayer.cpp b/security/manager/ssl/nsNSSIOLayer.cpp
|
|
|
+--- a/security/manager/ssl/nsNSSIOLayer.cpp
|
|
|
++++ b/security/manager/ssl/nsNSSIOLayer.cpp
|
|
|
+@@ -717,17 +717,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,
|
|
|
+diff --git a/storage/mozStorageHelper.h b/storage/mozStorageHelper.h
|
|
|
+--- a/storage/mozStorageHelper.h
|
|
|
++++ b/storage/mozStorageHelper.h
|
|
|
+@@ -218,17 +218,18 @@ protected:
|
|
|
+ \
|
|
|
+ if (cs) { \
|
|
|
+ nsCString msg(__FUNCTION__); \
|
|
|
+ msg.AppendLiteral(" is deprecated and will be removed soon."); \
|
|
|
+ \
|
|
|
+ nsCOMPtr<nsIScriptError> e = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); \
|
|
|
+ if (e && NS_SUCCEEDED(e->Init(NS_ConvertUTF8toUTF16(msg), EmptyString(), \
|
|
|
+ EmptyString(), 0, 0, \
|
|
|
+- nsIScriptError::errorFlag, "Storage"))) { \
|
|
|
++ nsIScriptError::errorFlag, "Storage", \
|
|
|
++ false))) { \
|
|
|
+ cs->LogMessage(e); \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ if (NS_IsMainThread()) { \
|
|
|
+ nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID()); \
|
|
|
+ if (xpc) { \
|
|
|
+ mozilla::Unused << xpc->DebugDumpJSStack(false, false, false); \
|
|
|
+diff --git a/toolkit/components/places/nsPlacesMacros.h b/toolkit/components/places/nsPlacesMacros.h
|
|
|
+--- a/toolkit/components/places/nsPlacesMacros.h
|
|
|
++++ b/toolkit/components/places/nsPlacesMacros.h
|
|
|
+@@ -70,13 +70,14 @@
|
|
|
+ nsCString msg(__FUNCTION__); \
|
|
|
+ msg.AppendLiteral(" is deprecated and will be removed in the next version.");\
|
|
|
+ NS_WARNING(msg.get()); \
|
|
|
+ nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);\
|
|
|
+ if (cs) { \
|
|
|
+ nsCOMPtr<nsIScriptError> e = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); \
|
|
|
+ if (e && NS_SUCCEEDED(e->Init(NS_ConvertUTF8toUTF16(msg), EmptyString(), \
|
|
|
+ EmptyString(), 0, 0, \
|
|
|
+- nsIScriptError::errorFlag, "Places"))) { \
|
|
|
++ nsIScriptError::errorFlag, "Places", \
|
|
|
++ false))) { \
|
|
|
+ cs->LogMessage(e); \
|
|
|
+ } \
|
|
|
+ } \
|
|
|
+ PR_END_MACRO
|
|
|
+diff --git a/toolkit/components/telemetry/TelemetryCommon.cpp b/toolkit/components/telemetry/TelemetryCommon.cpp
|
|
|
+--- 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)];
|
|
|
+diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
|
|
|
+--- a/xpcom/components/ManifestParser.cpp
|
|
|
++++ b/xpcom/components/ManifestParser.cpp
|
|
|
+@@ -186,17 +186,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);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/xpcom/ds/nsObserverService.cpp b/xpcom/ds/nsObserverService.cpp
|
|
|
+--- 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;
|