зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1328532 - Refactor updateRequest to fetch full text r=jsnajdr
MozReview-Commit-ID: mqLIWLs0xM --HG-- extra : rebase_source : b1c77b81baaaad815810fa169d7c61ba2fbdb6d7
This commit is contained in:
Родитель
f107b85dcc
Коммит
99073c5977
|
@ -711,6 +711,12 @@ NetworkEventsHandler.prototype = {
|
|||
* are available, or rejected if something goes wrong.
|
||||
*/
|
||||
getString: function (stringGrip) {
|
||||
// FIXME: this.webConsoleClient will be undefined in mochitest,
|
||||
// so we return string instantly to skip undefined error
|
||||
if (typeof stringGrip === "string") {
|
||||
return Promise.resolve(stringGrip);
|
||||
}
|
||||
|
||||
return this.webConsoleClient.getString(stringGrip);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -208,30 +208,25 @@ RequestsMenuView.prototype = {
|
|||
|
||||
if (responseContent && responseContent.content) {
|
||||
let request = getRequestById(this.store.getState(), action.id);
|
||||
let { text, encoding } = responseContent.content;
|
||||
if (request) {
|
||||
let { mimeType } = request;
|
||||
let { text, encoding } = responseContent.content;
|
||||
let response = yield gNetwork.getString(text);
|
||||
let payload = {};
|
||||
|
||||
if (mimeType.includes("image/")) {
|
||||
payload.responseContentDataUri = formDataURI(mimeType, encoding, response);
|
||||
}
|
||||
|
||||
if (mimeType.includes("text/")) {
|
||||
responseContent.content.text = response;
|
||||
payload.responseContent = responseContent;
|
||||
}
|
||||
|
||||
yield this.store.dispatch(Actions.updateRequest(action.id, payload, true));
|
||||
|
||||
// Fetch response data if the response is an image (to display thumbnail)
|
||||
if (mimeType.includes("image/")) {
|
||||
let responseBody = yield gNetwork.getString(text);
|
||||
const dataUri = formDataURI(mimeType, encoding, responseBody);
|
||||
yield this.store.dispatch(Actions.updateRequest(
|
||||
action.id,
|
||||
{ responseContentDataUri: dataUri },
|
||||
true
|
||||
));
|
||||
window.emit(EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED);
|
||||
// Fetch response text only if the response is html, but not all text/*
|
||||
} else if (mimeType.includes("text/html") && typeof text !== "string") {
|
||||
let responseBody = yield gNetwork.getString(text);
|
||||
responseContent.content.text = responseBody;
|
||||
responseContent = Object.assign({}, responseContent);
|
||||
yield this.store.dispatch(Actions.updateRequest(
|
||||
action.id,
|
||||
{ responseContent },
|
||||
true
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,9 +240,12 @@ RequestsMenuView.prototype = {
|
|||
const headersSize = headers.reduce((acc, { name, value }) => {
|
||||
return acc + name.length + value.length + 2;
|
||||
}, 0);
|
||||
yield this.store.dispatch(Actions.updateRequest(action.id, {
|
||||
requestHeadersFromUploadStream: { headers, headersSize }
|
||||
}, true));
|
||||
let payload = {};
|
||||
requestPostData.postData.text = postData;
|
||||
payload.requestPostData = Object.assign({}, requestPostData);
|
||||
payload.requestHeadersFromUploadStream = { headers, headersSize };
|
||||
|
||||
yield this.store.dispatch(Actions.updateRequest(action.id, payload, true));
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ add_task(function* () {
|
|||
gStore } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
let wait = waitForEvents();
|
||||
yield performRequests();
|
||||
yield wait;
|
||||
|
|
|
@ -51,9 +51,9 @@ add_task(function* () {
|
|||
// the hls-m3u8 part
|
||||
testEditorContent(editor, REQUESTS[0]);
|
||||
|
||||
wait = panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
yield panelWin.once(panelWin.EVENTS.TAB_UPDATED);
|
||||
yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
yield wait;
|
||||
|
||||
// the mpeg-dash part
|
||||
testEditorContent(editor, REQUESTS[1]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче