Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/support/har/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ export function getFullyLoaded(har) {

let pageEntries = [...entries];
pageEntries = pageEntries.filter(entry => entry.pageref === pageId);
// Skip pages without any requests, like the empty HAR
// that is added for a failing iteration
if (pageEntries.length === 0) continue;

let pageEnd = 0;
for (let entry of pageEntries) {
Expand Down
23 changes: 22 additions & 1 deletion test/unittests/harBuilderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const { serial } = test;
import {
addCreator,
mergeHars,
addExtraFieldsToHar
addExtraFieldsToHar,
getEmptyHAR,
getFullyLoaded
} from '../../lib/support/har/index.js';

let har;
Expand Down Expand Up @@ -311,6 +313,25 @@ test('Omit `_longTasks` entirely when pageinfo has no longTask field', t => {
t.is(har.log.pages[0].pageTimings._longTasks, undefined);
});

test('Skip pages without entries when getting fully loaded', t => {
// A failing iteration adds an empty HAR (without _url) that
// should not end up as a page without an URL in the result
har.log.pages[0]._url = 'https://example.com';
har.log.pages[0].startedDateTime = '2026-08-09T06:46:00.000Z';
har.log.entries[0].startedDateTime = '2026-08-09T06:46:00.100Z';
har.log.entries[0].time = 200;

const merged = mergeHars([
har,
getEmptyHAR('https://example.com', 'Firefox')
]);
const fullyLoaded = getFullyLoaded(merged);

t.is(fullyLoaded.length, 1);
t.is(fullyLoaded[0].url, 'https://example.com');
t.is(fullyLoaded[0].fullyLoaded, 300);
});

test('Tag the first entry of each page with `_documentURL`', t => {
// Cross-origin tinting in waterfall-tools reads `entries[0]._documentURL`
// to decide which request labels are third-party — without this, the
Expand Down
Loading