Commit f71621d4 authored by Vincent Lequertier's avatar Vincent Lequertier
Browse files

Bug 1451494 - Simplify edition of the "method" field in netmonitor edit and resend panel; r=Honza

Differential Revision: https://phabricator.services.mozilla.com/D6981

--HG--
extra : moz-landing-system : lando
parent 38a2b5ea
......@@ -50,6 +50,7 @@ class CustomRequestPanel extends Component {
componentDidMount() {
const { request, connector } = this.props;
this.initialRequestMethod = request.method;
fetchNetworkUpdatePacket(connector.requestData, request, [
"requestHeaders",
"responseHeaders",
......@@ -109,7 +110,11 @@ class CustomRequestPanel extends Component {
};
break;
case "custom-method-value":
data = { method: val.trim() };
// If val is empty when leaving the "method" field, set the method to
// its original value
data = (evt.type === "blur" && val === "") ?
{ method: this.initialRequestMethod } :
{ method: val.trim() };
break;
case "custom-postdata-value":
data = {
......@@ -212,7 +217,9 @@ class CustomRequestPanel extends Component {
id: "custom-method-value",
onChange: (evt) =>
this.updateCustomRequestFields(evt, request, updateRequest),
value: method || "GET",
onBlur: (evt) =>
this.updateCustomRequestFields(evt, request, updateRequest),
value: method,
}),
input({
className: "custom-url-value",
......
......@@ -7,7 +7,8 @@
/**
* Tests if position of caret does not change (resets to the end) after setting
* header's value to empty string.
* header's value to empty string. Also make sure the "method" field stays empty
* after removing it and resets to its original value when it looses focus.
*/
add_task(async function() {
......@@ -37,6 +38,9 @@ add_task(async function() {
contextResend.click();
await waitUntil(() => document.querySelector("#custom-headers-value"));
const headersTextarea = document.querySelector("#custom-headers-value");
await waitUntil(() => document.querySelector("#custom-method-value"));
const methodField = document.querySelector("#custom-method-value");
const originalMethodValue = methodField.value;
const {
getSelectedRequest
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
......@@ -54,6 +58,10 @@ add_task(async function() {
headersTextarea.setSelectionRange(start, end);
EventUtils.synthesizeKey("VK_DELETE", {});
methodField.focus();
methodField.select();
EventUtils.synthesizeKey("VK_DELETE", {});
ok(getSelectedRequest(store.getState()).requestHeaders.headers[0] !== hostHeader,
"Value of Host header was edited and should change"
);
......@@ -62,5 +70,15 @@ add_task(async function() {
"Position of caret should not change"
);
ok(getSelectedRequest(store.getState()).method === "",
"Value of method header was deleted and should be empty"
);
headersTextarea.focus();
ok(getSelectedRequest(store.getState()).method === originalMethodValue,
"Value of method header should reset to its original value"
);
return teardown(monitor);
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment