зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461271 - Copy POST data labelled wrongly for PUT/PATCH requests in network tab.r=Honza
MozReview-Commit-ID: 9WCfCh1T2lc --HG-- extra : rebase_source : 319a578df14e455c1960458d48851b1b9e5d67d7
This commit is contained in:
Родитель
e61f535377
Коммит
1ad6b152e7
|
@ -887,13 +887,13 @@ netmonitor.context.copyUrlParams=Copy URL Parameters
|
|||
# for the Copy URL Parameters menu item displayed in the context menu for a request
|
||||
netmonitor.context.copyUrlParams.accesskey=P
|
||||
|
||||
# LOCALIZATION NOTE (netmonitor.context.copyPostData): This is the label displayed
|
||||
# on the context menu that copies the selected request's post data
|
||||
netmonitor.context.copyPostData=Copy POST Data
|
||||
# LOCALIZATION NOTE (netmonitor.context.copyRequestData): This is the label displayed
|
||||
# on the context menu that copies the selected request's data
|
||||
netmonitor.context.copyRequestData=Copy %S Data
|
||||
|
||||
# LOCALIZATION NOTE (netmonitor.context.copyPostData.accesskey): This is the access key
|
||||
# for the Copy POST Data menu item displayed in the context menu for a request
|
||||
netmonitor.context.copyPostData.accesskey=D
|
||||
# LOCALIZATION NOTE (netmonitor.context.copyRequestData.accesskey): This is the access key
|
||||
# for the Copy POST/PATCH/PUT/DELETE Data menu item displayed in the context menu for a request
|
||||
netmonitor.context.copyRequestData.accesskey=D
|
||||
|
||||
# LOCALIZATION NOTE (netmonitor.context.copyAsCurl): This is the label displayed
|
||||
# on the context menu that copies the selected request as a cURL command.
|
||||
|
|
|
@ -70,8 +70,8 @@ class RequestListContextMenu {
|
|||
|
||||
copySubmenu.push({
|
||||
id: "request-list-context-copy-post-data",
|
||||
label: L10N.getStr("netmonitor.context.copyPostData"),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyPostData.accesskey"),
|
||||
label: L10N.getFormatStr("netmonitor.context.copyRequestData", method),
|
||||
accesskey: L10N.getStr("netmonitor.context.copyRequestData.accesskey"),
|
||||
// Menu item will be visible even if data hasn't arrived, so we need to check
|
||||
// *Available property and then fetch data lazily once user triggers the action.
|
||||
visible: !!(selectedRequest && (requestPostDataAvailable || requestPostData)),
|
||||
|
|
|
@ -48,10 +48,17 @@ add_task(async function() {
|
|||
await testCopyUrlParams(5, "a=b");
|
||||
await testCopyPostDataHidden(5, false);
|
||||
await testCopyPostData(5, "?foo=bar");
|
||||
await testCopyRequestDataLabel(5, "POST");
|
||||
|
||||
await testCopyUrlParamsHidden(6, true);
|
||||
await testCopyPostDataHidden(6, true);
|
||||
|
||||
await testCopyPostDataHidden(7, false);
|
||||
await testCopyRequestDataLabel(7, "PATCH");
|
||||
|
||||
await testCopyPostDataHidden(8, false);
|
||||
await testCopyRequestDataLabel(8, "PUT");
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function testCopyUrlParamsHidden(index, hidden) {
|
||||
|
@ -90,6 +97,17 @@ add_task(async function() {
|
|||
"be hidden.");
|
||||
}
|
||||
|
||||
function testCopyRequestDataLabel(index, method) {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll(".request-list-item")[index]);
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" },
|
||||
document.querySelectorAll(".request-list-item")[index]);
|
||||
const copyPostDataNode = monitor.panelWin.parent.document
|
||||
.querySelector("#request-list-context-copy-post-data");
|
||||
is(copyPostDataNode.attributes.label.value, "Copy " + method + " Data",
|
||||
"The \"Copy Data\" context menu item should have label - Copy " + method + " Data");
|
||||
}
|
||||
|
||||
async function testCopyPostData(index, postData) {
|
||||
// Wait for formDataSections and requestPostData state are ready in redux store
|
||||
// since copyPostData API needs to read these state.
|
||||
|
|
|
@ -31,20 +31,32 @@
|
|||
});
|
||||
}
|
||||
|
||||
async function post(address, query, contentType, postBody) {
|
||||
async function request(address, query, contentType, requestBody, method) {
|
||||
return new Promise(resolve => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", address + query, true);
|
||||
xhr.open(method, address + query, true);
|
||||
xhr.setRequestHeader("content-type", contentType);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (this.readyState == this.DONE) {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
xhr.send(postBody);
|
||||
xhr.send(requestBody);
|
||||
});
|
||||
}
|
||||
|
||||
async function post(address, query, contentType, postBody) {
|
||||
return request(address, query, contentType, postBody, "POST");
|
||||
}
|
||||
|
||||
async function patch(address, query, contentType, patchBody) {
|
||||
return request(address, query, contentType, patchBody, "PATCH");
|
||||
}
|
||||
|
||||
async function put(address, query, contentType, putBody) {
|
||||
return request(address, query, contentType, putBody, "PUT");
|
||||
}
|
||||
|
||||
async function performRequests() {
|
||||
const urlencoded = "application/x-www-form-urlencoded";
|
||||
await post("baz", "?a", urlencoded, '{ "foo": "bar" }');
|
||||
|
@ -54,6 +66,8 @@
|
|||
await post("baz", "?a=b", undefined, '{ "foo": "bar" }');
|
||||
await post("baz", "?a=b", undefined, "?foo=bar");
|
||||
await get("baz", "");
|
||||
await patch("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
|
||||
await put("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче