Bug 1425574 - Fill the feature gap between Console.jsm and Console API - part 2 - consoleID in ConsoleEvent, r=smaug, r=bgrins

This commit is contained in:
Andrea Marchesini 2018-01-04 19:19:43 +01:00
parent d820259403
commit 3137ff8bcc
6 changed files with 22 additions and 3 deletions

View File

@ -1507,6 +1507,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx,
event.mInnerID.Value().SetAsUnsignedLongLong() = 0;
}
event.mConsoleID = mConsoleID;
event.mLevel = aData->mMethodString;
event.mFilename = frame.mFilename;

View File

@ -415,6 +415,7 @@ private:
uint64_t mOuterID;
uint64_t mInnerID;
nsString mConsoleID;
enum {
eUnknown,

View File

@ -21,7 +21,9 @@ NS_INTERFACE_MAP_END
ConsoleInstance::ConsoleInstance(const ConsoleInstanceOptions& aOptions)
: mConsole(new Console(nullptr))
{}
{
mConsole->mConsoleID = aOptions.mConsoleID;
}
ConsoleInstance::~ConsoleInstance()
{}

View File

@ -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!");
}
};

View File

@ -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) {

View File

@ -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 = "";
};