Bug 1480544 - Allow Console API to log messages on stdout, r=bgrins

This patch introduces 2 new prefs:
- devtools.console.stdout.chrome: if true, console API writes on stdout when
                                  used by chrome code
- devtools.console.stdout.content: console API write on stdout when used by
                                   content code.
This commit is contained in:
Andrea Marchesini 2018-11-15 21:47:58 +01:00
Родитель 505d7f9d3c
Коммит c0950f9d8a
16 изменённых файлов: 45 добавлений и 6 удалений

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

@ -104,6 +104,7 @@ function setPrefDefaults() {
Services.prefs.setBoolPref("devtools.performance.ui.show-platform-data", true);
Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true);
Services.prefs.setBoolPref("browser.dom.window.dump.enabled", true);
Services.prefs.setBoolPref("devtools.console.stdout.chrome", true);
Services.prefs.setBoolPref("devtools.command-button-noautohide.enabled", true);
// Bug 1225160 - Using source maps with browser debugging can lead to a crash
Services.prefs.setBoolPref("devtools.debugger.source-maps-enabled", false);

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

@ -29,6 +29,8 @@ You can change the value of these preferences by going to `about:config`:
| Preference name | Value | Comments |
| --------------- | --------------- | -------- |
| `browser.dom.window.dump.enabled` | `true` | Adds global `dump` function to log strings to `stdout` |
| `devtools.console.stdout.chrome` | `true` | Allows console API to write to `stdout` when used by chrome content |
| `devtools.console.stdout.content` | `true` | Allows console API to write to `stdout` when used by content |
| `devtools.debugger.log` (*) | `true` | Dump packets sent over remote debugging protocol to `stdout`.<br /><br />The [remote protocol inspector add-on](https://github.com/firebug/rdp-inspector/wiki) might be useful too. |
| `devtools.dump.emit` (*) | `true` | Log event notifications from the EventEmitter class<br />(found at `devtools/shared/event-emitter.js`). |

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

@ -1093,7 +1093,9 @@ Console::Console(JSContext* aCx, nsIGlobalObject* aGlobal,
{
// Let's enable the dumping to stdout by default for chrome.
if (nsContentUtils::ThreadsafeIsSystemCaller(aCx)) {
mDumpToStdout = DOMPrefs::DumpEnabled();
mDumpToStdout = StaticPrefs::devtools_console_stdout_chrome();
} else {
mDumpToStdout = StaticPrefs::devtools_console_stdout_content();
}
mozilla::HoldJSObjects(this);

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

@ -1,3 +1,4 @@
pref("toolkit.defaultChromeURI", "chrome://mybrowser/content/hello.xul");
pref("browser.dom.window.dump.enabled", true);
pref("devtools.console.stdout.chrome", true);
pref("dom.max_script_run_time", 0);

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

@ -1,5 +1,6 @@
user_pref("app.update.disabledForTesting", true);
user_pref("browser.dom.window.dump.enabled", true);
user_pref("devtools.console.stdout.chrome", true);
user_pref("browser.sessionstore.resume_from_crash", false);
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("browser.xul.error_pages.enabled", true);

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

@ -1291,6 +1291,7 @@ XRE_XPCShellMain(int argc, char** argv, char** envp,
// xpc::ErrorReport::LogToConsoleWithStack needs this to print errors
// to stderr.
Preferences::SetBool("browser.dom.window.dump.enabled", true);
Preferences::SetBool("devtools.console.stdout.chrome", true);
AutoJSAPI jsapi;
jsapi.Init();

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

@ -394,8 +394,9 @@ that do not depend on XUL, or even ones testing other layout engines.
Running Tests
=============
(If you're not using a DEBUG build, first set browser.dom.window.dump.enabled
to true (in about:config, in the profile you'll be using to run the tests).
(If you're not using a DEBUG build, first set browser.dom.window.dump.enabled,
devtools.console.stdout.chrome and devtools.console.stdout.content to true (in
about:config, in the profile you'll be using to run the tests).
Create the option as a new boolean if it doesn't exist already. If you skip
this step you won't get any output in the terminal.)

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

@ -623,6 +623,7 @@ pref("browser.firstrun.show.localepicker", false);
// $ adb shell setprop log.redirect-stdio true
// $ adb shell start
pref("browser.dom.window.dump.enabled", true);
pref("devtools.console.stdout.chrome", true);
// controls if we want camera support
pref("device.camera.enabled", true);

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

@ -1776,6 +1776,24 @@ VARCACHE_PREF(
RelaxedAtomicBool, false
)
#ifdef MOZILLA_OFFICIAL
# define PREF_VALUE false
#else
# define PREF_VALUE true
#endif
VARCACHE_PREF(
"devtools.console.stdout.chrome",
devtools_console_stdout_chrome,
RelaxedAtomicBool, PREF_VALUE
)
#undef PREF_VALUE
VARCACHE_PREF(
"devtools.console.stdout.content",
devtools_console_stdout_content,
RelaxedAtomicBool, false
)
//---------------------------------------------------------------------------
// Feature-Policy prefs
//---------------------------------------------------------------------------

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

@ -1096,10 +1096,14 @@ pref("toolkit.asyncshutdown.log", false);
// it being specified, dump is disabled in artifact builds (see Bug 1490412).
#ifdef MOZILLA_OFFICIAL
pref("browser.dom.window.dump.enabled", false, sticky);
pref("devtools.console.stdout.chrome", false, sticky);
#else
pref("browser.dom.window.dump.enabled", true, sticky);
pref("devtools.console.stdout.chrome", true, sticky);
#endif
pref("devtools.console.stdout.content", false, sticky);
// Controls whether EventEmitter module throws dump message on each emit
pref("toolkit.dump.emit", false);

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

@ -118,6 +118,7 @@ SpecialPowers.pushPrefEnv({"set": [
["identity.fxaccounts.enabled", true], // fx accounts
["identity.fxaccounts.auth.uri", TEST_SERVER], // our sjs server
["browser.dom.window.dump.enabled", true],
["devtools.console.stdout.chrome", true],
]},
function() { runTest(); }
);

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

@ -18,6 +18,7 @@ lazy_static! {
// Enable the dump function, which sends messages to the system
// console
("browser.dom.window.dump.enabled", Pref::new(true)),
("devtools.console.stdout.chrome", Pref::new(true)),
// Disable safebrowsing components
("browser.safebrowsing.blockedURIs.enabled", Pref::new(false)),

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

@ -376,8 +376,9 @@ class GeckoInstance(object):
class FennecInstance(GeckoInstance):
fennec_prefs = {
# Enable output of dump()
# Enable output for dump() and chrome console API
"browser.dom.window.dump.enabled": True,
"devtools.console.stdout.chrome": True,
# Disable Android snippets
"browser.snippets.enabled": False,
@ -504,8 +505,9 @@ class DesktopInstance(GeckoInstance):
# We use a larger number than the default 22 to have some buffer
"browser.contentblocking.introCount": 99,
# Enable output of dump()
# Enable output for dump() and chrome console API
"browser.dom.window.dump.enabled": True,
"devtools.console.stdout.chrome": True,
# Indicate that the download panel has been shown once so that whichever
# download test runs first doesn"t show the popup inconsistently

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

@ -3,6 +3,7 @@
user_pref("app.update.disabledForTesting", true);
user_pref("browser.chrome.guess_favicon", false);
user_pref("browser.dom.window.dump.enabled", true);
user_pref("devtools.console.stdout.chrome", true);
// Use a python-eval-able empty JSON array even though asrouter expects plain object
user_pref("browser.newtabpage.activity-stream.asrouter.providers.snippets", "[]");
user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);

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

@ -59,6 +59,7 @@ class TPSTestRunner(object):
'app.update.disabledForTesting': True,
'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True,
'browser.dom.window.dump.enabled': True,
'devtools.console.stdout.chrome': True,
'browser.sessionstore.resume_from_crash': False,
'browser.shell.checkDefaultBrowser': False,
'browser.tabs.warnOnClose': False,

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

@ -39,8 +39,9 @@ class FennecProfile(FirefoxProfile):
"app.normandy.api_url": "",
# Increase the APZ content response timeout in tests to 1 minute.
"apz.content_response_timeout": 60000,
# Enable output of dump()
# Enable output for dump() and chrome console API
"browser.dom.window.dump.enabled": True,
"devtools.console.stdout.chrome": True,
# Disable safebrowsing components
"browser.safebrowsing.blockedURIs.enabled": False,
"browser.safebrowsing.downloads.enabled": False,