Bug 1365635 - Fix payload queue and damp regression r=Honza

MozReview-Commit-ID: 4mW6pH2CeQN

--HG--
extra : rebase_source : b4d3c6312e1ef5354c124067f42f79748d52d9d4
This commit is contained in:
Ricky Chien 2017-05-17 23:53:00 +08:00
Родитель edfc95cb55
Коммит 52a8cbb4a3
1 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -13,6 +13,10 @@ const { fetchHeaders, formDataURI } = require("../utils/request-utils");
class FirefoxConnector {
constructor() {
// Internal properties
this.payloadQueue = [];
// Public methods
this.connect = this.connect.bind(this);
this.disconnect = this.disconnect.bind(this);
this.willNavigate = this.willNavigate.bind(this);
@ -55,7 +59,7 @@ class FirefoxConnector {
this.actions = actions;
this.getState = getState;
this.tabTarget = connection.tabConnection.tabTarget;
this.tabClient = this.tabTarget.isTabActor ? this.tabTarget.activeTab : null;
this.webConsoleClient = this.tabTarget.activeConsole;
this.tabTarget.on("will-navigate", this.willNavigate);
@ -75,18 +79,22 @@ class FirefoxConnector {
}
async disconnect() {
// When debugging local or a remote instance, the connection is closed by
// the RemoteTarget. The webconsole actor is stopped on disconnect.
this.tabClient = null;
this.webConsoleClient = null;
this.actions.batchReset();
// The timeline front wasn't initialized and started if the server wasn't
// recent enough to emit the markers we were interested in.
if (this.tabTarget.getTrait("documentLoadingMarkers") && this.timelineFront) {
this.timelineFront.off("doc-loading", this.onDocLoadingMarker);
await this.timelineFront.destroy();
this.timelineFront = null;
}
this.tabTarget.off("will-navigate");
this.tabTarget.off("close");
this.tabTarget = null;
this.webConsoleClient.off("networkEvent");
this.webConsoleClient.off("networkEventUpdate");
this.webConsoleClient = null;
this.timelineFront = null;
}
willNavigate() {
@ -197,7 +205,12 @@ class FirefoxConnector {
let payload = Object.assign({}, data,
imageObj, requestHeadersObj, responseHeadersObj,
postDataObj, requestCookiesObj, responseCookiesObj);
await this.actions.updateRequest(id, payload, true);
this.pushPayloadToQueue(id, payload);
if (this.isQueuePayloadReady(id)) {
await this.actions.updateRequest(id, this.getPayloadFromQueue(id).payload, true);
}
}
async fetchImage(mimeType, responseContent) {