Attachment #8951598: Bug859051.patch for bug #859051

View | Details | Raw Unified | Return to bug 859051
Collapse All | Expand All

(-)a/devtools/client/locales/en-US/netmonitor.properties (+12 lines)
Line     Link Here 
 Lines 566-581   netmonitor.toolbar.waterfall=Timeline Link Here 
566
# LOCALIZATION NOTE (netmonitor.tab.headers): This is the label displayed
566
# LOCALIZATION NOTE (netmonitor.tab.headers): This is the label displayed
567
# in the network details pane identifying the headers tab.
567
# in the network details pane identifying the headers tab.
568
netmonitor.tab.headers=Headers
568
netmonitor.tab.headers=Headers
569
569
570
# LOCALIZATION NOTE (netmonitor.tab.cookies): This is the label displayed
570
# LOCALIZATION NOTE (netmonitor.tab.cookies): This is the label displayed
571
# in the network details pane identifying the cookies tab.
571
# in the network details pane identifying the cookies tab.
572
netmonitor.tab.cookies=Cookies
572
netmonitor.tab.cookies=Cookies
573
573
574
# LOCALIZATION NOTE (netmonitor.tab.cache): This is the label displayed
575
# in the network details pane identifying the cache tab.
576
netmonitor.tab.cache=Cache
577
574
# LOCALIZATION NOTE (netmonitor.tab.params): This is the label displayed
578
# LOCALIZATION NOTE (netmonitor.tab.params): This is the label displayed
575
# in the network details pane identifying the params tab.
579
# in the network details pane identifying the params tab.
576
netmonitor.tab.params=Params
580
netmonitor.tab.params=Params
577
581
578
# LOCALIZATION NOTE (netmonitor.tab.response): This is the label displayed
582
# LOCALIZATION NOTE (netmonitor.tab.response): This is the label displayed
579
# in the network details pane identifying the response tab.
583
# in the network details pane identifying the response tab.
580
netmonitor.tab.response=Response
584
netmonitor.tab.response=Response
581
585
 Lines 1029-1036   netmonitor.status.tooltip.cached = %1$S %2$S (cached) Link Here 
1029
# the column status code, when the request is from a service worker
1033
# the column status code, when the request is from a service worker
1030
# %1$S is the status code, %2$S is the status text.
1034
# %1$S is the status code, %2$S is the status text.
1031
netmonitor.status.tooltip.worker = %1$S %2$S (service worker)
1035
netmonitor.status.tooltip.worker = %1$S %2$S (service worker)
1032
1036
1033
# LOCALIZATION NOTE (netmonitor.status.tooltip.cachedworker): This is the tooltip
1037
# LOCALIZATION NOTE (netmonitor.status.tooltip.cachedworker): This is the tooltip
1034
# of the column status code, when the request is cached and is from a service worker
1038
# of the column status code, when the request is cached and is from a service worker
1035
# %1$S is the status code, %2$S is the status text.
1039
# %1$S is the status code, %2$S is the status text.
1036
netmonitor.status.tooltip.cachedworker = %1$S %2$S (cached, service worker)
1040
netmonitor.status.tooltip.cachedworker = %1$S %2$S (cached, service worker)
1041
1042
cacheEmptyText = No cache information
1043
dataSize = Data Size
1044
expires = Expires
1045
fetchCount = Fetch Count
1046
lastFetched = Last Fetched
1047
lastModified = Last Modified
1048
device = Device
(-)a/devtools/client/netmonitor/src/assets/styles/NetworkDetailsPanel.css (-1 / +3 lines)
Line     Link Here 
 Lines 163-178    Link Here 
163
}
163
}
164
164
165
.network-monitor .source-editor-mount {
165
.network-monitor .source-editor-mount {
166
  width: 100%;
166
  width: 100%;
167
  height: 100%;
167
  height: 100%;
168
}
168
}
169
169
170
.network-monitor .headers-summary-label,
170
.network-monitor .headers-summary-label,
171
.network-monitor .cache-summary-label,
171
.network-monitor .tree-container .objectBox {
172
.network-monitor .tree-container .objectBox {
172
  white-space: nowrap;
173
  white-space: nowrap;
173
}
174
}
174
175
175
/* Summary tabpanel */
176
/* Summary tabpanel */
176
177
177
.network-monitor .tabpanel-summary-container {
178
.network-monitor .tabpanel-summary-container {
178
  padding: 1px;
179
  padding: 1px;
 Lines 196-212    Link Here 
196
197
197
/* Headers tabpanel */
198
/* Headers tabpanel */
198
199
199
.network-monitor .headers-overview {
200
.network-monitor .headers-overview {
200
  background: var(--theme-toolbar-background);
201
  background: var(--theme-toolbar-background);
201
}
202
}
202
203
203
.network-monitor .headers-summary,
204
.network-monitor .headers-summary,
204
.network-monitor .response-summary {
205
.network-monitor .response-summary,
206
.network-monitor .cache-summary {
205
  display: flex;
207
  display: flex;
206
  align-items: center;
208
  align-items: center;
207
}
209
}
208
210
209
.network-monitor .headers-summary .devtools-button {
211
.network-monitor .headers-summary .devtools-button {
210
  margin-inline-end: 6px;
212
  margin-inline-end: 6px;
211
}
213
}
212
214
(-)a/devtools/client/netmonitor/src/components/CachePanel.js (+138 lines)
Line     Link Here 
Line 0    Link Here 
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
 "use strict";
6
7
 const { Component, createFactory } = require("devtools/client/shared/vendor/react");
8
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
9
 const { connect } = require("devtools/client/shared/vendor/react-redux");
10
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
11
 const { L10N } = require("../utils/l10n");
12
 const { fetchCacheDescriptor, fetchNetworkUpdatePacket } = require("../utils/request-utils");
13
 const { sortObjectKeys } = require("../utils/sort-utils");
14
 const Actions = require("../actions/index");
15
 
16
 // Component
17
 const PropertiesView = createFactory(require("./PropertiesView"));
18
 
19
 const { div, input } = dom;
20
21
 const CACHE_EMPTY_TEXT = L10N.getStr("cacheEmptyText");
22
 const DATA_SIZE = L10N.getStr("dataSize");
23
 const EXPIRES = L10N.getStr("expires");
24
 const FETCH_COUNT = L10N.getStr("fetchCount");
25
 const LAST_FETCHED = L10N.getStr("lastFetched");
26
 const LAST_MODIFIED = L10N.getStr("lastModified");
27
 const DEVICE = L10N.getStr("device");
28
 const SECTION_NAMES = [
29
   DATA_SIZE,
30
   LAST_FETCHED,
31
   LAST_MODIFIED,
32
   FETCH_COUNT,
33
   EXPIRES,
34
   DEVICE,
35
 ];
36
 /*
37
  * Cache panel component
38
  * This tab lists full details of any cache information of the response.
39
  */
40
 class CachePanel extends Component {
41
   static get propTypes() {
42
     return {
43
       connector: PropTypes.object.isRequired,
44
       openLink: PropTypes.func,
45
       request: PropTypes.object.isRequired,
46
     };
47
   }
48
 
49
   componentDidMount() {
50
     let { connector, request } = this.props;
51
     fetchNetworkUpdatePacket(connector.requestData, request, ["responseCache"]);
52
   }
53
 
54
   componentWillReceiveProps(nextProps) {
55
     let { connector, request } = nextProps;
56
     fetchNetworkUpdatePacket(connector.requestData, request, ["responseCache"]);
57
   }
58
59
   renderSummary(label, value) {
60
     return (
61
       div({ className: "tabpanel-summary-container cache-summary"},
62
        div({
63
          className: "tabpanel-summary-label cache-summary-label",
64
        }, label + ':'),
65
        input({
66
          className: "tabpanel-summary-value textbox-input devtools-monospace",
67
          readOnly: true,
68
          value
69
        }),
70
      )
71
     );
72
   }
73
74
   getProperties(responseCache) {
75
    let responseCacheObj;
76
     let cacheObj;
77
     try {
78
        responseCacheObj = Object.assign({}, responseCache);
79
        responseCacheObj = responseCacheObj.cache;
80
     } catch (e) {
81
        return null;
82
     }
83
84
     try {
85
       cacheObj = Object.assign({}, responseCacheObj);
86
     } catch (e) {
87
        return null;
88
     }
89
   
90
    return cacheObj;
91
  }
92
93
  getDate(timestamp) {
94
    let d = new Date(parseInt(timestamp) * 1000);
95
96
    return d.toLocaleDateString() + ' ' + d.toLocaleTimeString();
97
  }
98
99
   render() {
100
     let {
101
       request,
102
       openLink,
103
     } = this.props;
104
     let { responseCache } = request;
105
     
106
107
     let object = Object.assign({}, this.getProperties(responseCache));
108
     let panelObject = {};
109
     let summaryLastFetched = object.lastFetched ? this.renderSummary( LAST_FETCHED, this.getDate(object.lastFetched)): null;
110
     let summaryFetchCount = object.fetchCount ? this.renderSummary(FETCH_COUNT, object.fetchCount): null;
111
     let summaryDataSize = object.dataSize ? this.renderSummary(DATA_SIZE, object.dataSize): null;
112
     let summaryLastModified = object.lastModified ? this.renderSummary(LAST_MODIFIED, this.getDate(object.lastModified)): null;
113
     let summaryExpires = object.expires ? this.renderSummary(EXPIRES, this.getDate(object.expires)): null;
114
     let summaryDevice = object.device ? this.renderSummary(DEVICE, object.device) : null;
115
     
116
117
     return (
118
       div({ className: "panel-container" },
119
        div({ className: "cache-overview" } ,
120
          summaryLastFetched,
121
          summaryFetchCount,
122
          summaryDataSize,
123
          summaryLastModified,
124
          summaryExpires,
125
          summaryDevice
126
        ),
127
         PropertiesView({
128
           panelObject,
129
           sectionNames: SECTION_NAMES,
130
           openLink,
131
           enableInput: false,
132
           enableFilter: false,
133
         })
134
       )
135
     );
136
   }
137
 }
138
 module.exports = CachePanel;
(-)a/devtools/client/netmonitor/src/components/TabboxPanel.js (+9 lines)
Line     Link Here 
 Lines 10-30   const { L10N } = require("../utils/l10n"); Link Here 
10
const { PANELS } = require("../constants");
10
const { PANELS } = require("../constants");
11
11
12
// Components
12
// Components
13
const Tabbar = createFactory(require("devtools/client/shared/components/tabs/TabBar"));
13
const Tabbar = createFactory(require("devtools/client/shared/components/tabs/TabBar"));
14
const TabPanel = createFactory(require("devtools/client/shared/components/tabs/Tabs").TabPanel);
14
const TabPanel = createFactory(require("devtools/client/shared/components/tabs/Tabs").TabPanel);
15
const CookiesPanel = createFactory(require("./CookiesPanel"));
15
const CookiesPanel = createFactory(require("./CookiesPanel"));
16
const HeadersPanel = createFactory(require("./HeadersPanel"));
16
const HeadersPanel = createFactory(require("./HeadersPanel"));
17
const ParamsPanel = createFactory(require("./ParamsPanel"));
17
const ParamsPanel = createFactory(require("./ParamsPanel"));
18
const CachePanel = createFactory(require("./CachePanel"));
18
const ResponsePanel = createFactory(require("./ResponsePanel"));
19
const ResponsePanel = createFactory(require("./ResponsePanel"));
19
const SecurityPanel = createFactory(require("./SecurityPanel"));
20
const SecurityPanel = createFactory(require("./SecurityPanel"));
20
const StackTracePanel = createFactory(require("./StackTracePanel"));
21
const StackTracePanel = createFactory(require("./StackTracePanel"));
21
const TimingsPanel = createFactory(require("./TimingsPanel"));
22
const TimingsPanel = createFactory(require("./TimingsPanel"));
22
23
24
const CACHE_TITLE = L10N.getStr("netmonitor.tab.cache");
23
const COOKIES_TITLE = L10N.getStr("netmonitor.tab.cookies");
25
const COOKIES_TITLE = L10N.getStr("netmonitor.tab.cookies");
24
const HEADERS_TITLE = L10N.getStr("netmonitor.tab.headers");
26
const HEADERS_TITLE = L10N.getStr("netmonitor.tab.headers");
25
const PARAMS_TITLE = L10N.getStr("netmonitor.tab.params");
27
const PARAMS_TITLE = L10N.getStr("netmonitor.tab.params");
26
const RESPONSE_TITLE = L10N.getStr("netmonitor.tab.response");
28
const RESPONSE_TITLE = L10N.getStr("netmonitor.tab.response");
27
const SECURITY_TITLE = L10N.getStr("netmonitor.tab.security");
29
const SECURITY_TITLE = L10N.getStr("netmonitor.tab.security");
28
const STACK_TRACE_TITLE = L10N.getStr("netmonitor.tab.stackTrace");
30
const STACK_TRACE_TITLE = L10N.getStr("netmonitor.tab.stackTrace");
29
const TIMINGS_TITLE = L10N.getStr("netmonitor.tab.timings");
31
const TIMINGS_TITLE = L10N.getStr("netmonitor.tab.timings");
30
32
 Lines 81-96   function TabboxPanel({ Link Here 
81
        ParamsPanel({ connector, openLink, request }),
83
        ParamsPanel({ connector, openLink, request }),
82
      ),
84
      ),
83
      TabPanel({
85
      TabPanel({
84
        id: PANELS.RESPONSE,
86
        id: PANELS.RESPONSE,
85
        title: RESPONSE_TITLE,
87
        title: RESPONSE_TITLE,
86
      },
88
      },
87
        ResponsePanel({ request, openLink, connector }),
89
        ResponsePanel({ request, openLink, connector }),
88
      ),
90
      ),
91
      request.fromCache && 
92
      TabPanel({
93
        id: PANELS.CACHE,
94
        title: CACHE_TITLE,
95
      },
96
        CachePanel({ request, openLink, connector }),
97
      ),
89
      TabPanel({
98
      TabPanel({
90
        id: PANELS.TIMINGS,
99
        id: PANELS.TIMINGS,
91
        title: TIMINGS_TITLE,
100
        title: TIMINGS_TITLE,
92
      },
101
      },
93
        TimingsPanel({
102
        TimingsPanel({
94
          connector,
103
          connector,
95
          request,
104
          request,
96
        }),
105
        }),
(-)a/devtools/client/netmonitor/src/components/moz.build (+1 lines)
Line     Link Here 
 Lines 1-14    Link Here 
1
# This Source Code Form is subject to the terms of the Mozilla Public
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
4
5
DevToolsModules(
5
DevToolsModules(
6
    'App.js',
6
    'App.js',
7
    'CachePanel.js',
7
    'CookiesPanel.js',
8
    'CookiesPanel.js',
8
    'CustomRequestPanel.js',
9
    'CustomRequestPanel.js',
9
    'HeadersPanel.js',
10
    'HeadersPanel.js',
10
    'HtmlPreview.js',
11
    'HtmlPreview.js',
11
    'MdnLink.js',
12
    'MdnLink.js',
12
    'MonitorPanel.js',
13
    'MonitorPanel.js',
13
    'NetworkDetailsPanel.js',
14
    'NetworkDetailsPanel.js',
14
    'ParamsPanel.js',
15
    'ParamsPanel.js',
(-)a/devtools/client/netmonitor/src/connector/firefox-data-provider.js (-1 / +26 lines)
Line     Link Here 
 Lines 86-128   class FirefoxDataProvider { Link Here 
86
  async updateRequest(id, data) {
86
  async updateRequest(id, data) {
87
    let {
87
    let {
88
      responseContent,
88
      responseContent,
89
      responseCookies,
89
      responseCookies,
90
      responseHeaders,
90
      responseHeaders,
91
      requestCookies,
91
      requestCookies,
92
      requestHeaders,
92
      requestHeaders,
93
      requestPostData,
93
      requestPostData,
94
      responseCache,
94
    } = data;
95
    } = data;
95
96
96
    // fetch request detail contents in parallel
97
    // fetch request detail contents in parallel
97
    let [
98
    let [
98
      responseContentObj,
99
      responseContentObj,
99
      requestHeadersObj,
100
      requestHeadersObj,
100
      responseHeadersObj,
101
      responseHeadersObj,
101
      postDataObj,
102
      postDataObj,
102
      requestCookiesObj,
103
      requestCookiesObj,
103
      responseCookiesObj,
104
      responseCookiesObj,
105
      responseCacheObj,
104
    ] = await Promise.all([
106
    ] = await Promise.all([
105
      this.fetchResponseContent(responseContent),
107
      this.fetchResponseContent(responseContent),
106
      this.fetchRequestHeaders(requestHeaders),
108
      this.fetchRequestHeaders(requestHeaders),
107
      this.fetchResponseHeaders(responseHeaders),
109
      this.fetchResponseHeaders(responseHeaders),
108
      this.fetchPostData(requestPostData),
110
      this.fetchPostData(requestPostData),
109
      this.fetchRequestCookies(requestCookies),
111
      this.fetchRequestCookies(requestCookies),
110
      this.fetchResponseCookies(responseCookies),
112
      this.fetchResponseCookies(responseCookies),
113
      this.fetchResponseCache(responseCache),
111
    ]);
114
    ]);
112
115
113
    let payload = Object.assign({},
116
    let payload = Object.assign({},
114
      data,
117
      data,
115
      responseContentObj,
118
      responseContentObj,
116
      requestHeadersObj,
119
      requestHeadersObj,
117
      responseHeadersObj,
120
      responseHeadersObj,
118
      postDataObj,
121
      postDataObj,
119
      requestCookiesObj,
122
      requestCookiesObj,
120
      responseCookiesObj
123
      responseCookiesObj,
124
      responseCacheObj,
121
    );
125
    );
122
126
123
    if (this.actions.updateRequest) {
127
    if (this.actions.updateRequest) {
124
      await this.actions.updateRequest(id, payload, true);
128
      await this.actions.updateRequest(id, payload, true);
125
    }
129
    }
126
130
127
    return payload;
131
    return payload;
128
  }
132
  }
 Lines 219-234   class FirefoxDataProvider { Link Here 
219
        if (resCookies.length) {
223
        if (resCookies.length) {
220
          payload.responseCookies = resCookies;
224
          payload.responseCookies = resCookies;
221
        }
225
        }
222
      }
226
      }
223
    }
227
    }
224
    return payload;
228
    return payload;
225
  }
229
  }
226
230
231
  async fetchResponseCache(responseCache) {
232
    let payload = {};
233
    if (responseCache) {
234
      payload.responseCache = await this.getLongString(responseCache);
235
      payload.responseCacheAvailable = false;
236
    }
237
    return payload;
238
  }
239
227
  /**
240
  /**
228
   * Public API used by the Toolbox: Tells if there is still any pending request.
241
   * Public API used by the Toolbox: Tells if there is still any pending request.
229
   *
242
   *
230
   * @return {boolean} returns true if the payload queue is empty
243
   * @return {boolean} returns true if the payload queue is empty
231
   */
244
   */
232
  isPayloadQueueEmpty() {
245
  isPayloadQueueEmpty() {
233
    return this.payloadQueue.size === 0;
246
    return this.payloadQueue.size === 0;
234
  }
247
  }
 Lines 553-568   class FirefoxDataProvider { Link Here 
553
   */
566
   */
554
  async onResponseCookies(response) {
567
  async onResponseCookies(response) {
555
    let payload = await this.updateRequest(response.from, {
568
    let payload = await this.updateRequest(response.from, {
556
      responseCookies: response
569
      responseCookies: response
557
    });
570
    });
558
    emit(EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
571
    emit(EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
559
    return payload.responseCookies;
572
    return payload.responseCookies;
560
  }
573
  }
574
  
575
  /**
576
   * 
577
   * @param {object} response 
578
   */
579
  async onResponseCache(response) {
580
    let payload = await this.updateRequest(response.from, {
581
      responseCache: response
582
    });
583
    emit(EVENTS.RECEIVED_RESPONSE_CACHE, response.from);
584
    return payload.responseCache;
585
  }
561
586
562
  /**
587
  /**
563
   * Handles additional information received via "getResponseContent" request.
588
   * Handles additional information received via "getResponseContent" request.
564
   *
589
   *
565
   * @param {object} response the message received from the server.
590
   * @param {object} response the message received from the server.
566
   */
591
   */
567
  async onResponseContent(response) {
592
  async onResponseContent(response) {
568
    let payload = await this.updateRequest(response.from, {
593
    let payload = await this.updateRequest(response.from, {
(-)a/devtools/client/netmonitor/src/constants.js (+6 lines)
Line     Link Here 
 Lines 91-106   const EVENTS = { Link Here 
91
  // When response content begins, updates and finishes receiving.
91
  // When response content begins, updates and finishes receiving.
92
  STARTED_RECEIVING_RESPONSE: "NetMonitor:NetworkEventUpdating:ResponseStart",
92
  STARTED_RECEIVING_RESPONSE: "NetMonitor:NetworkEventUpdating:ResponseStart",
93
  UPDATING_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdating:ResponseContent",
93
  UPDATING_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdating:ResponseContent",
94
  RECEIVED_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdated:ResponseContent",
94
  RECEIVED_RESPONSE_CONTENT: "NetMonitor:NetworkEventUpdated:ResponseContent",
95
95
96
  // When stack-trace finishes receiving.
96
  // When stack-trace finishes receiving.
97
  RECEIVED_EVENT_STACKTRACE: "NetMonitor:NetworkEventUpdated:StackTrace",
97
  RECEIVED_EVENT_STACKTRACE: "NetMonitor:NetworkEventUpdated:StackTrace",
98
98
99
  UPDATING_RESPONSE_CACHE: "NetMonitor:NetwworkEventUpdating:ResponseCache",
100
  RECEIVED_RESPONSE_CACHE: "NetMonitor:NetworkEventUpdated:ResponseCache",
101
99
  // Fired once the connection is established
102
  // Fired once the connection is established
100
  CONNECTED: "connected",
103
  CONNECTED: "connected",
101
104
102
  // When request payload (HTTP details data) are fetched from the backend.
105
  // When request payload (HTTP details data) are fetched from the backend.
103
  PAYLOAD_READY: "NetMonitor:PayloadReady",
106
  PAYLOAD_READY: "NetMonitor:PayloadReady",
104
};
107
};
105
108
106
const UPDATE_PROPS = [
109
const UPDATE_PROPS = [
 Lines 130-154   const UPDATE_PROPS = [ Link Here 
130
  "requestPostData",
133
  "requestPostData",
131
  "requestPostDataAvailable",
134
  "requestPostDataAvailable",
132
  "responseHeaders",
135
  "responseHeaders",
133
  "responseHeadersAvailable",
136
  "responseHeadersAvailable",
134
  "responseCookies",
137
  "responseCookies",
135
  "responseCookiesAvailable",
138
  "responseCookiesAvailable",
136
  "responseContent",
139
  "responseContent",
137
  "responseContentAvailable",
140
  "responseContentAvailable",
141
  "responseCache",
142
  "responseCacheAvailable",
138
  "formDataSections",
143
  "formDataSections",
139
  "stacktrace",
144
  "stacktrace",
140
];
145
];
141
146
142
const PANELS = {
147
const PANELS = {
143
  COOKIES: "cookies",
148
  COOKIES: "cookies",
144
  HEADERS: "headers",
149
  HEADERS: "headers",
145
  PARAMS: "params",
150
  PARAMS: "params",
146
  RESPONSE: "response",
151
  RESPONSE: "response",
152
  CACHE: "cache",
147
  SECURITY: "security",
153
  SECURITY: "security",
148
  STACK_TRACE: "stack-trace",
154
  STACK_TRACE: "stack-trace",
149
  TIMINGS: "timings",
155
  TIMINGS: "timings",
150
};
156
};
151
157
152
const RESPONSE_HEADERS = [
158
const RESPONSE_HEADERS = [
153
  "Cache-Control",
159
  "Cache-Control",
154
  "Connection",
160
  "Connection",
(-)a/devtools/client/netmonitor/src/utils/request-utils.js (+14 lines)
Line     Link Here 
 Lines 452-467   async function updateFormDataSections(props) { Link Here 
452
      requestPostData,
452
      requestPostData,
453
      connector.getLongString,
453
      connector.getLongString,
454
    );
454
    );
455
455
456
    updateRequest(request.id, { formDataSections }, true);
456
    updateRequest(request.id, { formDataSections }, true);
457
  }
457
  }
458
}
458
}
459
459
460
async function fetchCacheDescriptor(props) {
461
  let {
462
    connector,
463
    request = {},
464
  } = props;
465
466
  let {
467
    id,
468
  } = request;
469
  let responseCache = await connector.requestData(id, "responseCache");
470
  return responseCache;
471
}
472
460
/**
473
/**
461
 * This helper function is used for additional processing of
474
 * This helper function is used for additional processing of
462
 * incoming network update packets. It's used by Network and
475
 * incoming network update packets. It's used by Network and
463
 * Console panel reducers.
476
 * Console panel reducers.
464
 */
477
 */
465
function processNetworkUpdates(request = {}) {
478
function processNetworkUpdates(request = {}) {
466
  let result = {};
479
  let result = {};
467
  for (let [key, value] of Object.entries(request)) {
480
  for (let [key, value] of Object.entries(request)) {
 Lines 485-500   function processNetworkUpdates(request = {}) { Link Here 
485
    }
498
    }
486
  }
499
  }
487
  return result;
500
  return result;
488
}
501
}
489
502
490
module.exports = {
503
module.exports = {
491
  decodeUnicodeBase64,
504
  decodeUnicodeBase64,
492
  getFormDataSections,
505
  getFormDataSections,
506
  fetchCacheDescriptor,
493
  fetchHeaders,
507
  fetchHeaders,
494
  fetchNetworkUpdatePacket,
508
  fetchNetworkUpdatePacket,
495
  formDataURI,
509
  formDataURI,
496
  writeHeaderText,
510
  writeHeaderText,
497
  decodeUnicodeUrl,
511
  decodeUnicodeUrl,
498
  getAbbreviatedMimeType,
512
  getAbbreviatedMimeType,
499
  getEndTime,
513
  getEndTime,
500
  getFormattedProtocol,
514
  getFormattedProtocol,
(-)a/devtools/server/actors/webconsole.js (+37 lines)
Line     Link Here 
 Lines 1986-2001   function NetworkEventActor(webConsoleActor) { Link Here 
1986
  this._response = {
1986
  this._response = {
1987
    headers: [],
1987
    headers: [],
1988
    cookies: [],
1988
    cookies: [],
1989
    content: {},
1989
    content: {},
1990
  };
1990
  };
1991
1991
1992
  this._timings = {};
1992
  this._timings = {};
1993
  this._stackTrace = {};
1993
  this._stackTrace = {};
1994
  this._cache = {};
1994
1995
1995
  // Keep track of LongStringActors owned by this NetworkEventActor.
1996
  // Keep track of LongStringActors owned by this NetworkEventActor.
1996
  this._longStringActors = new Set();
1997
  this._longStringActors = new Set();
1997
}
1998
}
1998
1999
1999
NetworkEventActor.prototype =
2000
NetworkEventActor.prototype =
2000
{
2001
{
2001
  _request: null,
2002
  _request: null,
 Lines 2150-2165   NetworkEventActor.prototype = Link Here 
2150
      from: this.actorID,
2151
      from: this.actorID,
2151
      headers: this._response.headers,
2152
      headers: this._response.headers,
2152
      headersSize: this._response.headersSize,
2153
      headersSize: this._response.headersSize,
2153
      rawHeaders: this._response.rawHeaders,
2154
      rawHeaders: this._response.rawHeaders,
2154
    };
2155
    };
2155
  },
2156
  },
2156
2157
2157
  /**
2158
  /**
2159
   * The "getResponseCache" packet type handler.
2160
   * 
2161
   * @return object
2162
   *         The cache packet - network cache information.
2163
   */
2164
  onGetResponseCache: function() {
2165
    return {
2166
      from: this.actorID,
2167
      cache: this._response.responseCache,
2168
    };
2169
  },
2170
2171
  /**
2158
   * The "getResponseCookies" packet type handler.
2172
   * The "getResponseCookies" packet type handler.
2159
   *
2173
   *
2160
   * @return object
2174
   * @return object
2161
   *         The response packet - network response cookies.
2175
   *         The response packet - network response cookies.
2162
   */
2176
   */
2163
  onGetResponseCookies: function () {
2177
  onGetResponseCookies: function () {
2164
    return {
2178
    return {
2165
      from: this.actorID,
2179
      from: this.actorID,
 Lines 2405-2420   NetworkEventActor.prototype = Link Here 
2405
      encoding: content.encoding,
2419
      encoding: content.encoding,
2406
      transferredSize: content.transferredSize,
2420
      transferredSize: content.transferredSize,
2407
      discardResponseBody,
2421
      discardResponseBody,
2408
    };
2422
    };
2409
2423
2410
    this.conn.send(packet);
2424
    this.conn.send(packet);
2411
  },
2425
  },
2412
2426
2427
  addResponseCache: function(content) {
2428
    this._response.responseCache = content.responseCache;
2429
    let packet = {
2430
      from: this.actorID,
2431
      type: "networkEventUpdate",
2432
      updateType: "responseCache",
2433
    };
2434
2435
    this.conn.send(packet);
2436
  },
2437
2438
  addResponseCache: function(content) {
2439
    this._response.responseCache = content.responseCache;
2440
    let packet = {
2441
      from: this.actorID,
2442
      type: "networkEventUpdate",
2443
      updateType: "responseCache",
2444
    };
2445
2446
    this.conn.send(packet);
2447
  },
2448
2413
  /**
2449
  /**
2414
   * Add network event timing information.
2450
   * Add network event timing information.
2415
   *
2451
   *
2416
   * @param number total
2452
   * @param number total
2417
   *        The total time of the network event.
2453
   *        The total time of the network event.
2418
   * @param object timings
2454
   * @param object timings
2419
   *        Timing details about the network event.
2455
   *        Timing details about the network event.
2420
   */
2456
   */
 Lines 2453-2465   NetworkEventActor.prototype = Link Here 
2453
NetworkEventActor.prototype.requestTypes =
2489
NetworkEventActor.prototype.requestTypes =
2454
{
2490
{
2455
  "release": NetworkEventActor.prototype.onRelease,
2491
  "release": NetworkEventActor.prototype.onRelease,
2456
  "getRequestHeaders": NetworkEventActor.prototype.onGetRequestHeaders,
2492
  "getRequestHeaders": NetworkEventActor.prototype.onGetRequestHeaders,
2457
  "getRequestCookies": NetworkEventActor.prototype.onGetRequestCookies,
2493
  "getRequestCookies": NetworkEventActor.prototype.onGetRequestCookies,
2458
  "getRequestPostData": NetworkEventActor.prototype.onGetRequestPostData,
2494
  "getRequestPostData": NetworkEventActor.prototype.onGetRequestPostData,
2459
  "getResponseHeaders": NetworkEventActor.prototype.onGetResponseHeaders,
2495
  "getResponseHeaders": NetworkEventActor.prototype.onGetResponseHeaders,
2460
  "getResponseCookies": NetworkEventActor.prototype.onGetResponseCookies,
2496
  "getResponseCookies": NetworkEventActor.prototype.onGetResponseCookies,
2497
  "getResponseCache": NetworkEventActor.prototype.onGetResponseCache,
2461
  "getResponseContent": NetworkEventActor.prototype.onGetResponseContent,
2498
  "getResponseContent": NetworkEventActor.prototype.onGetResponseContent,
2462
  "getEventTimings": NetworkEventActor.prototype.onGetEventTimings,
2499
  "getEventTimings": NetworkEventActor.prototype.onGetEventTimings,
2463
  "getSecurityInfo": NetworkEventActor.prototype.onGetSecurityInfo,
2500
  "getSecurityInfo": NetworkEventActor.prototype.onGetSecurityInfo,
2464
  "getStackTrace": NetworkEventActor.prototype.onGetStackTrace,
2501
  "getStackTrace": NetworkEventActor.prototype.onGetStackTrace,
2465
};
2502
};
(-)a/devtools/shared/webconsole/client.js (+22 lines)
Line     Link Here 
 Lines 155-177   WebConsoleClient.prototype = { Link Here 
155
        break;
155
        break;
156
      case "responseContent":
156
      case "responseContent":
157
        networkInfo.response.content = {
157
        networkInfo.response.content = {
158
          mimeType: packet.mimeType,
158
          mimeType: packet.mimeType,
159
        };
159
        };
160
        networkInfo.response.bodySize = packet.contentSize;
160
        networkInfo.response.bodySize = packet.contentSize;
161
        networkInfo.response.transferredSize = packet.transferredSize;
161
        networkInfo.response.transferredSize = packet.transferredSize;
162
        networkInfo.discardResponseBody = packet.discardResponseBody;
162
        networkInfo.discardResponseBody = packet.discardResponseBody;
163
163
        break;
164
        break;
164
      case "eventTimings":
165
      case "eventTimings":
165
        networkInfo.totalTime = packet.totalTime;
166
        networkInfo.totalTime = packet.totalTime;
166
        break;
167
        break;
167
      case "securityInfo":
168
      case "securityInfo":
168
        networkInfo.securityInfo = packet.state;
169
        networkInfo.securityInfo = packet.state;
169
        break;
170
        break;
171
      case "responseCache":
172
        networkInfo.response.responseCache = packet.responseCache;
173
        break;
170
    }
174
    }
171
175
172
    this.emit("networkEventUpdate", {
176
    this.emit("networkEventUpdate", {
173
      packet: packet,
177
      packet: packet,
174
      networkInfo
178
      networkInfo
175
    });
179
    });
176
  },
180
  },
177
181
 Lines 542-557   WebConsoleClient.prototype = { Link Here 
542
    let packet = {
546
    let packet = {
543
      to: actor,
547
      to: actor,
544
      type: "getResponseContent",
548
      type: "getResponseContent",
545
    };
549
    };
546
    return this._client.request(packet, onResponse);
550
    return this._client.request(packet, onResponse);
547
  },
551
  },
548
552
549
  /**
553
  /**
554
   * Retrieve the response cache from the given NetworkEventActor
555
   * 
556
   * @param string actor
557
   *        The NetworkEventActor ID.
558
   * @param function onResponse
559
   *        The function invoked when the response is recieved.
560
   * @return request
561
   *         Request object that implements both Promise and EventEmitter interfaces.
562
   */
563
  getResponseCache: function (actor, onResponse) {
564
    let packet = {
565
      to: actor,
566
      type: "getResponseCache",
567
    };
568
    return this._client.request(packet, onResponse);
569
  },
570
571
  /**
550
   * Retrieve the timing information for the given NetworkEventActor.
572
   * Retrieve the timing information for the given NetworkEventActor.
551
   *
573
   *
552
   * @param string actor
574
   * @param string actor
553
   *        The NetworkEventActor ID.
575
   *        The NetworkEventActor ID.
554
   * @param function onResponse
576
   * @param function onResponse
555
   *        The function invoked when the response is received.
577
   *        The function invoked when the response is received.
556
   * @return request
578
   * @return request
557
   *         Request object that implements both Promise and EventEmitter interfaces
579
   *         Request object that implements both Promise and EventEmitter interfaces
(-)a/devtools/shared/webconsole/network-helper.js (-1 / +65 lines)
Line     Link Here 
 Lines 54-70    Link Here 
54
 *  Austin Andrews
54
 *  Austin Andrews
55
 *  Christoph Dorn
55
 *  Christoph Dorn
56
 *  Steven Roussey (AppCenter Inc, Network54)
56
 *  Steven Roussey (AppCenter Inc, Network54)
57
 *  Mihai Sucan (Mozilla Corp.)
57
 *  Mihai Sucan (Mozilla Corp.)
58
 */
58
 */
59
59
60
"use strict";
60
"use strict";
61
61
62
const {components, Cc, Ci} = require("chrome");
62
const {components, Cc, Ci, Cu} = require("chrome");
63
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
63
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
64
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
64
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
65
const Services = require("Services");
65
const Services = require("Services");
66
const { LocalizationHelper } = require("devtools/shared/l10n");
66
const { LocalizationHelper } = require("devtools/shared/l10n");
67
const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties");
67
const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties");
68
68
69
// The cache used in the `nsIURL` function.
69
// The cache used in the `nsIURL` function.
70
const gNSURLStore = new Map();
70
const gNSURLStore = new Map();
 Lines 499-514   var NetworkHelper = { Link Here 
499
      case "svg":
499
      case "svg":
500
      case "xml":
500
      case "xml":
501
        return true;
501
        return true;
502
502
503
      default:
503
      default:
504
        return false;
504
        return false;
505
    }
505
    }
506
  },
506
  },
507
  /**
508
   * Gets a cache entry for a request.
509
   * 
510
   * @param Object request
511
   * @param Object response
512
   * @param Function onCacheDescriptorAvailable
513
   */
514
  getCacheEntry: function(request, response, onCacheDescriptorAvailable) {
515
    let CacheService = Cc["@mozilla.org/network/cache-service;1"];
516
    let CacheStorageService = Cc["@mozilla.org/network/cache-storage-service;1"];
517
    if (CacheStorageService) {
518
      let cacheService = CacheStorageService.getService(Ci.nsICacheStorageService);
519
      let loadContext = Services.loadContextInfo.default;
520
      let cacheSession = cacheService.diskCacheStorage(loadContext, false);
521
      cacheSession.asyncOpenURI(this.nsIURL(request.URI.spec), "", Ci.nsICacheStorage.OPEN_NORMALLY, 
522
      {
523
        onCacheEntryCheck: function(entry, appcache) {
524
          return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
525
        },
526
        onCacheEntryAvailable: function(descriptor, isnew, appcache, status) {
527
          if (descriptor) {
528
            let cdescriptor = {
529
              dataSize: descriptor.storageDataSize,
530
              expires: descriptor.expirationTime,
531
              fetchCount: descriptor.fetchCount,
532
              lastFetched: descriptor.lastFetched,
533
              lastModified: descriptor.lastModified,
534
            };
535
            if (descriptor.deviceID) {
536
              cdescriptor["device"] = descriptor.deviceID;
537
            }
538
            onCacheDescriptorAvailable(cdescriptor);
539
          } else {
540
            onCacheDescriptorAvailable(null);
541
          }
542
          
543
        },
544
      });
545
    } else { // CacheStorageService does not exist.
546
      let oldICache = Ci["ns" + "ICache"];
547
      let cacheService = CacheService.getService(Ci.nsICacheService);
548
      let cacheSession = cacheService.createSession("HTTP", oldICache.STORE_ANYWHERE, true);
549
550
      cacheSession.asyncOpenCacheEntry(this.nsIURL(request.URI.spec), oldICache.ACCESS_READ, {
551
        onCacheEntryAvailable: function(descriptor, accessGranted, status) {
552
          if (descriptor) {
553
            let cdescriptor = {
554
              dataSize: descriptor.storageDataSize,
555
              expires: descriptor.expirationTime,
556
              fetchCount: descriptor.fetchCount,
557
              lastFetched: descriptor.lastFetched,
558
              lastModified: descriptor.lastModified,
559
            };
560
            if (descriptor.deviceID) {
561
              cdescriptor["device"] = descriptor.deviceID;
562
            }
563
            onCacheDescriptorAvailable(cdescriptor);
564
          } else {
565
            onCacheDescriptorAvailable(null);
566
          }
567
        }
568
      })
569
    }
570
  },
507
571
508
  /**
572
  /**
509
   * Takes a securityInfo object of nsIRequest, the nsIRequest itself and
573
   * Takes a securityInfo object of nsIRequest, the nsIRequest itself and
510
   * extracts security information from them.
574
   * extracts security information from them.
511
   *
575
   *
512
   * @param object securityInfo
576
   * @param object securityInfo
513
   *        The securityInfo object of a request. If null channel is assumed
577
   *        The securityInfo object of a request. If null channel is assumed
514
   *        to be insecure.
578
   *        to be insecure.
(-)a/devtools/shared/webconsole/network-monitor.js (-1 / +11 lines)
Line     Link Here 
 Lines 929-948   NetworkMonitor.prototype = { Link Here 
929
      // Service worker requests emits cached-reponse notification on non-e10s,
929
      // Service worker requests emits cached-reponse notification on non-e10s,
930
      // and we fake one on e10s.
930
      // and we fake one on e10s.
931
      let fromServiceWorker = this.interceptedChannels.has(channel);
931
      let fromServiceWorker = this.interceptedChannels.has(channel);
932
      this.interceptedChannels.delete(channel);
932
      this.interceptedChannels.delete(channel);
933
933
934
      // If this is a cached response, there never was a request event
934
      // If this is a cached response, there never was a request event
935
      // so we need to construct one here so the frontend gets all the
935
      // so we need to construct one here so the frontend gets all the
936
      // expected events.
936
      // expected events.
937
938
      
939
937
      let httpActivity = this._createNetworkEvent(channel, {
940
      let httpActivity = this._createNetworkEvent(channel, {
938
        fromCache: !fromServiceWorker,
941
        fromCache: !fromServiceWorker,
939
        fromServiceWorker: fromServiceWorker
942
        fromServiceWorker: fromServiceWorker
940
      });
943
      });
944
945
      NetworkHelper.getCacheEntry(channel, response, function(descriptor) {
946
        httpActivity.owner.addResponseCache({
947
          responseCache: descriptor,
948
        });
949
      });
950
941
      httpActivity.owner.addResponseStart({
951
      httpActivity.owner.addResponseStart({
942
        httpVersion: response.httpVersion,
952
        httpVersion: response.httpVersion,
943
        remoteAddress: "",
953
        remoteAddress: "",
944
        remotePort: "",
954
        remotePort: "",
945
        status: response.status,
955
        status: response.status,
946
        statusText: response.statusText,
956
        statusText: response.statusText,
947
        headersSize: 0,
957
        headersSize: 0,
948
      }, "", true);
958
      }, "", true);
 Lines 1899-1915   NetworkEventActorProxy.prototype = { Link Here 
1899
    return this;
1909
    return this;
1900
  }),
1910
  }),
1901
};
1911
};
1902
1912
1903
(function () {
1913
(function () {
1904
  // Listeners for new network event data coming from the NetworkMonitor.
1914
  // Listeners for new network event data coming from the NetworkMonitor.
1905
  let methods = ["addRequestHeaders", "addRequestCookies", "addRequestPostData",
1915
  let methods = ["addRequestHeaders", "addRequestCookies", "addRequestPostData",
1906
                 "addResponseStart", "addSecurityInfo", "addResponseHeaders",
1916
                 "addResponseStart", "addSecurityInfo", "addResponseHeaders",
1907
                 "addResponseCookies", "addResponseContent", "addEventTimings"];
1917
                 "addResponseCookies", "addResponseContent", "addResponseCache", "addEventTimings"];
1908
  let factory = NetworkEventActorProxy.methodFactory;
1918
  let factory = NetworkEventActorProxy.methodFactory;
1909
  for (let method of methods) {
1919
  for (let method of methods) {
1910
    NetworkEventActorProxy.prototype[method] = factory(method);
1920
    NetworkEventActorProxy.prototype[method] = factory(method);
1911
  }
1921
  }
1912
})();
1922
})();
1913
1923
1914
/**
1924
/**
1915
 * This is triggered by the child calling `setupInParent` when the child's network monitor
1925
 * This is triggered by the child calling `setupInParent` when the child's network monitor

Return to bug 859051