зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1755464 - [devtools] Adds test for clear button of the new HTTP Custom request panel r=bomsy
Differential Revision: https://phabricator.services.mozilla.com/D139753
This commit is contained in:
Родитель
1d1ba585a6
Коммит
eb82038342
|
@ -10,6 +10,8 @@
|
|||
add_task(async function() {
|
||||
// Turn true the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
||||
// Resetting the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResendState", "");
|
||||
|
||||
const { monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
|
||||
requestCount: 1,
|
||||
|
@ -72,6 +74,11 @@ add_task(async function() {
|
|||
*/
|
||||
|
||||
add_task(async function() {
|
||||
// Turn true the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
||||
// Resetting the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResendState", "");
|
||||
|
||||
const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
|
||||
requestCount: 1,
|
||||
});
|
||||
|
@ -85,8 +92,6 @@ add_task(async function() {
|
|||
|
||||
await performRequests(monitor, tab, 1);
|
||||
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
||||
|
||||
info("selecting first request");
|
||||
const firstRequestItem = document.querySelectorAll(".request-list-item")[0];
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequestItem);
|
||||
|
@ -121,6 +126,11 @@ add_task(async function() {
|
|||
*/
|
||||
|
||||
add_task(async function() {
|
||||
// Turn true the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
||||
// Resetting the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResendState", "");
|
||||
|
||||
const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
|
||||
requestCount: 1,
|
||||
});
|
||||
|
@ -134,8 +144,6 @@ add_task(async function() {
|
|||
|
||||
await performRequests(monitor, tab, 2);
|
||||
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
||||
|
||||
info("selecting first request");
|
||||
const firstRequestItem = document.querySelectorAll(".request-list-item")[0];
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequestItem);
|
||||
|
@ -162,3 +170,81 @@ add_task(async function() {
|
|||
);
|
||||
await teardown(monitor);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test cleaning a custom request.
|
||||
*/
|
||||
add_task(async function() {
|
||||
// Turn on the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
||||
// Resetting the pref
|
||||
await pushPref("devtools.netmonitor.features.newEditAndResendState", "");
|
||||
|
||||
const { monitor, tab } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
|
||||
requestCount: 1,
|
||||
});
|
||||
info("Starting test... ");
|
||||
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
|
||||
// Action should be processed synchronously in tests.
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
const { getSelectedRequest } = windowRequire(
|
||||
"devtools/client/netmonitor/src/selectors/index"
|
||||
);
|
||||
|
||||
await performRequests(monitor, tab, 1);
|
||||
|
||||
info("selecting first request");
|
||||
const firstRequestItem = document.querySelectorAll(".request-list-item")[0];
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequestItem);
|
||||
EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequestItem);
|
||||
|
||||
info("Opening the new request panel");
|
||||
const waitForPanels = waitForDOM(
|
||||
document,
|
||||
".monitor-panel .network-action-bar"
|
||||
);
|
||||
getContextMenuItem(monitor, "request-list-context-resend").click();
|
||||
await waitForPanels;
|
||||
|
||||
const request = getSelectedRequest(store.getState());
|
||||
|
||||
// Check if the panel is updated with the content by the request clicked
|
||||
const urlValue = document.querySelector(".http-custom-url-value");
|
||||
is(
|
||||
urlValue.textContent,
|
||||
request.url,
|
||||
"The URL in the form should match the request we clicked"
|
||||
);
|
||||
|
||||
info("Clicking on the clear button");
|
||||
document.querySelector("#http-custom-request-clear-button").click();
|
||||
is(
|
||||
document.querySelector(".http-custom-method-value").value,
|
||||
"GET",
|
||||
"The method input should be 'GET' by default"
|
||||
);
|
||||
is(
|
||||
document.querySelector(".http-custom-url-value").textContent,
|
||||
"",
|
||||
"The URL input should be empty"
|
||||
);
|
||||
const urlParametersValue = document.querySelectorAll(
|
||||
"#http-custom-query .tabpanel-summary-container.http-custom-input"
|
||||
);
|
||||
is(urlParametersValue.length, 0, "The URL Parameters input should be empty");
|
||||
const headersValue = document.querySelectorAll(
|
||||
"#http-custom-headers .tabpanel-summary-container.http-custom-input"
|
||||
);
|
||||
is(headersValue.length, 0, "The Headers input should be empty");
|
||||
is(
|
||||
document.querySelector("#http-custom-postdata-value").textContent,
|
||||
"",
|
||||
"The Post body input should be empty"
|
||||
);
|
||||
|
||||
await teardown(monitor);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче