diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp index 3c9279a571a3..d732eea6a944 100644 --- a/dom/console/Console.cpp +++ b/dom/console/Console.cpp @@ -1507,6 +1507,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx, event.mInnerID.Value().SetAsUnsignedLongLong() = 0; } + event.mConsoleID = mConsoleID; event.mLevel = aData->mMethodString; event.mFilename = frame.mFilename; diff --git a/dom/console/Console.h b/dom/console/Console.h index 7b221f8ae199..6e21280abfa0 100644 --- a/dom/console/Console.h +++ b/dom/console/Console.h @@ -415,6 +415,7 @@ private: uint64_t mOuterID; uint64_t mInnerID; + nsString mConsoleID; enum { eUnknown, diff --git a/dom/console/ConsoleInstance.cpp b/dom/console/ConsoleInstance.cpp index 0c12f78da115..70aca6e6c6d6 100644 --- a/dom/console/ConsoleInstance.cpp +++ b/dom/console/ConsoleInstance.cpp @@ -21,7 +21,9 @@ NS_INTERFACE_MAP_END ConsoleInstance::ConsoleInstance(const ConsoleInstanceOptions& aOptions) : mConsole(new Console(nullptr)) -{} +{ + mConsole->mConsoleID = aOptions.mConsoleID; +} ConsoleInstance::~ConsoleInstance() {} diff --git a/dom/console/tests/console.jsm b/dom/console/tests/console.jsm index 3f521e69a541..df304db7024d 100644 --- a/dom/console/tests/console.jsm +++ b/dom/console/tests/console.jsm @@ -7,6 +7,8 @@ this.EXPORTED_SYMBOLS = [ "ConsoleTest" ]; this.ConsoleTest = { go: function() { console.log("Hello world!"); - console.createInstance().log("Hello world!"); + console.createInstance({ + consoleID: "wow", + }).log("Hello world!"); } }; diff --git a/dom/console/tests/test_jsm.xul b/dom/console/tests/test_jsm.xul index 5c072edd414a..995b432a07e2 100644 --- a/dom/console/tests/test_jsm.xul +++ b/dom/console/tests/test_jsm.xul @@ -31,6 +31,12 @@ consoleListener.prototype = { is(obj.ID, "jsm", "ID and InnerID are correctly set."); is (obj.arguments[0], "Hello world!", "Message matches"); + if (this.count == 0) { + is(obj.consoleID, "", "No consoleID for console API"); + } else { + is(obj.consoleID, "wow", "consoleID is set by consoleInstance"); + } + // We want to see 2 messages, the first is generated by console.log, // the second one from createInstance().log(); if (++this.count == 2) { diff --git a/dom/webidl/Console.webidl b/dom/webidl/Console.webidl index a48a28d228e7..17965c3985ee 100644 --- a/dom/webidl/Console.webidl +++ b/dom/webidl/Console.webidl @@ -58,6 +58,7 @@ namespace console { dictionary ConsoleEvent { (unsigned long long or DOMString) ID; (unsigned long long or DOMString) innerID; + DOMString consoleID = ""; DOMString addonId = ""; DOMString level = ""; DOMString filename = ""; @@ -154,5 +155,11 @@ interface ConsoleInstance { }; dictionary ConsoleInstanceOptions { - // TODO +/* TODO: + boolean dump = false; + DOMString prefix = ""; + DOMString maxLogLevel = ""; + DOMString innerID = ""; +*/ + DOMString consoleID = ""; };