mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1159929 - Cache the pref value for devtools.dump.emit in event emitter;r=fitzgen
This commit is contained in:
parent
c7e0b742a2
commit
89e2259a7f
@ -25,6 +25,16 @@ module.exports = EventEmitter;
|
||||
const { Cu, components } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const promise = require("promise");
|
||||
let loggingEnabled = true;
|
||||
|
||||
if (!isWorker) {
|
||||
loggingEnabled = Services.prefs.getBoolPref("devtools.dump.emit");
|
||||
Services.prefs.addObserver("devtools.dump.emit", {
|
||||
observe: () => {
|
||||
loggingEnabled = Services.prefs.getBoolPref("devtools.dump.emit");
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate an object with event emitter functionality.
|
||||
@ -147,60 +157,60 @@ EventEmitter.prototype = {
|
||||
},
|
||||
|
||||
logEvent: function(aEvent, args) {
|
||||
let logging = isWorker ? true : Services.prefs.getBoolPref("devtools.dump.emit");
|
||||
|
||||
if (logging) {
|
||||
let caller, func, path;
|
||||
if (!isWorker) {
|
||||
caller = components.stack.caller.caller;
|
||||
func = caller.name;
|
||||
let file = caller.filename;
|
||||
if (file.includes(" -> ")) {
|
||||
file = caller.filename.split(/ -> /)[1];
|
||||
}
|
||||
path = file + ":" + caller.lineNumber;
|
||||
}
|
||||
|
||||
let argOut = "(";
|
||||
if (args.length === 1) {
|
||||
argOut += aEvent;
|
||||
}
|
||||
|
||||
let out = "EMITTING: ";
|
||||
|
||||
// We need this try / catch to prevent any dead object errors.
|
||||
try {
|
||||
for (let i = 1; i < args.length; i++) {
|
||||
if (i === 1) {
|
||||
argOut = "(" + aEvent + ", ";
|
||||
} else {
|
||||
argOut += ", ";
|
||||
}
|
||||
|
||||
let arg = args[i];
|
||||
argOut += arg;
|
||||
|
||||
if (arg && arg.nodeName) {
|
||||
argOut += " (" + arg.nodeName;
|
||||
if (arg.id) {
|
||||
argOut += "#" + arg.id;
|
||||
}
|
||||
if (arg.className) {
|
||||
argOut += "." + arg.className;
|
||||
}
|
||||
argOut += ")";
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
// Object is dead so the toolbox is most likely shutting down,
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
argOut += ")";
|
||||
out += "emit" + argOut + " from " + func + "() -> " + path + "\n";
|
||||
|
||||
dump(out);
|
||||
if (!loggingEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
let caller, func, path;
|
||||
if (!isWorker) {
|
||||
caller = components.stack.caller.caller;
|
||||
func = caller.name;
|
||||
let file = caller.filename;
|
||||
if (file.includes(" -> ")) {
|
||||
file = caller.filename.split(/ -> /)[1];
|
||||
}
|
||||
path = file + ":" + caller.lineNumber;
|
||||
}
|
||||
|
||||
let argOut = "(";
|
||||
if (args.length === 1) {
|
||||
argOut += aEvent;
|
||||
}
|
||||
|
||||
let out = "EMITTING: ";
|
||||
|
||||
// We need this try / catch to prevent any dead object errors.
|
||||
try {
|
||||
for (let i = 1; i < args.length; i++) {
|
||||
if (i === 1) {
|
||||
argOut = "(" + aEvent + ", ";
|
||||
} else {
|
||||
argOut += ", ";
|
||||
}
|
||||
|
||||
let arg = args[i];
|
||||
argOut += arg;
|
||||
|
||||
if (arg && arg.nodeName) {
|
||||
argOut += " (" + arg.nodeName;
|
||||
if (arg.id) {
|
||||
argOut += "#" + arg.id;
|
||||
}
|
||||
if (arg.className) {
|
||||
argOut += "." + arg.className;
|
||||
}
|
||||
argOut += ")";
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
// Object is dead so the toolbox is most likely shutting down,
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
argOut += ")";
|
||||
out += "emit" + argOut + " from " + func + "() -> " + path + "\n";
|
||||
|
||||
dump(out);
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user