Bug 1431105 - Prefix in Console when used by JSM, r=bgrins, r=smaug

This commit is contained in:
Andrea Marchesini 2018-01-17 09:19:36 -08:00
Родитель f3830bcbef
Коммит 35717fcad1
6 изменённых файлов: 59 добавлений и 6 удалений

Просмотреть файл

@ -1507,6 +1507,7 @@ stubPackets.set("console.log('foobar', 'test')", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924471, "timeStamp": 1502884924471,
@ -1533,6 +1534,7 @@ stubPackets.set("console.log(undefined)", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924479, "timeStamp": 1502884924479,
@ -1557,6 +1559,7 @@ stubPackets.set("console.warn('danger, will robinson!')", {
"groupName": "", "groupName": "",
"level": "warn", "level": "warn",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924487, "timeStamp": 1502884924487,
@ -1583,6 +1586,7 @@ stubPackets.set("console.log(NaN)", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924495, "timeStamp": 1502884924495,
@ -1609,6 +1613,7 @@ stubPackets.set("console.log(null)", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924501, "timeStamp": 1502884924501,
@ -1633,6 +1638,7 @@ stubPackets.set("console.log('鼬')", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924506, "timeStamp": 1502884924506,
@ -1655,6 +1661,7 @@ stubPackets.set("console.clear()", {
"groupName": "", "groupName": "",
"level": "clear", "level": "clear",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924512, "timeStamp": 1502884924512,
"timer": null, "timer": null,
@ -1682,6 +1689,7 @@ stubPackets.set("console.count('bar')", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924515, "timeStamp": 1502884924515,
"timer": null, "timer": null,
@ -1729,6 +1737,7 @@ stubPackets.set("console.assert(false, {message: 'foobar'})", {
"groupName": "", "groupName": "",
"level": "assert", "level": "assert",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924521, "timeStamp": 1502884924521,
@ -1761,6 +1770,7 @@ stubPackets.set("console.log('hello \nfrom \rthe \"string world!')", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924528, "timeStamp": 1502884924528,
@ -1785,6 +1795,7 @@ stubPackets.set("console.log('úṇĩçödê țĕșť')", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924586, "timeStamp": 1502884924586,
@ -1821,6 +1832,7 @@ stubPackets.set("console.dirxml(window)", {
"groupName": "", "groupName": "",
"level": "dirxml", "level": "dirxml",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924596, "timeStamp": 1502884924596,
"timer": null, "timer": null,
@ -1863,6 +1875,7 @@ stubPackets.set("console.log('myarray', ['red', 'green', 'blue'])", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924604, "timeStamp": 1502884924604,
@ -1897,6 +1910,7 @@ stubPackets.set("console.log('myregex', /a.b.c/)", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924610, "timeStamp": 1502884924610,
@ -1938,6 +1952,7 @@ stubPackets.set("console.table(['red', 'green', 'blue']);", {
"groupName": "", "groupName": "",
"level": "table", "level": "table",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924612, "timeStamp": 1502884924612,
"timer": null, "timer": null,
@ -1998,6 +2013,7 @@ stubPackets.set("console.log('myobject', {red: 'redValue', green: 'greenValue',
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924614, "timeStamp": 1502884924614,
@ -2022,6 +2038,7 @@ stubPackets.set("console.debug('debug message');", {
"groupName": "", "groupName": "",
"level": "debug", "level": "debug",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924621, "timeStamp": 1502884924621,
@ -2046,6 +2063,7 @@ stubPackets.set("console.info('info message');", {
"groupName": "", "groupName": "",
"level": "info", "level": "info",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924625, "timeStamp": 1502884924625,
@ -2070,6 +2088,7 @@ stubPackets.set("console.error('error message');", {
"groupName": "", "groupName": "",
"level": "error", "level": "error",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924628, "timeStamp": 1502884924628,
@ -2125,6 +2144,7 @@ stubPackets.set("console.log('mymap')", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 5, "lineNumber": 5,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924631, "timeStamp": 1502884924631,
@ -2166,6 +2186,7 @@ stubPackets.set("console.log('myset')", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924746, "timeStamp": 1502884924746,
@ -2188,6 +2209,7 @@ stubPackets.set("console.trace()", {
"groupName": "", "groupName": "",
"level": "trace", "level": "trace",
"lineNumber": 3, "lineNumber": 3,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924752, "timeStamp": 1502884924752,
"timer": null, "timer": null,
@ -2232,6 +2254,7 @@ stubPackets.set("console.time('bar')", {
"groupName": "", "groupName": "",
"level": "time", "level": "time",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924757, "timeStamp": 1502884924757,
"timer": { "timer": {
@ -2258,6 +2281,7 @@ stubPackets.set("timerAlreadyExists", {
"groupName": "", "groupName": "",
"level": "time", "level": "time",
"lineNumber": 3, "lineNumber": 3,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924758, "timeStamp": 1502884924758,
"timer": { "timer": {
@ -2285,6 +2309,7 @@ stubPackets.set("console.timeEnd('bar')", {
"groupName": "", "groupName": "",
"level": "timeEnd", "level": "timeEnd",
"lineNumber": 4, "lineNumber": 4,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924759, "timeStamp": 1502884924759,
"timer": { "timer": {
@ -2312,6 +2337,7 @@ stubPackets.set("timerDoesntExist", {
"groupName": "", "groupName": "",
"level": "timeEnd", "level": "timeEnd",
"lineNumber": 5, "lineNumber": 5,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924759, "timeStamp": 1502884924759,
"timer": { "timer": {
@ -2339,6 +2365,7 @@ stubPackets.set("console.table('bar')", {
"groupName": "", "groupName": "",
"level": "table", "level": "table",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924801, "timeStamp": 1502884924801,
"timer": null, "timer": null,
@ -2380,6 +2407,7 @@ stubPackets.set("console.table(['a', 'b', 'c'])", {
"groupName": "", "groupName": "",
"level": "table", "level": "table",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924859, "timeStamp": 1502884924859,
"timer": null, "timer": null,
@ -2404,6 +2432,7 @@ stubPackets.set("console.group('bar')", {
"groupName": "bar", "groupName": "bar",
"level": "group", "level": "group",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924863, "timeStamp": 1502884924863,
@ -2426,6 +2455,7 @@ stubPackets.set("console.groupEnd('bar')", {
"groupName": "bar", "groupName": "bar",
"level": "groupEnd", "level": "groupEnd",
"lineNumber": 3, "lineNumber": 3,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924864, "timeStamp": 1502884924864,
"timer": null, "timer": null,
@ -2450,6 +2480,7 @@ stubPackets.set("console.groupCollapsed('foo')", {
"groupName": "foo", "groupName": "foo",
"level": "groupCollapsed", "level": "groupCollapsed",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924870, "timeStamp": 1502884924870,
@ -2472,6 +2503,7 @@ stubPackets.set("console.groupEnd('foo')", {
"groupName": "foo", "groupName": "foo",
"level": "groupEnd", "level": "groupEnd",
"lineNumber": 3, "lineNumber": 3,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924871, "timeStamp": 1502884924871,
"timer": null, "timer": null,
@ -2494,6 +2526,7 @@ stubPackets.set("console.group()", {
"groupName": "", "groupName": "",
"level": "group", "level": "group",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [], "styles": [],
"timeStamp": 1502884924878, "timeStamp": 1502884924878,
@ -2516,6 +2549,7 @@ stubPackets.set("console.groupEnd()", {
"groupName": "", "groupName": "",
"level": "groupEnd", "level": "groupEnd",
"lineNumber": 3, "lineNumber": 3,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924879, "timeStamp": 1502884924879,
"timer": null, "timer": null,
@ -2541,6 +2575,7 @@ stubPackets.set("console.log(%cfoobar)", {
"groupName": "", "groupName": "",
"level": "log", "level": "log",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [ "styles": [
"color:blue;font-size:1.3em;background:url('http://example.com/test');position:absolute;top:10px", "color:blue;font-size:1.3em;background:url('http://example.com/test');position:absolute;top:10px",
@ -2569,6 +2604,7 @@ stubPackets.set("console.group(%cfoo%cbar)", {
"groupName": "foo bar", "groupName": "foo bar",
"level": "group", "level": "group",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [ "styles": [
"color:blue;font-size:1.3em;background:url('http://example.com/test');position:absolute;top:10px", "color:blue;font-size:1.3em;background:url('http://example.com/test');position:absolute;top:10px",
@ -2594,6 +2630,7 @@ stubPackets.set("console.groupEnd(%cfoo%cbar)", {
"groupName": "foo bar", "groupName": "foo bar",
"level": "groupEnd", "level": "groupEnd",
"lineNumber": 6, "lineNumber": 6,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924887, "timeStamp": 1502884924887,
"timer": null, "timer": null,
@ -2619,6 +2656,7 @@ stubPackets.set("console.groupCollapsed(%cfoo%cbaz)", {
"groupName": "foo baz", "groupName": "foo baz",
"level": "groupCollapsed", "level": "groupCollapsed",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"styles": [ "styles": [
"color:blue;font-size:1.3em;background:url('http://example.com/test');position:absolute;top:10px", "color:blue;font-size:1.3em;background:url('http://example.com/test');position:absolute;top:10px",
@ -2644,6 +2682,7 @@ stubPackets.set("console.groupEnd(%cfoo%cbaz)", {
"groupName": "foo baz", "groupName": "foo baz",
"level": "groupEnd", "level": "groupEnd",
"lineNumber": 6, "lineNumber": 6,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924893, "timeStamp": 1502884924893,
"timer": null, "timer": null,
@ -2709,6 +2748,7 @@ stubPackets.set("console.dir({C, M, Y, K})", {
"groupName": "", "groupName": "",
"level": "dir", "level": "dir",
"lineNumber": 1, "lineNumber": 1,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1502884924899, "timeStamp": 1502884924899,
"timer": null, "timer": null,
@ -2736,6 +2776,7 @@ stubPackets.set("console.count | default: 1", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 2, "lineNumber": 2,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913333, "timeStamp": 1511365913333,
"timer": null, "timer": null,
@ -2763,6 +2804,7 @@ stubPackets.set("console.count | default: 2", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 3, "lineNumber": 3,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913334, "timeStamp": 1511365913334,
"timer": null, "timer": null,
@ -2790,6 +2832,7 @@ stubPackets.set("console.count | test counter: 1", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 4, "lineNumber": 4,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913334, "timeStamp": 1511365913334,
"timer": null, "timer": null,
@ -2817,6 +2860,7 @@ stubPackets.set("console.count | test counter: 2", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 5, "lineNumber": 5,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913334, "timeStamp": 1511365913334,
"timer": null, "timer": null,
@ -2844,6 +2888,7 @@ stubPackets.set("console.count | default: 3", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 6, "lineNumber": 6,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913334, "timeStamp": 1511365913334,
"timer": null, "timer": null,
@ -2866,6 +2911,7 @@ stubPackets.set("console.count | clear", {
"groupName": "", "groupName": "",
"level": "clear", "level": "clear",
"lineNumber": 7, "lineNumber": 7,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913334, "timeStamp": 1511365913334,
"timer": null, "timer": null,
@ -2893,6 +2939,7 @@ stubPackets.set("console.count | default: 4", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 8, "lineNumber": 8,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913335, "timeStamp": 1511365913335,
"timer": null, "timer": null,
@ -2920,6 +2967,7 @@ stubPackets.set("console.count | test counter: 3", {
"groupName": "", "groupName": "",
"level": "count", "level": "count",
"lineNumber": 9, "lineNumber": 9,
"prefix": "",
"private": false, "private": false,
"timeStamp": 1511365913335, "timeStamp": 1511365913335,
"timer": null, "timer": null,

Просмотреть файл

@ -1537,6 +1537,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx,
event.mConsoleID = mConsoleID; event.mConsoleID = mConsoleID;
event.mLevel = aData->mMethodString; event.mLevel = aData->mMethodString;
event.mFilename = frame.mFilename; event.mFilename = frame.mFilename;
event.mPrefix = mPrefix;
nsCOMPtr<nsIURI> filenameURI; nsCOMPtr<nsIURI> filenameURI;
nsAutoCString pass; nsAutoCString pass;
@ -2602,8 +2603,8 @@ Console::MaybeExecuteDumpFunction(JSContext* aCx,
message.Append(aMethodName); message.Append(aMethodName);
message.AppendLiteral(": "); message.AppendLiteral(": ");
if (!mDumpPrefix.IsEmpty()) { if (!mPrefix.IsEmpty()) {
message.Append(mDumpPrefix); message.Append(mPrefix);
message.AppendLiteral(": "); message.AppendLiteral(": ");
} }
@ -2640,8 +2641,8 @@ Console::MaybeExecuteDumpFunctionForTrace(JSContext* aCx, nsIStackFrame* aStack)
nsAutoString message; nsAutoString message;
message.AssignLiteral("console.trace:\n"); message.AssignLiteral("console.trace:\n");
if (!mDumpPrefix.IsEmpty()) { if (!mPrefix.IsEmpty()) {
message.Append(mDumpPrefix); message.Append(mPrefix);
message.AppendLiteral(": "); message.AppendLiteral(": ");
} }

Просмотреть файл

@ -444,7 +444,7 @@ private:
nsString mPassedInnerID; nsString mPassedInnerID;
RefPtr<ConsoleInstanceDumpCallback> mDumpFunction; RefPtr<ConsoleInstanceDumpCallback> mDumpFunction;
bool mDumpToStdout; bool mDumpToStdout;
nsString mDumpPrefix; nsString mPrefix;
bool mChromeInstance; bool mChromeInstance;
ConsoleLogLevel mMaxLogLevel; ConsoleLogLevel mMaxLogLevel;

Просмотреть файл

@ -79,7 +79,7 @@ ConsoleInstance::ConsoleInstance(const ConsoleInstanceOptions& aOptions)
mConsole->mDumpToStdout = true; mConsole->mDumpToStdout = true;
} }
mConsole->mDumpPrefix = aOptions.mPrefix; mConsole->mPrefix = aOptions.mPrefix;
// Let's inform that this is a custom instance. // Let's inform that this is a custom instance.
mConsole->mChromeInstance = true; mConsole->mChromeInstance = true;

Просмотреть файл

@ -38,6 +38,7 @@ consoleListener.prototype = {
is(obj.ID, "jsm", "ID and InnerID are correctly set."); is(obj.ID, "jsm", "ID and InnerID are correctly set.");
is(obj.arguments[0], "Hello world!", "Message matches"); is(obj.arguments[0], "Hello world!", "Message matches");
is(obj.consoleID, "", "No consoleID for console API"); is(obj.consoleID, "", "No consoleID for console API");
is(obj.prefix, "", "prefix is empty by default");
// We want to see 2 messages from this innerID, the first is generated // We want to see 2 messages from this innerID, the first is generated
// by console.log, the second one from createInstance().log(); // by console.log, the second one from createInstance().log();
@ -46,11 +47,13 @@ consoleListener.prototype = {
is(obj.ID, "jsm", "ID and InnerID are correctly set."); is(obj.ID, "jsm", "ID and InnerID are correctly set.");
is(obj.arguments[0], "Hello world!", "Message matches"); is(obj.arguments[0], "Hello world!", "Message matches");
is(obj.consoleID, "wow", "consoleID is set by consoleInstance"); is(obj.consoleID, "wow", "consoleID is set by consoleInstance");
is(obj.prefix, "_PREFIX_", "prefix is set by consoleInstance");
++this.count; ++this.count;
} else if (obj.innerID == "LEVEL") { } else if (obj.innerID == "LEVEL") {
// Nothing special... just we don't want to see 'invisible' messages. // Nothing special... just we don't want to see 'invisible' messages.
is(obj.ID, "jsm", "ID and InnerID are correctly set."); is(obj.ID, "jsm", "ID and InnerID are correctly set.");
is(obj.arguments[0], "Hello world!", "Message matches"); is(obj.arguments[0], "Hello world!", "Message matches");
is(obj.prefix, "", "prefix is empty by default");
++this.count; ++this.count;
} }

Просмотреть файл

@ -78,6 +78,7 @@ dictionary ConsoleEvent {
DOMString groupName = ""; DOMString groupName = "";
any timer = null; any timer = null;
any counter = null; any counter = null;
DOMString prefix = "";
}; };
// Event for profile operations // Event for profile operations