Backed out 2 changesets (bug 1223726) for failing devtools/client/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.js a=backout on a CLOSED TREE
authorBogdan Tara <btara@mozilla.com>
Sat, 10 Mar 2018 02:44:19 +0200
changeset 407446 1dfc5eba64f1b2ddb308da27206bd39de8a7f1a6
parent 407445 5f5da5116bfa9b16e9b9cd35cd7e9237dfc2785a
child 407447 49c2fbd9779e6272a994f50478872cb47fdda756
push id60933
push userbtara@mozilla.com
push dateSat, 10 Mar 2018 00:44:22 +0000
treeherderautoland@1dfc5eba64f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1223726
milestone60.0a1
backs outa95b0b28ca16d84b92b3831c9ff12297254cd048
6adb35cc708e13e826a1624281f095d3ab3a7a23
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 1223726) for failing devtools/client/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.js a=backout on a CLOSED TREE Backed out changeset a95b0b28ca16 (bug 1223726) Backed out changeset 6adb35cc708e (bug 1223726)
devtools/client/netmonitor/src/har/test/browser_net_har_copy_all_as_har.js
devtools/client/netmonitor/test/browser_net_truncate.js
devtools/client/preferences/devtools.js
devtools/client/webconsole/webconsole-connection-proxy.js
devtools/shared/webconsole/network-monitor.js
modules/libpref/init/all.js
--- a/devtools/client/netmonitor/src/har/test/browser_net_har_copy_all_as_har.js
+++ b/devtools/client/netmonitor/src/har/test/browser_net_har_copy_all_as_har.js
@@ -5,22 +5,40 @@
 
 /**
  * Basic tests for exporting Network panel content into HAR format.
  */
 add_task(async function () {
   // Disable tcp fast open, because it is setting a response header indicator
   // (bug 1352274). TCP Fast Open is not present on all platforms therefore the
   // number of response headers will vary depending on the platform.
-  await pushPref("network.tcp.tcp_fastopen_enable", false);
+  Services.prefs.setBoolPref("network.tcp.tcp_fastopen_enable", false);
   let { tab, monitor } = await initNetMonitor(SIMPLE_URL);
 
-  info("Starting test...");
+  info("Starting test... ");
+
+  let { connector, store, windowRequire } = monitor.panelWin;
+  let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
+  let RequestListContextMenu = windowRequire(
+    "devtools/client/netmonitor/src/widgets/RequestListContextMenu");
+  let { getSortedRequests } = windowRequire(
+    "devtools/client/netmonitor/src/selectors/index");
+
+  store.dispatch(Actions.batchEnable(false));
 
-  let har = await reloadAndCopyAllAsHar(tab, monitor);
+  let wait = waitForNetworkEvents(monitor, 1);
+  tab.linkedBrowser.reload();
+  await wait;
+
+  let contextMenu = new RequestListContextMenu({ connector });
+
+  await contextMenu.copyAllAsHar(getSortedRequests(store.getState()));
+
+  let jsonString = SpecialPowers.getClipboardData("text/unicode");
+  let har = JSON.parse(jsonString);
 
   // Check out HAR log
   isnot(har.log, null, "The HAR log must exist");
   is(har.log.creator.name, "Firefox", "The creator field must be set");
   is(har.log.browser.name, "Firefox", "The browser field must be set");
   is(har.log.pages.length, 1, "There must be one page");
   is(har.log.entries.length, 1, "There must be one request");
 
@@ -37,49 +55,10 @@ add_task(async function () {
   is(entry.response.statusText, "OK", "Check response status text");
   is(entry.response.headers.length, 6, "Check number of response headers");
   is(entry.response.content.mimeType, // eslint-disable-line
     "text/html", "Check response content type"); // eslint-disable-line
   isnot(entry.response.content.text, undefined, // eslint-disable-line
     "Check response body");
   isnot(entry.timings, undefined, "Check timings");
 
-  // Test response body limit (non zero).
-  await pushPref("devtools.netmonitor.responseBodyLimit", 10);
-  har = await reloadAndCopyAllAsHar(tab, monitor);
-  entry = har.log.entries[0];
-  is(entry.response.content.text.length, 10, // eslint-disable-line
-    "Response body must be truncated");
-
-  // Test response body limit (zero).
-  await pushPref("devtools.netmonitor.responseBodyLimit", 0);
-  har = await reloadAndCopyAllAsHar(tab, monitor);
-  entry = har.log.entries[0];
-  is(entry.response.content.text.length, 465, // eslint-disable-line
-    "Response body must not be truncated");
-
   return teardown(monitor);
 });
-
-/**
- * Reload the page and copy all as HAR.
- */
-async function reloadAndCopyAllAsHar(tab, monitor) {
-  let { connector, store, windowRequire } = monitor.panelWin;
-  let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
-  let RequestListContextMenu = windowRequire(
-    "devtools/client/netmonitor/src/widgets/RequestListContextMenu");
-  let { getSortedRequests } = windowRequire(
-    "devtools/client/netmonitor/src/selectors/index");
-
-  store.dispatch(Actions.batchEnable(false));
-
-  let wait = waitForNetworkEvents(monitor, 1);
-  tab.linkedBrowser.reload();
-  await wait;
-
-  let contextMenu = new RequestListContextMenu({ connector });
-
-  await contextMenu.copyAllAsHar(getSortedRequests(store.getState()));
-
-  let jsonString = SpecialPowers.getClipboardData("text/unicode");
-  return JSON.parse(jsonString);
-}
--- a/devtools/client/netmonitor/test/browser_net_truncate.js
+++ b/devtools/client/netmonitor/test/browser_net_truncate.js
@@ -3,18 +3,18 @@
 
 "use strict";
 
 /**
  * Verifies that truncated response bodies still have the correct reported size.
  */
 
 add_task(async function () {
-  let limit = Services.prefs.getIntPref("devtools.netmonitor.responseBodyLimit");
-  let URL = EXAMPLE_URL + "sjs_truncate-test-server.sjs?limit=" + limit;
+  let { RESPONSE_BODY_LIMIT } = require("devtools/shared/webconsole/network-monitor");
+  let URL = EXAMPLE_URL + "sjs_truncate-test-server.sjs?limit=" + RESPONSE_BODY_LIMIT;
   let { monitor, tab } = await initNetMonitor(URL);
 
   info("Starting test... ");
 
   let { L10N } = require("devtools/client/netmonitor/src/utils/l10n");
 
   let { document } = monitor.panelWin;
 
--- a/devtools/client/preferences/devtools.js
+++ b/devtools/client/preferences/devtools.js
@@ -160,19 +160,16 @@ pref("devtools.netmonitor.enabled", true
 // The default Network Monitor UI settings
 pref("devtools.netmonitor.panes-network-details-width", 550);
 pref("devtools.netmonitor.panes-network-details-height", 450);
 pref("devtools.netmonitor.filters", "[\"all\"]");
 pref("devtools.netmonitor.visibleColumns",
   "[\"status\",\"method\",\"file\",\"domain\",\"cause\",\"type\",\"transferred\",\"contentSize\",\"waterfall\"]"
 );
 
-// Save request/response bodies yes/no.
-pref("devtools.netmonitor.saveRequestAndResponseBodies", true);
-
 // The default Network monitor HAR export setting
 pref("devtools.netmonitor.har.defaultLogDir", "");
 pref("devtools.netmonitor.har.defaultFileName", "Archive %date");
 pref("devtools.netmonitor.har.jsonp", false);
 pref("devtools.netmonitor.har.jsonpCallback", "");
 pref("devtools.netmonitor.har.includeResponseBodies", true);
 pref("devtools.netmonitor.har.compress", false);
 pref("devtools.netmonitor.har.forceExport", false);
--- a/devtools/client/webconsole/webconsole-connection-proxy.js
+++ b/devtools/client/webconsole/webconsole-connection-proxy.js
@@ -203,25 +203,19 @@ WebConsoleConnectionProxy.prototype = {
                     response.message);
       this._connectDefer.reject(response);
       return;
     }
 
     this.webConsoleClient = webConsoleClient;
     this._hasNativeConsoleAPI = response.nativeConsoleAPI;
 
-    let saveBodies = Services.prefs.getBoolPref(
-      "devtools.netmonitor.saveRequestAndResponseBodies");
-
     // There is no way to view response bodies from the Browser Console, so do
     // not waste the memory.
-    if (this.webConsoleFrame.isBrowserConsole) {
-      saveBodies = false;
-    }
-
+    let saveBodies = !this.webConsoleFrame.isBrowserConsole;
     this.webConsoleFrame.setSaveRequestAndResponseBodies(saveBodies);
 
     this.webConsoleClient.on("networkEvent", this._onNetworkEvent);
     this.webConsoleClient.on("networkEventUpdate", this._onNetworkEventUpdate);
 
     let msgs = ["PageError", "ConsoleAPI"];
     this.webConsoleClient.getCachedMessages(msgs, this._onCachedMessages);
 
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -30,16 +30,21 @@ const {NetworkThrottleManager} = require
 const PR_UINT32_MAX = 4294967295;
 
 // HTTP status codes.
 const HTTP_MOVED_PERMANENTLY = 301;
 const HTTP_FOUND = 302;
 const HTTP_SEE_OTHER = 303;
 const HTTP_TEMPORARY_REDIRECT = 307;
 
+// The maximum number of bytes a NetworkResponseListener can hold: 1 MB
+const RESPONSE_BODY_LIMIT = 1048576;
+// Exported for testing.
+exports.RESPONSE_BODY_LIMIT = RESPONSE_BODY_LIMIT;
+
 /**
  * Check if a given network request should be logged by a network monitor
  * based on the specified filters.
  *
  * @param nsIHttpChannel channel
  *        Request to check.
  * @param filters
  *        NetworkMonitor filters to match against.
@@ -269,26 +274,23 @@ exports.StackTraceCollector = StackTrace
  *        HttpActivity object associated with this request. See NetworkMonitor
  *        for more information.
  */
 function NetworkResponseListener(owner, httpActivity) {
   this.owner = owner;
   this.receivedData = "";
   this.httpActivity = httpActivity;
   this.bodySize = 0;
-  // Indicates if the response had a size greater than response body limit.
+  // Indicates if the response had a size greater than RESPONSE_BODY_LIMIT.
   this.truncated = false;
   // Note that this is really only needed for the non-e10s case.
   // See bug 1309523.
   let channel = this.httpActivity.channel;
   this._wrappedNotificationCallbacks = channel.notificationCallbacks;
   channel.notificationCallbacks = this;
-
-  this.responseBodyLimit = Services.prefs.getIntPref(
-    "devtools.netmonitor.responseBodyLimit");
 }
 
 NetworkResponseListener.prototype = {
   QueryInterface:
     XPCOMUtils.generateQI([Ci.nsIStreamListener, Ci.nsIInputStreamCallback,
                            Ci.nsIRequestObserver, Ci.nsIInterfaceRequestor,
                            Ci.nsISupports]),
 
@@ -390,17 +392,17 @@ NetworkResponseListener.prototype = {
   setAsyncListener: function (stream, listener) {
     // Asynchronously wait for the stream to be readable or closed.
     stream.asyncWait(listener, 0, 0, Services.tm.mainThread);
   },
 
   /**
    * Stores the received data, if request/response body logging is enabled. It
    * also does limit the number of stored bytes, based on the
-   * `devtools.netmonitor.responseBodyLimit` pref.
+   * RESPONSE_BODY_LIMIT constant.
    *
    * Learn more about nsIStreamListener at:
    * https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIStreamListener
    *
    * @param nsIRequest request
    * @param nsISupports context
    * @param nsIInputStream inputStream
    * @param unsigned long offset
@@ -408,23 +410,20 @@ NetworkResponseListener.prototype = {
    */
   onDataAvailable: function (request, context, inputStream, offset, count) {
     this._findOpenResponse();
     let data = NetUtil.readInputStreamToString(inputStream, count);
 
     this.bodySize += count;
 
     if (!this.httpActivity.discardResponseBody) {
-      let limit = Services.prefs.getIntPref("devtools.netmonitor.responseBodyLimit");
-      if (this.receivedData.length < limit || limit == 0) {
+      if (this.receivedData.length < RESPONSE_BODY_LIMIT) {
         this.receivedData +=
           NetworkHelper.convertToUnicode(data, request.contentCharset);
-      }
-      if (this.receivedData.length > limit && limit > 0) {
-        this.receivedData = this.receivedData.substr(0, limit);
+      } else {
         this.truncated = true;
       }
     }
   },
 
   /**
    * See documentation at
    * https://developer.mozilla.org/En/NsIRequestObserver
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1108,22 +1108,16 @@ pref("devtools.debugger.log.verbose", fa
 
 pref("devtools.debugger.remote-port", 6000);
 pref("devtools.debugger.remote-websocket", false);
 // Force debugger server binding on the loopback interface
 pref("devtools.debugger.force-local", true);
 // Block tools from seeing / interacting with certified apps
 pref("devtools.debugger.forbid-certified-apps", true);
 
-// Limit for intercepted response bodies (1 MB)
-// Possible values:
-// 0 => the response body has no limit
-// n => represents max number of bytes stored
-pref("devtools.netmonitor.responseBodyLimit", 1048576);
-
 // DevTools default color unit
 pref("devtools.defaultColorUnit", "authored");
 
 // Used for devtools debugging
 pref("devtools.dump.emit", false);
 
 // Controls whether EventEmitter module throws dump message on each emit
 pref("toolkit.dump.emit", false);