Skip to content

Commit

Permalink
startAt needs to be walltime
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Sep 18, 2024
1 parent 7a251be commit b717257
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export abstract class APIRequestContext extends SdkObject {
const requestOptions = { ...options, agent };

const startAt = monotonicTime();
const startAtWallTime = Date.now();
let dnsLookupAt: number | undefined;
let tcpConnectionAt: number | undefined;
let tlsHandshakeAt: number | undefined;
Expand Down Expand Up @@ -441,7 +442,7 @@ export abstract class APIRequestContext extends SdkObject {
const endAt = monotonicTime();
// spec: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
const timing: channels.ResourceTiming = {
startTime: startAt,
startTime: startAtWallTime,
domainLookupStart: dnsLookupAt ? 0 : -1,
domainLookupEnd: dnsLookupAt ? dnsLookupAt! - startAt : -1,
connectStart: dnsLookupAt ? dnsLookupAt! - startAt : 0,
Expand Down
1 change: 1 addition & 0 deletions tests/library/browsercontext-fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ it('fetch should work', async ({ context, server }) => {
secureConnectionStart: expect.any(Number),
startTime: expect.any(Number),
});
expect(response.timing().startTime, 'is right order of magnitude').toBeCloseTo(Date.now(), -3);
expect(await response.text()).toBe('{"foo": "bar"}\n');
});

Expand Down

0 comments on commit b717257

Please sign in to comment.