diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-05-07 11:39:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-07 11:39:29 +0200 |
commit | 43208a5308f2ac64416d6c962d922776bb664431 (patch) | |
tree | f55ed4554e0a4999edefb08e3e4f4e27e24160ef /devtools/client/webconsole | |
parent | 5390888b97ecbd4135049c0b4a2ae0b103052a4a (diff) | |
parent | 1b0c4bf4626489c650becfee19fe50be4ee0852b (diff) | |
download | UXP-43208a5308f2ac64416d6c962d922776bb664431.tar UXP-43208a5308f2ac64416d6c962d922776bb664431.tar.gz UXP-43208a5308f2ac64416d6c962d922776bb664431.tar.lz UXP-43208a5308f2ac64416d6c962d922776bb664431.tar.xz UXP-43208a5308f2ac64416d6c962d922776bb664431.zip |
Merge pull request #337 from janekptacijarabaci/devtools_browserconsole_bodies_1
[regression] DevTools - Web and Browser console - Added "Log request and response bodies" preference
Diffstat (limited to 'devtools/client/webconsole')
-rw-r--r-- | devtools/client/webconsole/webconsole.js | 45 | ||||
-rw-r--r-- | devtools/client/webconsole/webconsole.xul | 4 |
2 files changed, 41 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); diff --git a/devtools/client/webconsole/webconsole.xul b/devtools/client/webconsole/webconsole.xul index 1310fb57d..36f9f03bf 100644 --- a/devtools/client/webconsole/webconsole.xul +++ b/devtools/client/webconsole/webconsole.xul @@ -96,6 +96,10 @@ function goUpdateConsoleCommands() { prefKey="netxhr"/> <menuitem label="&btnConsoleLog;" type="checkbox" autocheck="false" prefKey="networkinfo"/> + <menuseparator id="saveBodiesSeparator" /> + <menuitem id="saveBodies" type="checkbox" label="&saveBodies.label;" + accesskey="&saveBodies.accesskey;" autocheck="false" + prefKey="saveBodies"/> </menupopup> </toolbarbutton> <toolbarbutton label="&btnPageCSS.label;" type="menu-button" |