Skip to content

Commit

Permalink
lint, fix a test
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed May 31, 2024
1 parent 976a91c commit 9811633
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/lib/lantern/page-dependency-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,12 @@ class PageDependencyGraph {
/**
* TODO(15841): remove when CDT backend is gone. until then, this is a useful debugging tool
* to find delta between using CDP or the trace to create the network requests.
*
*
* When a test fails using the trace backend, I enabled this debug method and copied the network
* requests when CDP was used, then when trace is used, and diff'd them. This method helped
* remove non-logical differences from the comparison (order of properties, slight rounding
* discrepancies, removing object cycles, etc).
*
*
* When using for a unit test, make sure to do `.only` so you are getting what you expect.
* @param {Lantern.NetworkRequest[]} lanternRequests
* @return {never}
Expand Down
14 changes: 9 additions & 5 deletions core/test/create-test-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,21 @@ function createTestTrace(options) {
traceEvents.push(getTopLevelTask({ts: options.traceEnd - 1, duration: 1}));
}

// TODO(15841): why does "should estimate the FCP & LCP impact" in byte-efficiency-audit-test.js
// fail even when not creating records from trace? For now... just don't emit these events for
// when using CDP.
if (!process.env.INTERNAL_LANTERN_USE_TRACE) {
options.networkRecords = undefined;
}

const networkRecords = options.networkRecords || [];
for (const record of networkRecords) {
const willBeRedirected = networkRecords.some(r =>
r.requestId === record.requestId + ':redirect');
const requestId = record.requestId.replaceAll(':redirect', '');

const willSendTime = (record.rendererStartTime ?? record.networkRequestTime) * 10000;
const sendTime = record.networkRequestTime * 10000;
if (Number.isNaN(willSendTime) || Number.isNaN(sendTime)) {
throw new Error('bad times given');
}
const willSendTime = (record.rendererStartTime ?? record.networkRequestTime ?? 0) * 10000;
const sendTime = (record.networkRequestTime ?? 0) * 10000;

if (!willBeRedirected) {
traceEvents.push({
Expand Down

0 comments on commit 9811633

Please sign in to comment.