diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-05-07 07:23:21 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-05-07 07:23:21 +0200 |
commit | 1b0c4bf4626489c650becfee19fe50be4ee0852b (patch) | |
tree | 431b1c361d2e8e23457a0ed75c2caf32e1ec3a02 /devtools | |
parent | 7d5f95a8e57de5255ad2767342c1f2392b6f261f (diff) | |
download | uxp-1b0c4bf4626489c650becfee19fe50be4ee0852b.tar.gz |
[regression] DevTools - Web and Browser console - Added "Log request and response bodies" preference
Issue #102
Diffstat (limited to 'devtools')
-rw-r--r-- | devtools/client/locales/en-US/webConsole.dtd | 5 | ||||
-rw-r--r-- | devtools/client/preferences/devtools.js | 2 | ||||
-rw-r--r-- | devtools/client/webconsole/webconsole.js | 45 | ||||
-rw-r--r-- | devtools/client/webconsole/webconsole.xul | 4 |
4 files changed, 48 insertions, 8 deletions
diff --git a/devtools/client/locales/en-US/webConsole.dtd b/devtools/client/locales/en-US/webConsole.dtd index 17ae026992..7c81ee7e3f 100644 --- a/devtools/client/locales/en-US/webConsole.dtd +++ b/devtools/client/locales/en-US/webConsole.dtd @@ -11,6 +11,11 @@ <!ENTITY window.title "Web Console"> <!ENTITY browserConsole.title "Browser Console"> +<!-- LOCALIZATION NOTE (saveBodies.label): You can see this string in + - the Browser Console context menu. --> +<!ENTITY saveBodies.label "Log Request and Response Bodies"> +<!ENTITY saveBodies.accesskey "L"> + <!-- LOCALIZATION NOTE (openURL.label): You can see this string in the Web - Console context menu. --> <!ENTITY openURL.label "Open URL in New Tab"> diff --git a/devtools/client/preferences/devtools.js b/devtools/client/preferences/devtools.js index 9de9cd34ae..2f6ca21049 100644 --- a/devtools/client/preferences/devtools.js +++ b/devtools/client/preferences/devtools.js @@ -248,6 +248,7 @@ pref("devtools.webconsole.filter.log", true); pref("devtools.webconsole.filter.debug", true); pref("devtools.webconsole.filter.net", false); pref("devtools.webconsole.filter.netxhr", false); +pref("devtools.webconsole.filter.saveBodies", true); // Deprecated - old console frontend pref("devtools.webconsole.filter.network", true); pref("devtools.webconsole.filter.networkinfo", false); @@ -273,6 +274,7 @@ pref("devtools.browserconsole.filter.network", true); pref("devtools.browserconsole.filter.networkinfo", false); pref("devtools.browserconsole.filter.netwarn", true); pref("devtools.browserconsole.filter.netxhr", false); +pref("devtools.browserconsole.filter.saveBodies", false); pref("devtools.browserconsole.filter.csserror", true); pref("devtools.browserconsole.filter.cssparser", false); pref("devtools.browserconsole.filter.csslog", false); diff --git a/devtools/client/webconsole/webconsole.js b/devtools/client/webconsole/webconsole.js index bd7f90a0ec..f2031f18a8 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 1310fb57db..36f9f03bf2 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" |