add_task(async function () { // the initNetMonitor function clears the network request list after the // page is loaded. That's why we first load a bogus page from SIMPLE_URL, // and only then load the real thing from TOP_URL - we want to catch // all the requests the page is making, not only the XHRs. // We can't use about:blank here, because initNetMonitor checks that the // page has actually made at least one request. const { monitor } = await initNetMonitor(SIMPLE_URL, { requestCount: 1 });
is(
store.getState().requests.requests.length,
REQUEST_COUNT, "All the page events should be recorded."
);
// Fetch stack-trace data from the backend and wait till // all packets are received. const requests = getSortedRequests(store.getState());
await Promise.all(
requests.map(requestItem =>
connector.requestData(requestItem.id, "stackTrace")
)
);
// While there is a defined order for requests in each document separately, the requests // from different documents may interleave in various ways that change per test run, so // there is not a single order when considering all the requests together.
let currentTop = 0;
let currentSub = 0; for (let i = 0; i < REQUEST_COUNT; i++) { const requestItem = getSortedRequests(store.getState())[i];
if (stack) {
ok(stacktrace, `Request #${i} has a stacktrace`); Assert.greater(
stackLen,
0,
`Request #${i} (${causeType}) has a stacktrace with ${stackLen} items`
);
// if "stack" is array, check the details about the top stack frames if (Array.isArray(stack)) {
stack.forEach((frame, j) => {
is(
stacktrace[j].functionName,
frame.fn,
`Request #${i} has the correct function on JS stack frame #${j}`
);
is(
stacktrace[j].filename.split("/").pop(),
frame.file,
`Request #${i} has the correct file on JS stack frame #${j}`
);
is(
stacktrace[j].lineNumber,
frame.line,
`Request #${i} has the correct line number on JS stack frame #${j}`
);
is(
stacktrace[j].asyncCause,
frame.asyncCause,
`Request #${i} has the correct async cause on JS stack frame #${j}`
);
});
}
} else {
is(stackLen, 0, `Request #${i} (${causeType}) has an empty stacktrace`);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.