Bug 765651 - Fix console protocol for ws connections. r=Honza,nchevobbe
authorThiago Arrais <thiago.arrais@gmail.com>
Mon, 16 Dec 2019 11:42:01 +0000
changeset 507081 aa40b800b2ce6a854058523ff419f78750e3fcd1
parent 507080 57ee8e8fa11b3df04fd7a42169d0808a4100b23b
child 507082 621dfa36a301c35942298d077cbe9bc0054ecfaf
push id36922
push userncsoregi@mozilla.com
push dateMon, 16 Dec 2019 17:21:47 +0000
treeherdermozilla-central@27d0d6cc2131 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, nchevobbe
bugs765651
milestone73.0a1
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
Bug 765651 - Fix console protocol for ws connections. r=Honza,nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D56965
devtools/client/netmonitor/test/browser_net_filter-01.js
devtools/client/netmonitor/test/browser_net_websocket_stacks.js
devtools/client/netmonitor/test/head.js
devtools/server/actors/network-monitor/network-observer.js
--- a/devtools/client/netmonitor/test/browser_net_filter-01.js
+++ b/devtools/client/netmonitor/test/browser_net_filter-01.js
@@ -190,17 +190,17 @@ const EXPECTED_REQUESTS = [
       status: 200,
       statusText: "OK",
       type: "x-shockwave-flash",
       fullMimeType: "application/x-shockwave-flash",
     },
   },
   {
     method: "GET",
-    url: WS_CONTENT_TYPE_SJS + "?fmt=ws",
+    url: WS_WS_CONTENT_TYPE_SJS + "?fmt=ws",
     data: {
       fuzzyUrl: true,
       status: 101,
       statusText: "Switching Protocols",
     },
   },
 ];
 
--- a/devtools/client/netmonitor/test/browser_net_websocket_stacks.js
+++ b/devtools/client/netmonitor/test/browser_net_websocket_stacks.js
@@ -15,34 +15,34 @@ const EXPECTED_REQUESTS = [
     method: "GET",
     url: TOP_URL,
     causeType: "document",
     causeUri: null,
     stack: false,
   },
   {
     method: "GET",
-    url: "http://localhost:8080/",
+    url: "ws://localhost:8080/",
     causeType: "websocket",
     causeUri: TOP_URL,
     stack: [
       { fn: "openSocket", file: TOP_FILE_NAME, line: 6 },
       { file: TOP_FILE_NAME, line: 3 },
     ],
   },
   {
     method: "GET",
     url: EXAMPLE_URL + WORKER_FILE_NAME,
     causeType: "script",
     causeUri: TOP_URL,
     stack: [{ file: TOP_FILE_NAME, line: 9 }],
   },
   {
     method: "GET",
-    url: "https://localhost:8081/",
+    url: "wss://localhost:8081/",
     causeType: "websocket",
     causeUri: TOP_URL,
     stack: [
       { fn: "openWorkerSocket", file: WORKER_FILE_NAME, line: 5 },
       { file: WORKER_FILE_NAME, line: 2 },
     ],
   },
 ];
--- a/devtools/client/netmonitor/test/head.js
+++ b/devtools/client/netmonitor/test/head.js
@@ -95,16 +95,17 @@ const OPEN_REQUEST_IN_TAB_URL = EXAMPLE_
 const CSP_URL = EXAMPLE_URL + "html_csp-test-page.html";
 const CSP_RESEND_URL = EXAMPLE_URL + "html_csp-resend-test-page.html";
 
 const SIMPLE_SJS = EXAMPLE_URL + "sjs_simple-test-server.sjs";
 const SIMPLE_UNSORTED_COOKIES_SJS =
   EXAMPLE_URL + "sjs_simple-unsorted-cookies-test-server.sjs";
 const CONTENT_TYPE_SJS = EXAMPLE_URL + "sjs_content-type-test-server.sjs";
 const WS_CONTENT_TYPE_SJS = WS_HTTP_URL + "sjs_content-type-test-server.sjs";
+const WS_WS_CONTENT_TYPE_SJS = WS_URL + "sjs_content-type-test-server.sjs";
 const HTTPS_CONTENT_TYPE_SJS =
   HTTPS_EXAMPLE_URL + "sjs_content-type-test-server.sjs";
 const SERVER_TIMINGS_TYPE_SJS =
   HTTPS_EXAMPLE_URL + "sjs_timings-test-server.sjs";
 const STATUS_CODES_SJS = EXAMPLE_URL + "sjs_status-codes-test-server.sjs";
 const SORTING_SJS = EXAMPLE_URL + "sjs_sorting-test-server.sjs";
 const HTTPS_REDIRECT_SJS = EXAMPLE_URL + "sjs_https-redirect-test-server.sjs";
 const CORS_SJS_PATH =
--- a/devtools/server/actors/network-monitor/network-observer.js
+++ b/devtools/server/actors/network-monitor/network-observer.js
@@ -680,16 +680,31 @@ NetworkObserver.prototype = {
     if (channel.loadInfo) {
       causeType = channel.loadInfo.externalContentPolicyType;
       const { loadingPrincipal } = channel.loadInfo;
       if (loadingPrincipal && loadingPrincipal.URI) {
         causeUri = loadingPrincipal.URI.spec;
       }
     }
 
+    // Show the right WebSocket URL in case of WS channel.
+    if (channel.notificationCallbacks) {
+      let wsChannel = null;
+      try {
+        wsChannel = channel.notificationCallbacks.QueryInterface(
+          Ci.nsIWebSocketChannel
+        );
+      } catch (e) {
+        // Not all channels implement nsIWebSocketChannel.
+      }
+      if (wsChannel) {
+        event.url = wsChannel.URI.spec;
+      }
+    }
+
     event.cause = {
       type: causeTypeToString(causeType),
       loadingDocumentUri: causeUri,
       stacktrace,
     };
 
     httpActivity.isXHR = event.isXHR =
       causeType === Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST ||