Backed out 2 changesets (bug 1827651) for causing TestAUSHelper related bustages...
[gecko.git] / xpcom / base / nsIConsoleService.idl
blob0d20b678d0de6045a70e71a67d95897dd38e54d1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.idl"
8 interface nsIConsoleListener;
9 interface nsIConsoleMessage;
11 [scriptable, builtinclass, uuid(0eb81d20-c37e-42d4-82a8-ca9ae96bdf52)]
12 interface nsIConsoleService : nsISupports
14 void logMessage(in nsIConsoleMessage message);
16 // This helper function executes `func` and redirects any exception
17 // that may be thrown while running it to the DevTools Console currently
18 // debugging `targetGlobal`.
20 // This helps flag the nsIScriptError with a particular innerWindowID
21 // which is especially useful for WebExtension content scripts
22 // where script are running in a Sandbox whose prototype is the content window.
23 // We expect content script exception to be flaged with the content window
24 // innerWindowID in order to appear in the tab's DevTools.
25 [implicit_jscontext]
26 jsval callFunctionAndLogException(in jsval targetGlobal, in jsval func);
28 // This is a variant of LogMessage which allows the caller to determine
29 // if the message should be output to an OS-specific log. This is used on
30 // B2G to control whether the message is logged to the android log or not.
31 cenum OutputMode : 8 {
32 SuppressLog = 0,
33 OutputToLog
35 void logMessageWithMode(in nsIConsoleMessage message,
36 in nsIConsoleService_OutputMode mode);
38 /**
39 * Convenience method for logging simple messages.
41 void logStringMessage(in wstring message);
43 /**
44 * Get an array of all the messages logged so far.
46 Array<nsIConsoleMessage> getMessageArray();
48 /**
49 * To guard against stack overflows from listeners that could log
50 * messages (it's easy to do this inadvertently from listeners
51 * implemented in JavaScript), we don't call any listeners when
52 * another error is already being logged.
54 void registerListener(in nsIConsoleListener listener);
56 /**
57 * Each registered listener should also be unregistered.
59 void unregisterListener(in nsIConsoleListener listener);
61 /**
62 * Clear the message buffer (e.g. for privacy reasons).
64 void reset();
66 /**
67 * Clear the message buffer for a given window.
69 void resetWindow(in uint64_t windowInnerId);
73 %{ C++
74 #define NS_CONSOLESERVICE_CID \
75 { 0x7e3ff85c, 0x1dd2, 0x11b2, { 0x8d, 0x4b, 0xeb, 0x45, 0x2c, 0xb0, 0xff, 0x40 }}
77 #define NS_CONSOLESERVICE_CONTRACTID "@mozilla.org/consoleservice;1"