diff --git a/js/xpconnect/idl/nsIScriptError.idl b/js/xpconnect/idl/nsIScriptError.idl index 74388de4a49..b4ffd8b55be 100644 --- a/js/xpconnect/idl/nsIScriptError.idl +++ b/js/xpconnect/idl/nsIScriptError.idl @@ -11,7 +11,7 @@ #include "nsISupports.idl" #include "nsIConsoleMessage.idl" -[scriptable, uuid(ec640482-be5f-49a0-a9cb-c87eacce9291)] +[scriptable, uuid(cac9d8e8-0d53-4fa8-9903-bb367e4fa1fe)] interface nsIScriptError : nsIConsoleMessage { /** pseudo-flag for default case */ @@ -49,15 +49,6 @@ interface nsIScriptError : nsIConsoleMessage */ readonly attribute string category; - /* - The time (in milliseconds from the Epoch) that the script error instance - was initialised, and thus the time when the error occurred. - Currently used to display date and time of the message in Error console. - The timestamp is initialized as JS_now/1000 so that it can be - compared to Date.now in Javascript. - */ - readonly attribute long long timeStamp; - /* Get the window id this was initialized with. Zero will be returned if init() was used instead of initWithWindowID(). */ readonly attribute unsigned long long outerWindowID; @@ -87,13 +78,11 @@ interface nsIScriptError : nsIConsoleMessage in uint32_t flags, in string category, in unsigned long long innerWindowID); - - AUTF8String toString(); }; %{ C++ #define NS_SCRIPTERROR_CID \ -{ 0xe38e53b9, 0x5bb0, 0x456a, { 0xb5, 0x53, 0x57, 0x93, 0x70, 0xcb, 0x15, 0x67 }} +{ 0x1950539a, 0x90f0, 0x4d22, { 0xb5, 0xaf, 0x71, 0x32, 0x9c, 0x68, 0xfa, 0x35 }} #define NS_SCRIPTERROR_CONTRACTID "@mozilla.org/scripterror;1" %} diff --git a/xpcom/base/nsConsoleMessage.cpp b/xpcom/base/nsConsoleMessage.cpp index 119e1b1d942..6c5c005c8db 100644 --- a/xpcom/base/nsConsoleMessage.cpp +++ b/xpcom/base/nsConsoleMessage.cpp @@ -9,29 +9,41 @@ #include "nsConsoleMessage.h" #include "nsReadableUtils.h" +#include "jsapi.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsConsoleMessage, nsIConsoleMessage) -nsConsoleMessage::nsConsoleMessage() +nsConsoleMessage::nsConsoleMessage() + : mMessage(), + mTimeStamp(0) { } -nsConsoleMessage::nsConsoleMessage(const PRUnichar *message) +nsConsoleMessage::nsConsoleMessage(const PRUnichar *message) { - mMessage.Assign(message); + mTimeStamp = JS_Now() / 1000; + mMessage.Assign(message); } NS_IMETHODIMP -nsConsoleMessage::GetMessageMoz(PRUnichar **result) { - *result = ToNewUnicode(mMessage); +nsConsoleMessage::GetMessageMoz(PRUnichar **result) +{ + *result = ToNewUnicode(mMessage); - return NS_OK; + return NS_OK; } -// NS_IMETHODIMP -// nsConsoleMessage::Init(const PRUnichar *message) { -// nsAutoString newMessage(message); -// mMessage = ToNewUnicode(newMessage); -// return NS_OK; -// } +NS_IMETHODIMP +nsConsoleMessage::GetTimeStamp(int64_t *aTimeStamp) +{ + *aTimeStamp = mTimeStamp; + return NS_OK; +} +NS_IMETHODIMP +nsConsoleMessage::ToString(nsACString& /*UTF8*/ aResult) +{ + CopyUTF16toUTF8(mMessage, aResult); + + return NS_OK; +} diff --git a/xpcom/base/nsConsoleMessage.h b/xpcom/base/nsConsoleMessage.h index 6fae2655b0e..95fbd3864de 100644 --- a/xpcom/base/nsConsoleMessage.h +++ b/xpcom/base/nsConsoleMessage.h @@ -22,6 +22,7 @@ public: private: ~nsConsoleMessage() {} + int64_t mTimeStamp; nsString mMessage; }; diff --git a/xpcom/base/nsIConsoleMessage.idl b/xpcom/base/nsIConsoleMessage.idl index 360e5360ac0..ba6a80f8d93 100644 --- a/xpcom/base/nsIConsoleMessage.idl +++ b/xpcom/base/nsIConsoleMessage.idl @@ -10,13 +10,23 @@ * provide an object that can be qi'ed to provide more specific * message information. */ -[scriptable, uuid(41bd8784-1dd2-11b2-9553-8606958fffe1)] +[scriptable, uuid(c14c151b-5ea4-47ed-8e85-d392cdd3e154)] interface nsIConsoleMessage : nsISupports { + /** + * The time (in milliseconds from the Epoch) that the message instance + * was initialised. + * The timestamp is initialized as JS_now/1000 so that it can be + * compared to Date.now in Javascript. + */ + readonly attribute long long timeStamp; + [binaryname(MessageMoz)] readonly attribute wstring message; + + AUTF8String toString(); }; %{ C++ #define NS_CONSOLEMESSAGE_CID \ -{ 0x56c9d666, 0x1dd2, 0x11b2, { 0xb4, 0x3c, 0xa8, 0x4b, 0xf3, 0xb3, 0xec, 0xbb }} +{ 0x024efc9e, 0x54dc, 0x4844, { 0x80, 0x4b, 0x41, 0xd3, 0xf3, 0x69, 0x90, 0x73 }} %}