1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* This module controls various global flags that can be toggled on and off.
* These flags are generally used to change the behavior of the code during
* testing. They are tracked by preferences so that they are propagated
* between the parent and content processes. The flags are exposed via a module
* as a conveniene and to stop from littering preference names throughout the
* code ase.
*
* Each of the flags is documented where it is defined.
*/
/**
* We cannot make a normal property writeable on `exports` because
* the module system freezes it. This function observes a preference
* and provides the latest value through a getter.
*/
function makePrefTrackedFlag(exports, name, pref) {
let flag;
// We don't have access to pref in worker, so disable all logs by default
if (isWorker) {
flag = false;
} else {
flag = Services.prefs.getBoolPref(pref, false);
const prefObserver = () => {
flag = Services.prefs.getBoolPref(pref, false);
};
Services.prefs.addObserver(pref, prefObserver);
// Also listen for Loader unload to unregister the pref observer and prevent leaking
const unloadObserver = function (subject) {
if (subject.wrappedJSObject == require("@loader/unload")) {
Services.prefs.removeObserver(pref, prefObserver);
Services.obs.removeObserver(unloadObserver, "devtools:loader:destroy");
}
};
Services.obs.addObserver(unloadObserver, "devtools:loader:destroy");
}
Object.defineProperty(exports, name, {
get() {
return flag;
},
});
}
/**
* Setting the "devtools.debugger.log" preference to true will enable logging of
* the RDP calls to the devtools server.
*/
makePrefTrackedFlag(exports, "wantLogging", "devtools.debugger.log");
/**
* Setting the "devtools.debugger.log.verbose" preference to true will enable a
* more verbose logging of the the RDP. The "devtools.debugger.log" preference
* must be set to true as well for this to have any effect.
*/
makePrefTrackedFlag(exports, "wantVerbose", "devtools.debugger.log.verbose");
/**
* Setting the "devtools.testing" preference to true will toggle on certain
* behaviors that can differ from the production version of the code. These
* behaviors typically enable easier testing or enhanced debugging features.
*/
makePrefTrackedFlag(exports, "testing", "devtools.testing");
|