Bug 769298 - Avoid logging script errors coming from private windows in the global error console

This commit is contained in:
Andres Hernandez 2012-10-19 15:52:21 -06:00
parent 4411ead4c2
commit 3da7d5c215
5 changed files with 29 additions and 5 deletions

View File

@ -11,7 +11,7 @@
#include "nsISupports.idl"
#include "nsIConsoleMessage.idl"
[scriptable, uuid(ddc19b34-e22e-46d5-9f7f-c7768a7dc50a)]
[scriptable, uuid(ec640482-be5f-49a0-a9cb-c87eacce9291)]
interface nsIScriptError : nsIConsoleMessage
{
/** pseudo-flag for default case */
@ -66,6 +66,8 @@ interface nsIScriptError : nsIConsoleMessage
returned if init() was used instead of initWithWindowID(). */
readonly attribute unsigned long long innerWindowID;
readonly attribute boolean isFromPrivateWindow;
void init(in AString message,
in AString sourceName,
in AString sourceLine,

View File

@ -11,6 +11,8 @@
#include "xpcprivate.h"
#include "nsGlobalWindow.h"
#include "nsPIDOMWindow.h"
#include "nsILoadContext.h"
#include "nsIDocShell.h"
NS_IMPL_THREADSAFE_ISUPPORTS2(nsScriptError, nsIConsoleMessage, nsIScriptError)
@ -24,7 +26,8 @@ nsScriptError::nsScriptError()
mCategory(),
mOuterWindowID(0),
mInnerWindowID(0),
mTimeStamp(0)
mTimeStamp(0),
mIsFromPrivateWindow(false)
{
}
@ -130,6 +133,12 @@ nsScriptError::InitWithWindowID(const nsAString& message,
nsPIDOMWindow* outer = window->GetOuterWindow();
if (outer)
mOuterWindowID = outer->WindowID();
nsIDocShell* docShell = window->GetDocShell();
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext) {
mIsFromPrivateWindow = loadContext->UsePrivateBrowsing();
}
}
}
@ -217,3 +226,10 @@ nsScriptError::GetTimeStamp(int64_t *aTimeStamp)
*aTimeStamp = mTimeStamp;
return NS_OK;
}
NS_IMETHODIMP
nsScriptError::GetIsFromPrivateWindow(bool *aIsFromPrivateWindow)
{
*aIsFromPrivateWindow = mIsFromPrivateWindow;
return NS_OK;
}

View File

@ -3859,6 +3859,7 @@ private:
uint64_t mOuterWindowID;
uint64_t mInnerWindowID;
int64_t mTimeStamp;
bool mIsFromPrivateWindow;
};
/******************************************************************************

View File

@ -162,7 +162,13 @@
// filter chrome urls
if (!this.showChromeErrors && scriptError.sourceName.substr(0, 9) == "chrome://")
return;
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
// filter private windows
if (scriptError.isFromPrivateWindow)
return;
#endif
this.appendError(scriptError);
} catch (ex) {
try {
@ -511,4 +517,3 @@
</binding>
</bindings>

View File

@ -6,4 +6,4 @@ toolkit.jar:
content/global/console.js (content/console.js)
content/global/console.xul (content/console.xul)
content/global/console.css (content/console.css)
content/global/consoleBindings.xml (content/consoleBindings.xml)
* content/global/consoleBindings.xml (content/consoleBindings.xml)