Bug 972655 - Console should show XMLHttpRequests - Add XHR filter to webconsole. r=past
authorIan Moody <moz-ian@perix.co.uk>
Wed, 21 Jan 2015 10:39:45 -0800
changeset 224892 ee5109a2d1b469a70212c8e76215f4a8cfd7ad21
parent 224891 5a4d0f82563fe23099e4494dd03cc1670c718d55
child 224893 39c78d4281d5793ed51941c6a6d652d6b1fac3ac
push id10919
push usermozilla@noorenberghe.ca
push dateWed, 21 Jan 2015 18:40:10 +0000
treeherderfx-team@ee5109a2d1b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs972655
milestone38.0a1
Bug 972655 - Console should show XMLHttpRequests - Add XHR filter to webconsole. r=past
browser/app/profile/firefox.js
browser/devtools/webconsole/test/browser.ini
browser/devtools/webconsole/test/browser_console.js
browser/devtools/webconsole/test/browser_webconsole_bug_622303_persistent_filters.js
browser/devtools/webconsole/test/browser_webconsole_bug_632817.js
browser/devtools/webconsole/webconsole.js
browser/devtools/webconsole/webconsole.xul
browser/locales/en-US/chrome/browser/devtools/webConsole.dtd
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1491,16 +1491,17 @@ pref("devtools.gcli.eagerHelper", 2);
 pref("devtools.gcli.jquerySrc", "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js");
 pref("devtools.gcli.lodashSrc", "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js");
 pref("devtools.gcli.underscoreSrc", "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js");
 
 // Remember the Web Console filters
 pref("devtools.webconsole.filter.network", true);
 pref("devtools.webconsole.filter.networkinfo", false);
 pref("devtools.webconsole.filter.netwarn", true);
+pref("devtools.webconsole.filter.netxhr", false);
 pref("devtools.webconsole.filter.csserror", true);
 pref("devtools.webconsole.filter.cssparser", false);
 pref("devtools.webconsole.filter.csslog", false);
 pref("devtools.webconsole.filter.exception", true);
 pref("devtools.webconsole.filter.jswarn", true);
 pref("devtools.webconsole.filter.jslog", false);
 pref("devtools.webconsole.filter.error", true);
 pref("devtools.webconsole.filter.warn", true);
@@ -1508,16 +1509,17 @@ pref("devtools.webconsole.filter.info", 
 pref("devtools.webconsole.filter.log", true);
 pref("devtools.webconsole.filter.secerror", true);
 pref("devtools.webconsole.filter.secwarn", true);
 
 // Remember the Browser Console filters
 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.csserror", true);
 pref("devtools.browserconsole.filter.cssparser", false);
 pref("devtools.browserconsole.filter.csslog", false);
 pref("devtools.browserconsole.filter.exception", true);
 pref("devtools.browserconsole.filter.jswarn", true);
 pref("devtools.browserconsole.filter.jslog", true);
 pref("devtools.browserconsole.filter.error", true);
 pref("devtools.browserconsole.filter.warn", true);
--- a/browser/devtools/webconsole/test/browser.ini
+++ b/browser/devtools/webconsole/test/browser.ini
@@ -251,16 +251,17 @@ skip-if = e10s # Bug 1042253 - webconsol
 [browser_webconsole_bug_622303_persistent_filters.js]
 [browser_webconsole_bug_623749_ctrl_a_select_all_winnt.js]
 run-if = os == "win"
 [browser_webconsole_bug_630733_response_redirect_headers.js]
 [browser_webconsole_bug_632275_getters_document_width.js]
 [browser_webconsole_bug_632347_iterators_generators.js]
 skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
 [browser_webconsole_bug_632817.js]
+skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
 [browser_webconsole_bug_642108_pruneTest.js]
 [browser_webconsole_autocomplete_and_selfxss.js]
 [browser_webconsole_bug_644419_log_limits.js]
 skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s (expectUncaughtException)
 [browser_webconsole_bug_646025_console_file_location.js]
 [browser_webconsole_bug_651501_document_body_autocomplete.js]
 [browser_webconsole_bug_653531_highlighter_console_helper.js]
 skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
--- a/browser/devtools/webconsole/test/browser_console.js
+++ b/browser/devtools/webconsole/test/browser_console.js
@@ -75,17 +75,17 @@ function consoleOpened(hud)
         text: "foobarExceptionBug587757",
         category: CATEGORY_JS,
         severity: SEVERITY_ERROR,
       },
       {
         name: "network message",
         text: "test-console.html",
         category: CATEGORY_NETWORK,
-        severity: SEVERITY_LOG,
+        severity: SEVERITY_INFO,
       },
     ],
   });
 }
 
 function waitForConsole() {
   let deferred = promise.defer();
 
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_622303_persistent_filters.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_622303_persistent_filters.js
@@ -1,16 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const prefs = {
   "net": [
     "network",
     "netwarn",
-    "networkinfo",
+    "netxhr",
+    "networkinfo"
   ],
   "css": [
     "csserror",
     "cssparser",
     "csslog"
   ],
   "js": [
     "exception",
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_632817.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_632817.js
@@ -16,20 +16,23 @@ const TEST_URI = "data:text/html;charset
 let lastRequest = null;
 let requestCallback = null;
 let hud, browser;
 
 function test()
 {
   const PREF = "devtools.webconsole.persistlog";
   let original = Services.prefs.getBoolPref("devtools.webconsole.filter.networkinfo");
+  let originalXhr = Services.prefs.getBoolPref("devtools.webconsole.filter.netxhr");
   Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", true);
+  Services.prefs.setBoolPref("devtools.webconsole.filter.netxhr", true);
   Services.prefs.setBoolPref(PREF, true);
   registerCleanupFunction(() => {
     Services.prefs.setBoolPref("devtools.webconsole.filter.networkinfo", original);
+    Services.prefs.setBoolPref("devtools.webconsole.filter.netxhr", originalXhr);
     Services.prefs.clearUserPref(PREF);
   });
 
   loadTab(TEST_URI).then((tab) => {
     browser = tab.browser;
     openConsole().then((aHud) => {
       hud = aHud;
 
@@ -134,17 +137,17 @@ function testFormSubmission()
           text: "test-network-request.html",
           category: CATEGORY_NETWORK,
           severity: SEVERITY_LOG,
           count: 3,
         },
         {
           text: "test-data.json",
           category: CATEGORY_NETWORK,
-          severity: SEVERITY_LOG,
+          severity: SEVERITY_INFO,
           count: 2,
         },
       ],
     }).then(testLiveFilteringOnSearchStrings);
   };
 
   let form = content.document.querySelector("form");
   ok(form, "we have the HTML form");
--- a/browser/devtools/webconsole/webconsole.js
+++ b/browser/devtools/webconsole/webconsole.js
@@ -100,24 +100,24 @@ const SEVERITY_CLASS_FRAGMENTS = [
 ];
 
 // The preference keys to use for each category/severity combination, indexed
 // first by category (rows) and then by severity (columns).
 //
 // Most of these rather idiosyncratic names are historical and predate the
 // division of message type into "category" and "severity".
 const MESSAGE_PREFERENCE_KEYS = [
-//  Error         Warning       Info      Log
-  [ "network",    "netwarn",    null,     "networkinfo", ],  // Network
-  [ "csserror",   "cssparser",  null,     "csslog",      ],  // CSS
-  [ "exception",  "jswarn",     null,     "jslog",       ],  // JS
-  [ "error",      "warn",       "info",   "log",         ],  // Web Developer
-  [ null,         null,         null,     null,          ],  // Input
-  [ null,         null,         null,     null,          ],  // Output
-  [ "secerror",   "secwarn",    null,     null,          ],  // Security
+//  Error         Warning       Info       Log
+  [ "network",    "netwarn",    "netxhr",  "networkinfo", ],  // Network
+  [ "csserror",   "cssparser",  null,      "csslog",      ],  // CSS
+  [ "exception",  "jswarn",     null,      "jslog",       ],  // JS
+  [ "error",      "warn",       "info",    "log",         ],  // Web Developer
+  [ null,         null,         null,      null,          ],  // Input
+  [ null,         null,         null,      null,          ],  // Output
+  [ "secerror",   "secwarn",    null,      null,          ],  // Security
 ];
 
 // A mapping from the console API log event levels to the Web Console
 // severities.
 const LEVELS = {
   error: SEVERITY_ERROR,
   exception: SEVERITY_ERROR,
   assert: SEVERITY_ERROR,
@@ -542,35 +542,39 @@ WebConsoleFrame.prototype = {
     let reverseSaveBodiesPref = ({ target: aElement }) => {
       this.getSaveRequestAndResponseBodies().then(aValue => {
         this.setSaveRequestAndResponseBodies(!aValue);
         aElement.setAttribute("checked", aValue);
         this.emit("save-bodies-pref-reversed");
       });
     }
 
+    let saveBodiesDisabled = !this.getFilterState("networkinfo") &&
+                             !this.getFilterState("netxhr") &&
+                             !this.getFilterState("network");
+
     let saveBodies = doc.getElementById("saveBodies");
     saveBodies.addEventListener("command", reverseSaveBodiesPref);
-    saveBodies.disabled = !this.getFilterState("networkinfo") &&
-                          !this.getFilterState("network");
+    saveBodies.disabled = saveBodiesDisabled;
 
     let saveBodiesContextMenu = doc.getElementById("saveBodiesContextMenu");
     saveBodiesContextMenu.addEventListener("command", reverseSaveBodiesPref);
-    saveBodiesContextMenu.disabled = !this.getFilterState("networkinfo") &&
-                                     !this.getFilterState("network");
+    saveBodiesContextMenu.disabled = saveBodiesDisabled;
 
     saveBodies.parentNode.addEventListener("popupshowing", () => {
       updateSaveBodiesPrefUI(saveBodies);
       saveBodies.disabled = !this.getFilterState("networkinfo") &&
+                            !this.getFilterState("netxhr") &&
                             !this.getFilterState("network");
     });
 
     saveBodiesContextMenu.parentNode.addEventListener("popupshowing", () => {
       updateSaveBodiesPrefUI(saveBodiesContextMenu);
       saveBodiesContextMenu.disabled = !this.getFilterState("networkinfo") &&
+                                       !this.getFilterState("netxhr") &&
                                        !this.getFilterState("network");
     });
 
     let clearButton = doc.getElementsByClassName("webconsole-clear-console-button")[0];
     clearButton.addEventListener("command", () => {
       this.owner._onClearButton();
       this.jsterm.clearOutput(true);
     });
@@ -619,17 +623,17 @@ WebConsoleFrame.prototype = {
   /**
    * Initialize the default filter preferences.
    * @private
    */
   _initDefaultFilterPrefs: function WCF__initDefaultFilterPrefs()
   {
     let prefs = ["network", "networkinfo", "csserror", "cssparser", "csslog",
                  "exception", "jswarn", "jslog", "error", "info", "warn", "log",
-                 "secerror", "secwarn", "netwarn"];
+                 "secerror", "secwarn", "netwarn", "netxhr"];
     for (let pref of prefs) {
       this.filterPrefs[pref] = Services.prefs
                                .getBoolPref(this._filterPrefsPrefix + pref);
     }
   },
 
   /**
    * Attach / detach reflow listeners depending on the checked status
@@ -878,18 +882,19 @@ WebConsoleFrame.prototype = {
       case "menuitem": {
         let state = target.getAttribute("checked") !== "true";
         target.setAttribute("checked", state);
 
         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 == "network") {
+        if (prefKey == "networkinfo" || prefKey == "netxhr" || prefKey == "network") {
           let checkState = !this.getFilterState("networkinfo") &&
+                           !this.getFilterState("netxhr") &&
                            !this.getFilterState("network");
           this.document.getElementById("saveBodies").disabled = checkState;
           this.document.getElementById("saveBodiesContextMenu").disabled = checkState;
         }
 
         // Adjust the state of the button appropriately.
         let menuPopup = target.parentNode;
 
@@ -1488,16 +1493,19 @@ WebConsoleFrame.prototype = {
     let networkInfo = this._networkRequests[actorId];
     if (!networkInfo) {
       return null;
     }
 
     let request = networkInfo.request;
     let clipboardText = request.method + " " + request.url;
     let severity = SEVERITY_LOG;
+    if (networkInfo.isXHR) {
+      severity = SEVERITY_INFO;
+    }
     let mixedRequest =
       WebConsoleUtils.isMixedHTTPSRequest(request.url, this.contentLocation);
     if (mixedRequest) {
       severity = SEVERITY_WARNING;
     }
 
     let methodNode = this.document.createElementNS(XHTML_NS, "span");
     methodNode.className = "method";
@@ -1745,16 +1753,17 @@ WebConsoleFrame.prototype = {
       actor: aActor.actor,
       discardRequestBody: true,
       discardResponseBody: true,
       startedDateTime: aActor.startedDateTime,
       request: {
         url: aActor.url,
         method: aActor.method,
       },
+      isXHR: aActor.isXHR,
       response: {},
       timings: {},
       updates: [], // track the list of network event updates
       private: aActor.private,
     };
 
     this._networkRequests[aActor.actor] = networkInfo;
     this.outputMessage(CATEGORY_NETWORK, this.logNetEvent, [aActor]);
--- a/browser/devtools/webconsole/webconsole.xul
+++ b/browser/devtools/webconsole/webconsole.xul
@@ -93,16 +93,18 @@ function goUpdateConsoleCommands() {
                          accesskeyMacOSX="&btnPageNet.accesskeyMacOSX;"
                          accesskey="&btnPageNet.accesskey;"
                          tabindex="3">
             <menupopup id="net-contextmenu">
               <menuitem label="&btnConsoleErrors;" type="checkbox" autocheck="false"
                         prefKey="network"/>
               <menuitem label="&btnConsoleWarnings;" type="checkbox" autocheck="false"
                         prefKey="netwarn"/>
+              <menuitem label="&btnConsoleXhr;" type="checkbox" autocheck="false"
+                        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;"/>
             </menupopup>
           </toolbarbutton>
           <toolbarbutton label="&btnPageCSS.label;" type="menu-button"
--- a/browser/locales/en-US/chrome/browser/devtools/webConsole.dtd
+++ b/browser/locales/en-US/chrome/browser/devtools/webConsole.dtd
@@ -68,16 +68,17 @@
   -  console.error(). -->
 <!ENTITY btnPageLogging.label   "Logging">
 <!ENTITY btnPageLogging.tooltip "Log messages sent to the window.console object">
 <!ENTITY btnPageLogging.accesskey3 "L">
 <!ENTITY btnConsoleErrors       "Errors">
 <!ENTITY btnConsoleInfo         "Info">
 <!ENTITY btnConsoleWarnings     "Warnings">
 <!ENTITY btnConsoleLog          "Log">
+<!ENTITY btnConsoleXhr          "XHR">
 <!ENTITY btnConsoleReflows      "Reflows">
 
 <!ENTITY filterOutput.placeholder "Filter output">
 <!ENTITY btnClear.label        "Clear">
 <!ENTITY btnClear.tooltip      "Clear the Web Console output">
 <!ENTITY btnClear.accesskey    "r">
 
 <!ENTITY fullZoomEnlargeCmd.commandkey  "+">