Backed out 3 changesets (bug 1223726) for mochitest devtools failures on devtools/client/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.js
authorCosmin Sabou <csabou@mozilla.com>
Mon, 12 Mar 2018 14:51:37 +0200
changeset 407593 48400efc495805643cc4e8d00ecc0c43fee2cfec
parent 407592 b7ad4ad9f1c015a8ea0cd9fc860b4eb1d334213d
child 407594 6ce51cd7a60de1b695a8b084af2e703dbab4c8e0
push id60966
push usercsabou@mozilla.com
push dateMon, 12 Mar 2018 12:51:51 +0000
treeherderautoland@48400efc4958 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1223726
milestone60.0a1
backs out1a09e6c3c0a3c0109c32e49b164c7170fc3cfbe5
41da2897f549475c85639df00e984b987df8ef66
fa0a1e88a238faf3a74535f78c172a9f548c016f
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 3 changesets (bug 1223726) for mochitest devtools failures on devtools/client/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.js Backed out changeset 1a09e6c3c0a3 (bug 1223726) Backed out changeset 41da2897f549 (bug 1223726) Backed out changeset fa0a1e88a238 (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/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.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/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.js
+++ b/devtools/client/styleeditor/test/browser_styleeditor_fetch-from-netmonitor.js
@@ -29,20 +29,16 @@ add_task(function* () {
   let styleeditor = yield toolbox.selectTool("styleeditor");
   let ui = styleeditor.UI;
 
   info("Waiting for the sources to be loaded.");
   yield ui.editors[0].getSourceEditor();
   yield ui.selectStyleSheet(ui.editors[1].styleSheet);
   yield ui.editors[1].getSourceEditor();
 
-  // Wait till there is 5 requests in Netmonitor store.
-  // (i.e. the Styleeditor panel performed one request).
-  yield waitUntil(() => getSortedRequests(store.getState()).length == 5);
-
   info("Checking Netmonitor contents.");
   let shortRequests = [];
   let longRequests = [];
   let hugeRequests = [];
   for (let item of getSortedRequests(store.getState())) {
     if (item.url.endsWith("doc_short_string.css")) {
       shortRequests.push(item);
     }
--- 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);