summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/webconsole.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-05-07 07:23:21 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-05-07 07:23:21 +0200
commit1b0c4bf4626489c650becfee19fe50be4ee0852b (patch)
tree431b1c361d2e8e23457a0ed75c2caf32e1ec3a02 /devtools/client/webconsole/webconsole.js
parent7d5f95a8e57de5255ad2767342c1f2392b6f261f (diff)
downloadUXP-1b0c4bf4626489c650becfee19fe50be4ee0852b.tar
UXP-1b0c4bf4626489c650becfee19fe50be4ee0852b.tar.gz
UXP-1b0c4bf4626489c650becfee19fe50be4ee0852b.tar.lz
UXP-1b0c4bf4626489c650becfee19fe50be4ee0852b.tar.xz
UXP-1b0c4bf4626489c650becfee19fe50be4ee0852b.zip
[regression] DevTools - Web and Browser console - Added "Log request and response bodies" preference
Issue #102
Diffstat (limited to 'devtools/client/webconsole/webconsole.js')
-rw-r--r--devtools/client/webconsole/webconsole.js45
1 files changed, 37 insertions, 8 deletions
diff --git a/devtools/client/webconsole/webconsole.js b/devtools/client/webconsole/webconsole.js
index bd7f90a0e..f2031f18a 100644
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -555,6 +555,19 @@ WebConsoleFrame.prototype = {
// calculations.
this._updateCharSize();
+ let saveBodiesDisabled = !this.getFilterState("networkinfo") &&
+ !this.getFilterState("netxhr") &&
+ !this.getFilterState("network");
+
+ let saveBodies = this.document.getElementById("saveBodies");
+ saveBodies.disabled = saveBodiesDisabled;
+
+ saveBodies.parentNode.addEventListener("popupshowing", () => {
+ saveBodies.disabled = !this.getFilterState("networkinfo") &&
+ !this.getFilterState("netxhr") &&
+ !this.getFilterState("network");
+ });
+
this.jsterm = new JSTerm(this);
this.jsterm.init();
@@ -684,9 +697,9 @@ WebConsoleFrame.prototype = {
_initDefaultFilterPrefs: function () {
let prefs = ["network", "networkinfo", "csserror", "cssparser", "csslog",
"exception", "jswarn", "jslog", "error", "info", "warn", "log",
- "secerror", "secwarn", "netwarn", "netxhr", "sharedworkers",
- "serviceworkers", "windowlessworkers", "servererror",
- "serverwarn", "serverinfo", "serverlog"];
+ "secerror", "secwarn", "netwarn", "netxhr", "saveBodies",
+ "sharedworkers", "serviceworkers", "windowlessworkers",
+ "servererror", "serverwarn", "serverinfo", "serverlog"];
for (let pref of prefs) {
this.filterPrefs[pref] = Services.prefs.getBoolPref(
@@ -954,6 +967,16 @@ WebConsoleFrame.prototype = {
let prefKey = target.getAttribute("prefKey");
this.setFilterState(prefKey, state);
+ // Disable the log response and request body if network logging is off.
+ if (prefKey == "networkinfo" ||
+ prefKey == "netxhr" ||
+ prefKey == "network") {
+ let checkState = !this.getFilterState("networkinfo") &&
+ !this.getFilterState("netxhr") &&
+ !this.getFilterState("network");
+ this.document.getElementById("saveBodies").disabled = checkState;
+ }
+
// Adjust the state of the button appropriately.
let menuPopup = target.parentNode;
@@ -987,9 +1010,12 @@ WebConsoleFrame.prototype = {
_setMenuState: function (target, state) {
let menuItems = target.querySelectorAll("menuitem");
Array.forEach(menuItems, (item) => {
- item.setAttribute("checked", state);
let prefKey = item.getAttribute("prefKey");
- this.setFilterState(prefKey, state);
+ // If not a separate switch only.
+ if (prefKey != "saveBodies") {
+ item.setAttribute("checked", state);
+ this.setFilterState(prefKey, state);
+ }
});
},
@@ -1006,6 +1032,10 @@ WebConsoleFrame.prototype = {
Services.prefs.setBoolPref(this._filterPrefsPrefix + toggleType, state);
+ if (toggleType == "saveBodies") {
+ this.setSaveRequestAndResponseBodies(state);
+ }
+
if (this._updateListenersTimeout) {
clearTimeout(this._updateListenersTimeout);
}
@@ -3245,9 +3275,8 @@ WebConsoleConnectionProxy.prototype = {
this.webConsoleClient = webConsoleClient;
this._hasNativeConsoleAPI = response.nativeConsoleAPI;
- // There is no way to view response bodies from the Browser Console, so do
- // not waste the memory.
- let saveBodies = !this.webConsoleFrame.isBrowserConsole;
+ let saveBodiesPref = this.webConsoleFrame._filterPrefsPrefix + "saveBodies";
+ let saveBodies = Services.prefs.getBoolPref(saveBodiesPref);
this.webConsoleFrame.setSaveRequestAndResponseBodies(saveBodies);
this.webConsoleClient.on("networkEvent", this._onNetworkEvent);