mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
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
This commit is contained in:
parent
38a2b5eaf8
commit
f71621d402
@ -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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user