From 47eca82a8c027928271fe5a20a4fe283bbd79555 Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Wed, 24 Aug 2011 23:44:35 +0300 Subject: [PATCH] Bug 670896 - Add inner window ID and timestamp to nsIScriptError2; r=bzbarsky --- browser/devtools/scratchpad/scratchpad.js | 10 +++--- content/base/public/nsContentUtils.h | 6 ++-- content/base/public/nsIDocument.h | 9 +++++ content/base/src/nsContentUtils.cpp | 11 +++--- content/base/src/nsEventSource.cpp | 6 ++-- content/base/src/nsEventSource.h | 6 ++-- content/base/src/nsWebSocket.cpp | 6 ++-- content/base/src/nsWebSocket.h | 8 ++--- content/xml/document/src/nsXMLDocument.cpp | 4 +-- dom/base/nsDOMClassInfo.cpp | 2 +- dom/base/nsGlobalWindow.h | 5 +++ dom/base/nsJSEnvironment.cpp | 18 ++++++---- dom/base/nsJSUtils.cpp | 8 ++--- dom/base/nsJSUtils.h | 8 ++--- dom/workers/WorkerPrivate.cpp | 16 ++++----- dom/workers/WorkerPrivate.h | 2 +- js/src/xpconnect/idl/nsIScriptError.idl | 16 ++++++--- js/src/xpconnect/src/nsScriptError.cpp | 39 +++++++++++++++++++--- js/src/xpconnect/src/xpccomponents.cpp | 8 ++--- js/src/xpconnect/src/xpcconvert.cpp | 2 +- js/src/xpconnect/src/xpcprivate.h | 4 ++- js/src/xpconnect/src/xpcwrappedjsclass.cpp | 2 +- layout/style/nsCSSScanner.cpp | 13 ++++---- layout/style/nsCSSScanner.h | 2 +- layout/style/nsCSSStyleSheet.cpp | 12 +++---- layout/style/nsCSSStyleSheet.h | 4 +-- layout/style/nsFontFaceLoader.cpp | 4 +-- modules/libpr0n/src/Decoder.cpp | 2 +- modules/libpr0n/src/Image.cpp | 2 +- modules/libpr0n/src/Image.h | 8 ++--- modules/libpr0n/src/imgLoader.cpp | 4 +-- modules/libpr0n/src/imgRequest.cpp | 7 ++-- modules/libpr0n/src/imgRequest.h | 12 +++---- parser/htmlparser/src/nsExpatDriver.cpp | 9 +++-- parser/htmlparser/src/nsExpatDriver.h | 2 +- 35 files changed, 171 insertions(+), 106 deletions(-) diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 7d4edd073eb2..153b7fd9f5fd 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -280,7 +280,7 @@ var Scratchpad = { scriptError.initWithWindowID(ex.message + "\n" + ex.stack, ex.fileName, "", ex.lineNumber, 0, scriptError.errorFlag, "content javascript", - this.getWindowId(contentWindow)); + this.getInnerWindowId(contentWindow)); Services.console.logMessage(scriptError); } @@ -633,16 +633,16 @@ var Scratchpad = { }, /** - * Gets the ID of the outer window of the given DOM window object. + * Gets the ID of the inner window of the given DOM window object. * * @param nsIDOMWindow aWindow * @return integer - * the outer window ID + * the inner window ID */ - getWindowId: function SP_getWindowId(aWindow) + getInnerWindowId: function SP_getInnerWindowId(aWindow) { return aWindow.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIDOMWindowUtils).outerWindowID; + getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID; }, /** diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 0fc672e12160..0503e6b64a0e 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -743,8 +743,8 @@ public: * @param aColumnNumber Column number within resource containing error. * @param aErrorFlags See nsIScriptError. * @param aCategory Name of module reporting error. - * @param [aWindowId=0] (Optional) The window ID of the outer window the - * message originates from. + * @param [aInnerWindowId=0] (Optional) The window ID of the inner window + * the message originates from. */ enum PropertiesFile { eCSS_PROPERTIES, @@ -769,7 +769,7 @@ public: PRUint32 aColumnNumber, PRUint32 aErrorFlags, const char *aCategory, - PRUint64 aWindowId = 0); + PRUint64 aInnerWindowId = 0); /** * Report a localized error message to the error console. diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 95c8d4814c5e..aa8a104328b2 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -720,6 +720,15 @@ public: return window ? window->WindowID() : 0; } + /** + * Return the inner window ID. + */ + PRUint64 InnerWindowID() + { + nsPIDOMWindow *window = GetInnerWindow(); + return window ? window->WindowID() : 0; + } + /** * Get the script loader for this document */ diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 89e9465327b2..d8ffd0ebae73 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -2734,7 +2734,7 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile, PRUint32 aColumnNumber, PRUint32 aErrorFlags, const char *aCategory, - PRUint64 aWindowId) + PRUint64 aInnerWindowId) { NS_ASSERTION((aParams && aParamsLength) || (!aParams && !aParamsLength), "Supply either both parameters and their number or no" @@ -2768,7 +2768,8 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile, NS_ConvertUTF8toUTF16(spec).get(), // file name aSourceLine.get(), aLineNumber, aColumnNumber, - aErrorFlags, aCategory, aWindowId); + aErrorFlags, aCategory, + aInnerWindowId); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr logError = do_QueryInterface(errorObject); @@ -2789,17 +2790,17 @@ nsContentUtils::ReportToConsole(PropertiesFile aFile, nsIDocument* aDocument) { nsIURI* uri = aURI; - PRUint64 windowID = 0; + PRUint64 innerWindowID = 0; if (aDocument) { if (!uri) { uri = aDocument->GetDocumentURI(); } - windowID = aDocument->OuterWindowID(); + innerWindowID = aDocument->InnerWindowID(); } return ReportToConsole(aFile, aMessageName, aParams, aParamsLength, uri, aSourceLine, aLineNumber, aColumnNumber, aErrorFlags, - aCategory, windowID); + aCategory, innerWindowID); } PRBool diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp index eecb62f2ab1d..16d46d3a2bf7 100644 --- a/content/base/src/nsEventSource.cpp +++ b/content/base/src/nsEventSource.cpp @@ -85,7 +85,7 @@ nsEventSource::nsEventSource() : mLastConvertionResult(NS_OK), mReadyState(nsIEventSource::CONNECTING), mScriptLine(0), - mWindowID(0) + mInnerWindowID(0) { } @@ -253,7 +253,7 @@ nsEventSource::Init(nsIPrincipal* aPrincipal, mScriptFile.AssignASCII(filename); } - mWindowID = nsJSUtils::GetCurrentlyRunningCodeWindowID(cx); + mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx); } // Get the load group for the page. When requesting we'll add ourselves to it. @@ -1072,7 +1072,7 @@ nsEventSource::PrintErrorOnConsole(const char *aBundleURI, nsnull, mScriptLine, 0, nsIScriptError::errorFlag, - "Event Source", mWindowID); + "Event Source", mInnerWindowID); // print the error message directly to the JS console nsCOMPtr logError = do_QueryInterface(errObj); diff --git a/content/base/src/nsEventSource.h b/content/base/src/nsEventSource.h index 3347b7376bbf..b121ed568366 100644 --- a/content/base/src/nsEventSource.h +++ b/content/base/src/nsEventSource.h @@ -252,12 +252,12 @@ protected: // Event Source owner information: // - the script file name // - source code line number where the Event Source object was constructed. - // - the window ID of the outer window where the script lives. Note that this - // may not be the same as the Event Source owner window. + // - the ID of the inner window where the script lives. Note that this may not + // be the same as the Event Source owner window. // These attributes are used for error reporting. nsString mScriptFile; PRUint32 mScriptLine; - PRUint64 mWindowID; + PRUint64 mInnerWindowID; private: nsEventSource(const nsEventSource& x); // prevent bad usage diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp index e45fac54a253..8b3a5d912c84 100644 --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -357,7 +357,7 @@ nsWebSocketEstablishedConnection::PrintErrorOnConsole(const char *aBundleURI, NS_ConvertUTF8toUTF16(mOwner->GetScriptFile()).get(), nsnull, mOwner->GetScriptLine(), 0, nsIScriptError::errorFlag, - "Web Socket", mOwner->WindowID() + "Web Socket", mOwner->InnerWindowID() ); // print the error message directly to the JS console @@ -631,7 +631,7 @@ nsWebSocket::nsWebSocket() : mKeepingAlive(PR_FALSE), mReadyState(nsIMozWebSocket::CONNECTING), mOutgoingBufferedAmount(0), mScriptLine(0), - mWindowID(0) + mInnerWindowID(0) { NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread"); } @@ -1428,7 +1428,7 @@ nsWebSocket::Init(nsIPrincipal* aPrincipal, } } - mWindowID = nsJSUtils::GetCurrentlyRunningCodeWindowID(cx); + mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx); } // parses the url diff --git a/content/base/src/nsWebSocket.h b/content/base/src/nsWebSocket.h index 87fade9a4273..938ce8d02c5f 100644 --- a/content/base/src/nsWebSocket.h +++ b/content/base/src/nsWebSocket.h @@ -99,7 +99,7 @@ public: // Determine if preferences allow WebSocket static PRBool PrefEnabled(); - const PRUint64 WindowID() const { return mWindowID; } + const PRUint64 InnerWindowID() const { return mInnerWindowID; } const nsCString& GetScriptFile() const { return mScriptFile; } const PRUint32 GetScriptLine() const { return mScriptLine; } @@ -164,12 +164,12 @@ protected: // Web Socket owner information: // - the script file name, UTF8 encoded. // - source code line number where the Web Socket object was constructed. - // - the window ID of the outer window where the script lives. Note that this - // may not be the same as the Web Socket owner window. + // - 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; PRUint32 mScriptLine; - PRUint64 mWindowID; + PRUint64 mInnerWindowID; private: nsWebSocket(const nsWebSocket& x); // prevent bad usage diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp index 8e1a68fabcbb..4bdb55f49bde 100644 --- a/content/xml/document/src/nsXMLDocument.cpp +++ b/content/xml/document/src/nsXMLDocument.cpp @@ -382,8 +382,8 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) nsnull, 0, 0, nsIScriptError::warningFlag, "DOM", callingDoc ? - callingDoc->OuterWindowID() : - this->OuterWindowID()); + callingDoc->InnerWindowID() : + this->InnerWindowID()); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index d9650eefdbe5..c878386433be 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1707,7 +1707,7 @@ PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty) 0, // column for error is not available nsIScriptError::warningFlag, "DOM:HTML", - nsJSUtils::GetCurrentlyRunningCodeWindowID(cx)); + nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx)); if (NS_SUCCEEDED(rv)){ nsCOMPtr logError = do_QueryInterface(scriptError); diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 51ee653d6150..3fbc5f862907 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -540,6 +540,11 @@ public: return outerWindow && !outerWindow->IsInnerWindow() ? outerWindow : nsnull; } + static nsGlobalWindow* GetInnerWindowWithId(PRUint64 aInnerWindowID) { + nsGlobalWindow* innerWindow = sWindowsById->Get(aInnerWindowID); + return innerWindow && innerWindow->IsInnerWindow() ? innerWindow : nsnull; + } + static bool HasIndexedDBSupport(); static bool HasPerformanceSupport(); diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 06dc982d6c20..b68888c9bb80 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -267,11 +267,11 @@ public: const nsAString& aFileName, const nsAString& aSourceLine, PRBool aDispatchEvent, - PRUint64 aWindowID) + PRUint64 aInnerWindowID) : mScriptGlobal(aScriptGlobal), mLineNr(aLineNr), mColumn(aColumn), mFlags(aFlags), mErrorMsg(aErrorMsg), mFileName(aFileName), mSourceLine(aSourceLine), mDispatchEvent(aDispatchEvent), - mWindowID(aWindowID) + mInnerWindowID(aInnerWindowID) {} NS_IMETHOD Run() @@ -364,7 +364,7 @@ public: rv = error2->InitWithWindowID(mErrorMsg.get(), mFileName.get(), mSourceLine.get(), mLineNr, mColumn, mFlags, - category, mWindowID); + category, mInnerWindowID); } else { rv = errorObject->Init(mErrorMsg.get(), mFileName.get(), mSourceLine.get(), @@ -393,7 +393,7 @@ public: nsString mFileName; nsString mSourceLine; PRBool mDispatchEvent; - PRUint64 mWindowID; + PRUint64 mInnerWindowID; static PRBool sHandlingScriptError; }; @@ -474,13 +474,19 @@ NS_ScriptErrorReporter(JSContext *cx, nsAutoString sourceLine; sourceLine.Assign(reinterpret_cast(report->uclinebuf)); nsCOMPtr win = do_QueryInterface(globalObject); - PRUint64 windowID = win ? win->WindowID() : 0; + PRUint64 innerWindowID = 0; + if (win) { + nsCOMPtr innerWin = win->GetCurrentInnerWindow(); + if (innerWin) { + innerWindowID = innerWin->WindowID(); + } + } nsContentUtils::AddScriptRunner( new ScriptErrorEvent(globalObject, report->lineno, report->uctokenptr - report->uclinebuf, report->flags, msg, fileName, sourceLine, report->errorNumber != JSMSG_OUT_OF_MEMORY, - windowID)); + innerWindowID)); } } diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index b7888fd49f6d..bbcb3c73e2a9 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -163,12 +163,12 @@ nsJSUtils::GetDynamicScriptContext(JSContext *aContext) } PRUint64 -nsJSUtils::GetCurrentlyRunningCodeWindowID(JSContext *aContext) +nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext) { if (!aContext) return 0; - PRUint64 windowID = 0; + PRUint64 innerWindowID = 0; JSObject *jsGlobal = JS_GetGlobalForScopeChain(aContext); if (jsGlobal) { @@ -177,10 +177,10 @@ nsJSUtils::GetCurrentlyRunningCodeWindowID(JSContext *aContext) if (scriptGlobal) { nsCOMPtr win = do_QueryInterface(scriptGlobal); if (win) - windowID = win->GetOuterWindow()->WindowID(); + innerWindowID = win->WindowID(); } } - return windowID; + return innerWindowID; } diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h index e58f1058bdd4..1f846f7948eb 100644 --- a/dom/base/nsJSUtils.h +++ b/dom/base/nsJSUtils.h @@ -71,14 +71,14 @@ public: static nsIScriptContext *GetDynamicScriptContext(JSContext *aContext); /** - * Retrieve the outer window ID based on the given JSContext. + * Retrieve the inner window ID based on the given JSContext. * * @param JSContext aContext - * The JSContext from which you want to find the outer window ID. + * The JSContext from which you want to find the inner window ID. * - * @returns PRUint64 the outer window ID. + * @returns PRUint64 the inner window ID. */ - static PRUint64 GetCurrentlyRunningCodeWindowID(JSContext *aContext); + static PRUint64 GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext); }; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 8d09a7221f7e..f3298a33cca1 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -895,11 +895,11 @@ public: aWorkerPrivate->AssertInnerWindowIsCorrect(); } - PRUint64 windowId; + PRUint64 innerWindowId; WorkerPrivate* parent = aWorkerPrivate->GetParent(); if (parent) { - windowId = 0; + innerWindowId = 0; } else { AssertIsOnMainThread(); @@ -909,13 +909,13 @@ public: return true; } - windowId = aWorkerPrivate->GetOuterWindowId(); + innerWindowId = aWorkerPrivate->GetInnerWindowId(); } return ReportErrorRunnable::ReportError(aCx, parent, true, target, mMessage, mFilename, mLine, mLineNumber, mColumnNumber, mFlags, - mErrorNumber, windowId); + mErrorNumber, innerWindowId); } static bool @@ -923,7 +923,7 @@ public: bool aFireAtScope, JSObject* aTarget, const nsString& aMessage, const nsString& aFilename, const nsString& aLine, PRUint32 aLineNumber, PRUint32 aColumnNumber, PRUint32 aFlags, - PRUint32 aErrorNumber, PRUint64 aWindowId) + PRUint32 aErrorNumber, PRUint64 aInnerWindowId) { if (aWorkerPrivate) { aWorkerPrivate->AssertIsOnWorkerThread(); @@ -1030,7 +1030,7 @@ public: aLine.get(), aLineNumber, aColumnNumber, aFlags, "Web Worker", - aWindowId))) { + aInnerWindowId))) { consoleMessage = do_QueryInterface(scriptError); NS_ASSERTION(consoleMessage, "This should never fail!"); } @@ -1932,10 +1932,10 @@ WorkerPrivateParent::PostMessage(JSContext* aCx, jsval aMessage) template PRUint64 -WorkerPrivateParent::GetOuterWindowId() +WorkerPrivateParent::GetInnerWindowId() { AssertIsOnMainThread(); - return mDocument->OuterWindowID(); + return mDocument->InnerWindowID(); } template diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index db1e3ccbb1f0..cc31a26ea54b 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -299,7 +299,7 @@ public: PostMessage(JSContext* aCx, jsval aMessage); PRUint64 - GetOuterWindowId(); + GetInnerWindowId(); void UpdateJSContextOptions(JSContext* aCx, PRUint32 aOptions); diff --git a/js/src/xpconnect/idl/nsIScriptError.idl b/js/src/xpconnect/idl/nsIScriptError.idl index 72a52c05f2fa..65b75ca3cb97 100644 --- a/js/src/xpconnect/idl/nsIScriptError.idl +++ b/js/src/xpconnect/idl/nsIScriptError.idl @@ -96,15 +96,23 @@ interface nsIScriptError : nsIConsoleMessage * An interface that nsIScriptError objects can implement to allow * them to be initialized with a window id. */ -[scriptable, uuid(35cd0f6a-f5bb-497a-ba83-9c8d089b52cd)] +[scriptable, uuid(4472646b-c928-4d76-9e7c-6b91da7f24cc)] interface nsIScriptError2 : nsISupports { /* Get the window id this was initialized with. Zero will be - returned if init() was used instead of initWithWindowId(). */ + returned if init() was used instead of initWithWindowID(). */ readonly attribute unsigned long long outerWindowID; + /* Get the inner window id this was initialized with. Zero will be + returned if init() was used instead of initWithWindowID(). */ + readonly attribute unsigned long long innerWindowID; + + /* Elapsed time, in milliseconds, from a platform-specific zero time to the + time the message was created. */ + readonly attribute long long timeStamp; + /* This should be called instead of nsIScriptError.init to initialize with a window id. The window id should be for the - outer window associated with this error. */ + inner window associated with this error. */ void initWithWindowID(in wstring message, in wstring sourceName, in wstring sourceLine, @@ -112,7 +120,7 @@ interface nsIScriptError2 : nsISupports { in PRUint32 columnNumber, in PRUint32 flags, in string category, - in unsigned long long windowID); + in unsigned long long innerWindowID); }; %{ C++ diff --git a/js/src/xpconnect/src/nsScriptError.cpp b/js/src/xpconnect/src/nsScriptError.cpp index 316acccf0983..c94ef5491856 100644 --- a/js/src/xpconnect/src/nsScriptError.cpp +++ b/js/src/xpconnect/src/nsScriptError.cpp @@ -43,6 +43,8 @@ */ #include "xpcprivate.h" +#include "nsGlobalWindow.h" +#include "nsPIDOMWindow.h" NS_IMPL_THREADSAFE_ISUPPORTS3(nsScriptError, nsIConsoleMessage, nsIScriptError, nsIScriptError2) @@ -55,7 +57,9 @@ nsScriptError::nsScriptError() mColumnNumber(0), mFlags(0), mCategory(), - mWindowID(0) + mOuterWindowID(0), + mInnerWindowID(0), + mTimeStamp(0) { } @@ -142,7 +146,7 @@ nsScriptError::InitWithWindowID(const PRUnichar *message, PRUint32 columnNumber, PRUint32 flags, const char *category, - PRUint64 aWindowID) + PRUint64 aInnerWindowID) { mMessage.Assign(message); mSourceName.Assign(sourceName); @@ -151,7 +155,18 @@ nsScriptError::InitWithWindowID(const PRUnichar *message, mColumnNumber = columnNumber; mFlags = flags; mCategory.Assign(category); - mWindowID = aWindowID; + mTimeStamp = PR_Now() / 1000; + mInnerWindowID = aInnerWindowID; + + if(aInnerWindowID) { + nsGlobalWindow* window = + nsGlobalWindow::GetInnerWindowWithId(aInnerWindowID); + if(window) { + nsPIDOMWindow* outer = window->GetOuterWindow(); + if(outer) + mOuterWindowID = outer->WindowID(); + } + } return NS_OK; } @@ -218,8 +233,22 @@ nsScriptError::ToString(nsACString& /*UTF8*/ aResult) } NS_IMETHODIMP -nsScriptError::GetOuterWindowID(PRUint64 *aWindowID) +nsScriptError::GetOuterWindowID(PRUint64 *aOuterWindowID) { - *aWindowID = mWindowID; + *aOuterWindowID = mOuterWindowID; + return NS_OK; +} + +NS_IMETHODIMP +nsScriptError::GetInnerWindowID(PRUint64 *aInnerWindowID) +{ + *aInnerWindowID = mInnerWindowID; + return NS_OK; +} + +NS_IMETHODIMP +nsScriptError::GetTimeStamp(PRInt64 *aTimeStamp) +{ + *aTimeStamp = mTimeStamp; return NS_OK; } diff --git a/js/src/xpconnect/src/xpccomponents.cpp b/js/src/xpconnect/src/xpccomponents.cpp index ea5e9dddbbe1..2c1513eb8e4c 100644 --- a/js/src/xpconnect/src/xpccomponents.cpp +++ b/js/src/xpconnect/src/xpccomponents.cpp @@ -2880,7 +2880,7 @@ nsXPCComponents_Utils::ReportError() if(NS_FAILED(rv) || !argv) return NS_OK; - const PRUint64 windowID = nsJSUtils::GetCurrentlyRunningCodeWindowID(cx); + const PRUint64 innerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx); JSErrorReport* err = JS_ErrorFromException(cx, argv[0]); if(err) @@ -2899,7 +2899,7 @@ nsXPCComponents_Utils::ReportError() err->lineno, column, err->flags, - "XPConnect JavaScript", windowID); + "XPConnect JavaScript", innerWindowID); if(NS_FAILED(rv)) return NS_OK; @@ -2935,8 +2935,8 @@ nsXPCComponents_Utils::ReportError() rv = scripterr->InitWithWindowID(reinterpret_cast(msgchars), NS_ConvertUTF8toUTF16(fileName).get(), nsnull, - lineNo, 0, - 0, "XPConnect JavaScript", windowID); + lineNo, 0, 0, + "XPConnect JavaScript", innerWindowID); if(NS_SUCCEEDED(rv)) { nsCOMPtr logError = do_QueryInterface(scripterr); diff --git a/js/src/xpconnect/src/xpcconvert.cpp b/js/src/xpconnect/src/xpcconvert.cpp index eadedc10da21..67b6d7ea5a66 100644 --- a/js/src/xpconnect/src/xpcconvert.cpp +++ b/js/src/xpconnect/src/xpcconvert.cpp @@ -1827,7 +1827,7 @@ XPCConvert::JSErrorToXPCException(XPCCallContext& ccx, (const PRUnichar *)report->uclinebuf, report->lineno, report->uctokenptr - report->uclinebuf, report->flags, "XPConnect JavaScript", - nsJSUtils::GetCurrentlyRunningCodeWindowID(ccx.GetJSContext())); + nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(ccx.GetJSContext())); } if(data) diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index 592f88de998b..dd774f30b738 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -3885,7 +3885,9 @@ private: PRUint32 mColumnNumber; PRUint32 mFlags; nsCString mCategory; - PRUint64 mWindowID; + PRUint64 mOuterWindowID; + PRUint64 mInnerWindowID; + PRUint64 mTimeStamp; }; /***************************************************************************/ diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp index 12058a2948c6..386a9dfb3a96 100644 --- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -1218,7 +1218,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx, nsnull, lineNumber, 0, 0, "XPConnect JavaScript", - nsJSUtils::GetCurrentlyRunningCodeWindowID(cx)); + nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx)); if(NS_FAILED(rv)) scriptError = nsnull; } diff --git a/layout/style/nsCSSScanner.cpp b/layout/style/nsCSSScanner.cpp index a3de10928b3f..eb2f5595be81 100644 --- a/layout/style/nsCSSScanner.cpp +++ b/layout/style/nsCSSScanner.cpp @@ -285,7 +285,7 @@ nsCSSScanner::nsCSSScanner() , mSVGMode(PR_FALSE) #ifdef CSS_REPORT_PARSE_ERRORS , mError(mErrorBuf, NS_ARRAY_LENGTH(mErrorBuf), 0) - , mWindowID(0) + , mInnerWindowID(0) , mWindowIDCached(PR_FALSE) , mSheet(nsnull) , mLoader(nsnull) @@ -449,12 +449,12 @@ nsCSSScanner::OutputError() if (InitGlobals() && gReportErrors) { if (!mWindowIDCached) { if (mSheet) { - mWindowID = mSheet->FindOwningWindowID(); + mInnerWindowID = mSheet->FindOwningWindowInnerID(); } - if (mWindowID == 0 && mLoader) { + if (mInnerWindowID == 0 && mLoader) { nsIDocument* doc = mLoader->GetDocument(); if (doc) { - mWindowID = doc->OuterWindowID(); + mInnerWindowID = doc->InnerWindowID(); } } mWindowIDCached = PR_TRUE; @@ -471,7 +471,8 @@ nsCSSScanner::OutputError() mErrorLineNumber, mErrorColNumber, nsIScriptError::warningFlag, - "CSS Parser", mWindowID); + "CSS Parser", + mInnerWindowID); if (NS_SUCCEEDED(rv)) { nsCOMPtr logError = do_QueryInterface(errorObject); gConsoleService->LogMessage(logError); @@ -622,7 +623,7 @@ nsCSSScanner::Close() mFileName.Truncate(); mURI = nsnull; mError.Truncate(); - mWindowID = 0; + mInnerWindowID = 0; mWindowIDCached = PR_FALSE; mSheet = nsnull; mLoader = nsnull; diff --git a/layout/style/nsCSSScanner.h b/layout/style/nsCSSScanner.h index ed82e3dc7034..3470eeea7645 100644 --- a/layout/style/nsCSSScanner.h +++ b/layout/style/nsCSSScanner.h @@ -248,7 +248,7 @@ protected: PRUint32 mErrorLineNumber, mColNumber, mErrorColNumber; nsFixedString mError; PRUnichar mErrorBuf[200]; - PRUint64 mWindowID; + PRUint64 mInnerWindowID; PRBool mWindowIDCached; nsCSSStyleSheet* mSheet; mozilla::css::Loader* mLoader; diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index 54e35d9c6ca5..c6b0ce7cd485 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -1252,12 +1252,12 @@ nsCSSStyleSheet::SetOwningDocument(nsIDocument* aDocument) } } -/* virtual */ PRUint64 -nsCSSStyleSheet::FindOwningWindowID() const +PRUint64 +nsCSSStyleSheet::FindOwningWindowInnerID() const { PRUint64 windowID = 0; if (mDocument) { - windowID = mDocument->OuterWindowID(); + windowID = mDocument->InnerWindowID(); } if (windowID == 0 && mOwningNode) { @@ -1265,7 +1265,7 @@ nsCSSStyleSheet::FindOwningWindowID() const if (node) { nsIDocument* doc = node->GetOwnerDoc(); if (doc) { - windowID = doc->OuterWindowID(); + windowID = doc->InnerWindowID(); } } } @@ -1275,13 +1275,13 @@ nsCSSStyleSheet::FindOwningWindowID() const if (sheet) { nsRefPtr cssSheet = do_QueryObject(sheet); if (cssSheet) { - windowID = cssSheet->FindOwningWindowID(); + windowID = cssSheet->FindOwningWindowInnerID(); } } } if (windowID == 0 && mParent) { - windowID = mParent->FindOwningWindowID(); + windowID = mParent->FindOwningWindowInnerID(); } return windowID; diff --git a/layout/style/nsCSSStyleSheet.h b/layout/style/nsCSSStyleSheet.h index dbf8e72d2ef6..b305d314edc8 100644 --- a/layout/style/nsCSSStyleSheet.h +++ b/layout/style/nsCSSStyleSheet.h @@ -155,8 +155,8 @@ public: virtual nsIDocument* GetOwningDocument() const; // may be null virtual void SetOwningDocument(nsIDocument* aDocument); - // Find the ID of the owner outer window. - virtual PRUint64 FindOwningWindowID() const; + // Find the ID of the owner inner window. + PRUint64 FindOwningWindowInnerID() const; #ifdef DEBUG virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; #endif diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index 6ce61aa15401..bc1878e06121 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -798,14 +798,14 @@ nsUserFontSet::LogMessage(gfxProxyFontEntry *aProxy, do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - PRUint64 windowID = GetPresContext()->Document()->OuterWindowID(); + PRUint64 innerWindowID = GetPresContext()->Document()->InnerWindowID(); rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(msg).get(), href.get(), // file text.get(), // src line 0, 0, // line & column number aFlags, // flags "CSS Loader", // category (make separate?) - windowID); + innerWindowID); if (NS_SUCCEEDED(rv)){ nsCOMPtr logError = do_QueryInterface(scriptError); if (logError) { diff --git a/modules/libpr0n/src/Decoder.cpp b/modules/libpr0n/src/Decoder.cpp index 97087621b0c2..03d260e2f90d 100644 --- a/modules/libpr0n/src/Decoder.cpp +++ b/modules/libpr0n/src/Decoder.cpp @@ -133,7 +133,7 @@ Decoder::Finish() NS_ConvertUTF8toUTF16(mImage->GetURIString()).get(), nsnull, 0, 0, nsIScriptError::errorFlag, - "Image", mImage->WindowID() + "Image", mImage->InnerWindowID() ); nsCOMPtr error = do_QueryInterface(errorObject); diff --git a/modules/libpr0n/src/Image.cpp b/modules/libpr0n/src/Image.cpp index 755840f8cdbc..16921ed34c11 100644 --- a/modules/libpr0n/src/Image.cpp +++ b/modules/libpr0n/src/Image.cpp @@ -42,7 +42,7 @@ namespace imagelib { // Constructor Image::Image(imgStatusTracker* aStatusTracker) : - mWindowId(0), + mInnerWindowId(0), mAnimationConsumers(0), mAnimationMode(kNormalAnimMode), mInitialized(PR_FALSE), diff --git a/modules/libpr0n/src/Image.h b/modules/libpr0n/src/Image.h index f216b72f5844..b6851888ec7c 100644 --- a/modules/libpr0n/src/Image.h +++ b/modules/libpr0n/src/Image.h @@ -125,10 +125,10 @@ public: PRUint32 GetAnimationConsumers() { return mAnimationConsumers; } #endif - void SetWindowID(PRUint64 aWindowId) { - mWindowId = aWindowId; + void SetInnerWindowID(PRUint64 aInnerWindowId) { + mInnerWindowId = aInnerWindowId; } - PRUint64 WindowID() const { return mWindowId; } + PRUint64 InnerWindowID() const { return mInnerWindowId; } PRBool HasError() { return mError; } @@ -144,7 +144,7 @@ protected: virtual nsresult StartAnimation() = 0; virtual nsresult StopAnimation() = 0; - PRUint64 mWindowId; + PRUint64 mInnerWindowId; // Member data shared by all implementations of this abstract class nsAutoPtr mStatusTracker; diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp index 04faeb86f556..36858e961acd 100644 --- a/modules/libpr0n/src/imgLoader.cpp +++ b/modules/libpr0n/src/imgLoader.cpp @@ -1709,10 +1709,10 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, request->Init(aURI, aURI, loadGroup, newChannel, entry, cacheId, aCX, aLoadingPrincipal, corsmode); - // Pass the windowID of the loading document, if possible. + // Pass the inner window ID of the loading document, if possible. nsCOMPtr doc = do_QueryInterface(aCX); if (doc) { - request->SetWindowID(doc->OuterWindowID()); + request->SetInnerWindowID(doc->InnerWindowID()); } // create the proxy listener diff --git a/modules/libpr0n/src/imgRequest.cpp b/modules/libpr0n/src/imgRequest.cpp index c24354cb8ee9..dd4673fbb256 100644 --- a/modules/libpr0n/src/imgRequest.cpp +++ b/modules/libpr0n/src/imgRequest.cpp @@ -184,8 +184,9 @@ NS_IMPL_ISUPPORTS8(imgRequest, imgRequest::imgRequest() : mCacheId(0), mValidator(nsnull), mImageSniffers("image-sniffing-services"), - mWindowId(0), mCORSMode(imgIRequest::CORS_NONE), mDecodeRequested(PR_FALSE), - mIsMultiPartChannel(PR_FALSE), mGotData(PR_FALSE), mIsInCache(PR_FALSE) + mInnerWindowId(0), mCORSMode(imgIRequest::CORS_NONE), + mDecodeRequested(PR_FALSE), mIsMultiPartChannel(PR_FALSE), mGotData(PR_FALSE), + mIsInCache(PR_FALSE) {} imgRequest::~imgRequest() @@ -1035,7 +1036,7 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx } else { mImage = new RasterImage(mStatusTracker.forget()); } - mImage->SetWindowID(mWindowId); + mImage->SetInnerWindowID(mInnerWindowId); imageType = mImage->GetType(); // Notify any imgRequestProxys that are observing us that we have an Image. diff --git a/modules/libpr0n/src/imgRequest.h b/modules/libpr0n/src/imgRequest.h index 7de1693622cc..1e62fcb5ef96 100644 --- a/modules/libpr0n/src/imgRequest.h +++ b/modules/libpr0n/src/imgRequest.h @@ -123,12 +123,12 @@ public: nsresult UnlockImage(); nsresult RequestDecode(); - inline void SetWindowID(PRUint64 aWindowId) { - mWindowId = aWindowId; + inline void SetInnerWindowID(PRUint64 aInnerWindowId) { + mInnerWindowId = aInnerWindowId; } - inline PRUint64 WindowID() const { - return mWindowId; + inline PRUint64 InnerWindowID() const { + return mInnerWindowId; } // Set the cache validation information (expiry time, whether we must @@ -257,8 +257,8 @@ private: nsCOMPtr mRedirectCallback; nsCOMPtr mNewRedirectChannel; - // Originating outer window ID. Used for error reporting. - PRUint64 mWindowId; + // The ID of the inner window origin, used for error reporting. + PRUint64 mInnerWindowId; // The CORS mode (defined in imgIRequest) this image was loaded with. By // default, imgIRequest::CORS_NONE. diff --git a/parser/htmlparser/src/nsExpatDriver.cpp b/parser/htmlparser/src/nsExpatDriver.cpp index 9511016ad504..470dfebf3619 100644 --- a/parser/htmlparser/src/nsExpatDriver.cpp +++ b/parser/htmlparser/src/nsExpatDriver.cpp @@ -376,7 +376,7 @@ nsExpatDriver::nsExpatDriver() mInternalState(NS_OK), mExpatBuffered(0), mCatalogData(nsnull), - mWindowID(0) + mInnerWindowID(0) { } @@ -953,7 +953,7 @@ nsExpatDriver::HandleError() mLastLine.get(), lineNumber, colNumber, nsIScriptError::errorFlag, "malformed-xml", - mWindowID); + mInnerWindowID); } // If it didn't initialize, we can't do any logging. @@ -1250,8 +1250,11 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext, win = do_QueryInterface(global); } } + if (win && !win->IsInnerWindow()) { + win = win->GetCurrentInnerWindow(); + } if (win) { - mWindowID = win->GetOuterWindow()->WindowID(); + mInnerWindowID = win->WindowID(); } } diff --git a/parser/htmlparser/src/nsExpatDriver.h b/parser/htmlparser/src/nsExpatDriver.h index 487a68ddc8cc..9f0e3a051d55 100644 --- a/parser/htmlparser/src/nsExpatDriver.h +++ b/parser/htmlparser/src/nsExpatDriver.h @@ -169,7 +169,7 @@ private: nsString mURISpec; // Used for error reporting. - PRUint64 mWindowID; + PRUint64 mInnerWindowID; }; #endif