Bug 1634779 - pt 2. Partially revert Bug 1603006 r=kmag
[gecko.git] / dom / webidl / Console.webidl
blobfbec19a870e288b048483fffed6cca5cc09bbbaa
1 /* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  *
7  * For more information on this interface, please see
8  * https://console.spec.whatwg.org/#console-namespace
9  */
11 [Exposed=(Window,Worker,WorkerDebugger,Worklet),
12  ClassString="Console",
13  ProtoObjectHack]
14 namespace console {
16   // NOTE: if you touch this namespace, remember to update the ConsoleInstance
17   // interface as well!
19   // Logging
20   [UseCounter]
21   void assert(optional boolean condition = false, any... data);
22   [UseCounter]
23   void clear();
24   [UseCounter]
25   void count(optional DOMString label = "default");
26   [UseCounter]
27   void countReset(optional DOMString label = "default");
28   [UseCounter]
29   void debug(any... data);
30   [UseCounter]
31   void error(any... data);
32   [UseCounter]
33   void info(any... data);
34   [UseCounter]
35   void log(any... data);
36   [UseCounter]
37   void table(any... data); // FIXME: The spec is still unclear about this.
38   [UseCounter]
39   void trace(any... data);
40   [UseCounter]
41   void warn(any... data);
42   [UseCounter]
43   void dir(any... data); // FIXME: This doesn't follow the spec yet.
44   [UseCounter]
45   void dirxml(any... data);
47   // Grouping
48   [UseCounter]
49   void group(any... data);
50   [UseCounter]
51   void groupCollapsed(any... data);
52   [UseCounter]
53   void groupEnd();
55   // Timing
56   [UseCounter]
57   void time(optional DOMString label = "default");
58   [UseCounter]
59   void timeLog(optional DOMString label = "default", any... data);
60   [UseCounter]
61   void timeEnd(optional DOMString label = "default");
63   // Mozilla only or Webcompat methods
65   [UseCounter]
66   void _exception(any... data);
67   [UseCounter]
68   void timeStamp(optional any data);
70   [UseCounter]
71   void profile(any... data);
72   [UseCounter]
73   void profileEnd(any... data);
75   [ChromeOnly]
76   const boolean IS_NATIVE_CONSOLE = true;
78   [ChromeOnly, NewObject]
79   ConsoleInstance createInstance(optional ConsoleInstanceOptions options = {});
82 // This is used to propagate console events to the observers.
83 [GenerateConversionToJS]
84 dictionary ConsoleEvent {
85   (unsigned long long or DOMString) ID;
86   (unsigned long long or DOMString) innerID;
87   DOMString consoleID = "";
88   DOMString addonId = "";
89   DOMString level = "";
90   DOMString filename = "";
91   // Unique identifier within the process for the script source this event is
92   // associated with, or zero.
93   unsigned long sourceId = 0;
94   unsigned long lineNumber = 0;
95   unsigned long columnNumber = 0;
96   DOMString functionName = "";
97   double timeStamp = 0;
98   sequence<any> arguments;
99   sequence<DOMString?> styles;
100   boolean private = false;
101   // stacktrace is handled via a getter in some cases so we can construct it
102   // lazily.  Note that we're not making this whole thing an interface because
103   // consumers expect to see own properties on it, which would mean making the
104   // props unforgeable, which means lots of JSFunction allocations.  Maybe we
105   // should fix those consumers, of course....
106   // sequence<ConsoleStackEntry> stacktrace;
107   DOMString groupName = "";
108   any timer = null;
109   any counter = null;
110   DOMString prefix = "";
111   boolean chromeContext = false;
114 // Event for profile operations
115 [GenerateConversionToJS]
116 dictionary ConsoleProfileEvent {
117   DOMString action = "";
118   sequence<any> arguments;
119   boolean chromeContext = false;
122 // This dictionary is used to manage stack trace data.
123 [GenerateConversionToJS]
124 dictionary ConsoleStackEntry {
125   DOMString filename = "";
126   // Unique identifier within the process for the script source this entry is
127   // associated with, or zero.
128   unsigned long sourceId = 0;
129   unsigned long lineNumber = 0;
130   unsigned long columnNumber = 0;
131   DOMString functionName = "";
132   DOMString? asyncCause;
135 [GenerateConversionToJS]
136 dictionary ConsoleTimerStart {
137   DOMString name = "";
140 [GenerateConversionToJS]
141 dictionary ConsoleTimerLogOrEnd {
142   DOMString name = "";
143   double duration = 0;
146 [GenerateConversionToJS]
147 dictionary ConsoleTimerError {
148   DOMString error = "";
149   DOMString name = "";
152 [GenerateConversionToJS]
153 dictionary ConsoleCounter {
154   DOMString label = "";
155   unsigned long count = 0;
158 [GenerateConversionToJS]
159 dictionary ConsoleCounterError {
160   DOMString label = "";
161   DOMString error = "";
164 [ChromeOnly,
165  Exposed=(Window,Worker,WorkerDebugger,Worklet)]
166 // This is basically a copy of the console namespace.
167 interface ConsoleInstance {
168   // Logging
169   void assert(optional boolean condition = false, any... data);
170   void clear();
171   void count(optional DOMString label = "default");
172   void countReset(optional DOMString label = "default");
173   void debug(any... data);
174   void error(any... data);
175   void info(any... data);
176   void log(any... data);
177   void table(any... data); // FIXME: The spec is still unclear about this.
178   void trace(any... data);
179   void warn(any... data);
180   void dir(any... data); // FIXME: This doesn't follow the spec yet.
181   void dirxml(any... data);
183   // Grouping
184   void group(any... data);
185   void groupCollapsed(any... data);
186   void groupEnd();
188   // Timing
189   void time(optional DOMString label = "default");
190   void timeLog(optional DOMString label = "default", any... data);
191   void timeEnd(optional DOMString label = "default");
193   // Mozilla only or Webcompat methods
195   void _exception(any... data);
196   void timeStamp(optional any data);
198   void profile(any... data);
199   void profileEnd(any... data);
202 callback ConsoleInstanceDumpCallback = void (DOMString message);
204 enum ConsoleLogLevel {
205   "All", "Debug", "Log", "Info", "Clear", "Trace", "TimeLog", "TimeEnd", "Time",
206   "Group", "GroupEnd", "Profile", "ProfileEnd", "Dir", "Dirxml", "Warn", "Error",
207   "Off"
210 dictionary ConsoleInstanceOptions {
211   // An optional function to intercept all strings written to stdout.
212   ConsoleInstanceDumpCallback dump;
214   // An optional prefix string to be printed before the actual logged message.
215   DOMString prefix = "";
217   // An ID representing the source of the message. Normally the inner ID of a
218   // DOM window.
219   DOMString innerID = "";
221   // String identified for the console, this will be passed through the console
222   // notifications.
223   DOMString consoleID = "";
225   // Identifier that allows to filter which messages are logged based on their
226   // log level.
227   ConsoleLogLevel maxLogLevel;
229   // String pref name which contains the level to use for maxLogLevel. If the
230   // pref doesn't exist, gets removed or it is used in workers, the maxLogLevel
231   // will default to the value passed to this constructor (or "all" if it wasn't
232   // specified).
233   DOMString maxLogLevelPref = "";
236 enum ConsoleLevel { "log", "warning", "error" };
238 // this interface is just for testing
239 partial interface ConsoleInstance {
240   [ChromeOnly]
241   void reportForServiceWorkerScope(DOMString scope, DOMString message,
242                                    DOMString filename, unsigned long lineNumber,
243                                    unsigned long columnNumber,
244                                    ConsoleLevel level);