From da22fde827d76b27543da9880ae572656cbcbba2 Mon Sep 17 00:00:00 2001 From: Jan Odvarko Date: Thu, 8 Mar 2018 10:07:45 +0100 Subject: [PATCH] Bug 1434855 - Refactor HAR builder options; r=ochameau MozReview-Commit-ID: FRcxp4XPFdf --HG-- extra : rebase_source : 4b88ddf3b5c14b0d9f1cb8f71018cd556ebbe353 --- devtools/client/netmonitor/initializer.js | 19 ++-------------- .../client/netmonitor/src/har/har-exporter.js | 22 +++++++++++++++++-- .../src/widgets/RequestListContextMenu.js | 13 +---------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/devtools/client/netmonitor/initializer.js b/devtools/client/netmonitor/initializer.js index c6b4d02815d8..0b422f5fa966 100644 --- a/devtools/client/netmonitor/initializer.js +++ b/devtools/client/netmonitor/initializer.js @@ -105,21 +105,11 @@ window.Netmonitor = { */ getHar() { let { HarExporter } = require("devtools/client/netmonitor/src/har/har-exporter"); - let { - getLongString, - getTabTarget, - getTimingMarker, - requestData, - } = connector; - let { form: { title, url } } = getTabTarget(); let state = store.getState(); let options = { - getString: getLongString, + connector, items: getSortedRequests(state), - requestData, - getTimingMarker, - title: title || url, }; return HarExporter.getHar(options); @@ -136,13 +126,8 @@ window.Netmonitor = { } let { HarExporter } = require("devtools/client/netmonitor/src/har/har-exporter"); - let { getLongString, getTabTarget, requestData } = connector; - let { form: { title, url } } = getTabTarget(); - let options = { - getString: getLongString, - requestData, - title: title || url, + connector, includeResponseBodies: false, items: [getDisplayedRequestById(store.getState(), requestId)], }; diff --git a/devtools/client/netmonitor/src/har/har-exporter.js b/devtools/client/netmonitor/src/har/har-exporter.js index cf95fd74cdf0..dd15d6c5a218 100644 --- a/devtools/client/netmonitor/src/har/har-exporter.js +++ b/devtools/client/netmonitor/src/har/har-exporter.js @@ -186,10 +186,28 @@ const HarExporter = { * since it can involve additional RDP communication (e.g. resolving * long strings). */ - buildHarData: function (options) { + buildHarData: async function (options) { + let { connector } = options; + let { + getTabTarget, + } = connector; + let { + form: { title, url } + } = getTabTarget(); + + options = { + ...options, + title: title || url, + getString: connector.getLongString, + getTimingMarker: connector.getTimingMarker, + requestData: connector.requestData, + }; + // Build HAR object from collected data. let builder = new HarBuilder(options); - return builder.build(); + let result = await builder.build(); + + return result; }, /** diff --git a/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js b/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js index be953a86516e..85191c5f2b46 100644 --- a/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js +++ b/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js @@ -409,20 +409,9 @@ class RequestListContextMenu { } getDefaultHarOptions(sortedRequests) { - let { - getLongString, - getTabTarget, - requestData, - getTimingMarker, - } = this.props.connector; - let { form: { title, url } } = getTabTarget(); - return { - getString: getLongString, + connector: this.props.connector, items: sortedRequests, - requestData, - getTimingMarker, - title: title || url, }; } }