зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1441792
- add waitForRequestData to netmonitor test head r=Honza,ochameau
MozReview-Commit-ID: 9xyKuCdXZfa --HG-- extra : rebase_source : 83a510bdb1918a086d78b1a58cac4c2e9442a461
This commit is contained in:
Родитель
aa7e884402
Коммит
d29e11bfbd
|
@ -12,9 +12,6 @@ add_task(async function() {
|
|||
|
||||
let { document, store, windowRequire } = monitor.panelWin;
|
||||
let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
let {
|
||||
getSortedRequests,
|
||||
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
|
||||
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
|
@ -27,10 +24,7 @@ add_task(async function() {
|
|||
document.querySelectorAll(".request-list-item")[0]);
|
||||
await wait;
|
||||
|
||||
await waitUntil(() => {
|
||||
let request = getSortedRequests(store.getState()).get(0);
|
||||
return request.requestHeaders && request.responseHeaders;
|
||||
});
|
||||
await waitForRequestData(store, ["requestHeaders", "responseHeaders"]);
|
||||
|
||||
document.querySelectorAll(".devtools-filterinput")[1].focus();
|
||||
EventUtils.synthesizeKey("con", {});
|
||||
|
|
|
@ -32,10 +32,7 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
async function verifyHeaders(monitor) {
|
||||
let { document, store, windowRequire } = monitor.panelWin;
|
||||
let {
|
||||
getSortedRequests,
|
||||
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
|
||||
let { document, store } = monitor.panelWin;
|
||||
|
||||
info("Check if Request-Headers and Response-Headers are sorted");
|
||||
|
||||
|
@ -44,10 +41,7 @@ async function verifyHeaders(monitor) {
|
|||
document.querySelectorAll(".request-list-item")[0]);
|
||||
await wait;
|
||||
|
||||
await waitUntil(() => {
|
||||
let request = getSortedRequests(store.getState()).get(0);
|
||||
return request.requestHeaders && request.responseHeaders;
|
||||
});
|
||||
await waitForRequestData(store, ["requestHeaders", "responseHeaders"]);
|
||||
|
||||
let expectedResponseHeaders = ["cache-control", "connection", "content-length",
|
||||
"content-type", "date", "expires", "foo-bar",
|
||||
|
|
|
@ -21,7 +21,6 @@ add_task(async function() {
|
|||
let {
|
||||
getSelectedRequest,
|
||||
getSortedRequests,
|
||||
getRequestById
|
||||
} = windowRequire("devtools/client/netmonitor/src/selectors/index");
|
||||
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
@ -32,13 +31,13 @@ add_task(async function() {
|
|||
let origItemId = getSortedRequests(store.getState()).get(0).id;
|
||||
|
||||
store.dispatch(Actions.selectRequest(origItemId));
|
||||
await waitForRequestHeaders(origItemId);
|
||||
await waitForRequestData(store, ["requestHeaders", "requestPostData"], origItemId);
|
||||
|
||||
let origItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
// add a new custom request cloned from selected request
|
||||
store.dispatch(Actions.cloneSelectedRequest());
|
||||
|
||||
store.dispatch(Actions.cloneSelectedRequest());
|
||||
await testCustomForm(origItem);
|
||||
|
||||
let customItem = getSelectedRequest(store.getState());
|
||||
|
@ -82,13 +81,6 @@ add_task(async function() {
|
|||
is(item.url, orig.url, "item is showing the same URL as original request");
|
||||
}
|
||||
|
||||
function waitForRequestHeaders(id) {
|
||||
return waitUntil(() => {
|
||||
const item = getRequestById(store.getState(), id);
|
||||
return item.requestHeaders && item.requestPostData;
|
||||
});
|
||||
}
|
||||
|
||||
function testCustomItemChanged(item, orig) {
|
||||
let url = item.url;
|
||||
let expectedUrl = orig.url + "&" + ADD_QUERY;
|
||||
|
|
|
@ -48,11 +48,9 @@ add_task(async function() {
|
|||
}
|
||||
|
||||
// Wait until requestHeaders packet gets updated.
|
||||
await waitUntil(() => {
|
||||
item = getSortedRequests(store.getState()).get(0);
|
||||
return item.requestHeaders;
|
||||
});
|
||||
await waitForRequestData(store, ["requestHeaders"]);
|
||||
|
||||
item = getSortedRequests(store.getState()).get(0);
|
||||
is(item.method, "POST", "The request has the right method");
|
||||
is(item.url, requestUrl, "The request has the right URL");
|
||||
|
||||
|
|
|
@ -104,10 +104,7 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.RECEIVED_REQUEST_HEADERS, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.requestHeaders;
|
||||
});
|
||||
await waitForRequestData(store, ["requestHeaders"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -130,10 +127,7 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.RECEIVED_REQUEST_COOKIES, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.requestCookies;
|
||||
});
|
||||
await waitForRequestData(store, ["requestCookies"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -156,10 +150,7 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.RECEIVED_RESPONSE_HEADERS, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.responseHeaders;
|
||||
});
|
||||
await waitForRequestData(store, ["responseHeaders"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -180,10 +171,7 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.RECEIVED_RESPONSE_COOKIES, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.responseCookies;
|
||||
});
|
||||
await waitForRequestData(store, ["responseCookies"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -202,14 +190,12 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.STARTED_RECEIVING_RESPONSE, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem &&
|
||||
requestItem.httpVersion &&
|
||||
requestItem.status &&
|
||||
requestItem.statusText &&
|
||||
requestItem.headersSize;
|
||||
});
|
||||
await waitForRequestData(store, [
|
||||
"httpVersion",
|
||||
"status",
|
||||
"statusText",
|
||||
"headersSize"
|
||||
]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -242,13 +228,11 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.PAYLOAD_READY, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem &&
|
||||
requestItem.transferredSize &&
|
||||
requestItem.contentSize &&
|
||||
requestItem.mimeType;
|
||||
});
|
||||
await waitForRequestData(store, [
|
||||
"transferredSize",
|
||||
"contentSize",
|
||||
"mimeType"
|
||||
]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -275,10 +259,7 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.UPDATING_EVENT_TIMINGS, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.eventTimings;
|
||||
});
|
||||
await waitForRequestData(store, ["eventTimings"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
@ -300,10 +281,7 @@ function test() {
|
|||
});
|
||||
|
||||
expectEvent(EVENTS.RECEIVED_EVENT_TIMINGS, async () => {
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.eventTimings;
|
||||
});
|
||||
await waitForRequestData(store, ["eventTimings"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ async function throttleTest(actuallyThrottle) {
|
|||
await triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_DISABLED);
|
||||
await wait;
|
||||
|
||||
await waitUntil(() => {
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
return requestItem && requestItem.eventTimings;
|
||||
});
|
||||
await waitForRequestData(store, ["eventTimings"]);
|
||||
|
||||
let requestItem = getSortedRequests(store.getState()).get(0);
|
||||
const reportedOneSecond = requestItem.eventTimings.timings.receive > 1000;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
/* exported Toolbox, restartNetMonitor, teardown, waitForExplicitFinish,
|
||||
verifyRequestItemTarget, waitFor, testFilterButtons,
|
||||
performRequestsInContent, waitForNetworkEvents, selectIndexAndWaitForSourceEditor,
|
||||
testColumnsAlignment, hideColumn, showColumn, performRequests */
|
||||
testColumnsAlignment, hideColumn, showColumn, performRequests, waitForRequestData */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -18,6 +18,12 @@ const {
|
|||
getFormattedIPAndPort,
|
||||
getFormattedTime,
|
||||
} = require("devtools/client/netmonitor/src/utils/format-utils");
|
||||
|
||||
const {
|
||||
getSortedRequests,
|
||||
getRequestById
|
||||
} = require("devtools/client/netmonitor/src/selectors/index");
|
||||
|
||||
const {
|
||||
getUnicodeUrl,
|
||||
getUnicodeHostname,
|
||||
|
@ -764,3 +770,30 @@ async function performRequests(monitor, tab, count) {
|
|||
});
|
||||
await wait;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for lazy fields to be loaded in a request.
|
||||
*
|
||||
* @param Object Store redux store containing request list.
|
||||
* @param array fields array of strings which contain field names to be checked
|
||||
* on the request.
|
||||
*/
|
||||
function waitForRequestData(store, fields, id) {
|
||||
return waitUntil(() => {
|
||||
let item;
|
||||
if (id) {
|
||||
item = getRequestById(store.getState(), id);
|
||||
} else {
|
||||
item = getSortedRequests(store.getState()).get(0);
|
||||
}
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
for (const field of fields) {
|
||||
if (!item[field]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче