Skip to content
Merged
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
17 changes: 9 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,15 @@ export function harFromMessages(messages, options) {
_resourceType: params.type ? params.type.toLowerCase() : undefined
};

// CDP `renderBlockingStatus` (Chrome 108+) — values are PascalCase
// (`Blocking`, `NonBlocking`, `InBodyParserBlocking`, `Potentially…`).
// waterfall-tools' WPT-style renderer matches `_renderBlocking ===
// 'blocking'` to draw the orange ⊗ marker, so lowercase the value
// here. Other variants ride along verbatim-lowercased for any
// consumer that wants to inspect them.
if (params.renderBlockingStatus) {
entry._renderBlocking = params.renderBlockingStatus.toLowerCase();
// CDP per-request render-blocking classification (Chrome 108+).
// The field lives at `Network.requestWillBeSent.params.renderBlockingBehavior`
// and its values are PascalCase (`Blocking`, `NonBlocking`,
// `NonBlockingDynamic`, …). waterfall-tools' WPT-style renderer
// matches `_renderBlocking === 'blocking'` to draw the orange ⊗
// marker, so lowercase the value here; other variants ride along
// verbatim-lowercased for any consumer that wants to inspect them.
if (params.renderBlockingBehavior) {
entry._renderBlocking = params.renderBlockingBehavior.toLowerCase();
}

// The object initiator change according to its type
Expand Down
25 changes: 21 additions & 4 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ test('Parses IPv6 address', t => {
);
});

test('Lifts CDP renderBlockingStatus onto entries as `_renderBlocking`', t => {
test('Lifts CDP renderBlockingBehavior onto entries as `_renderBlocking`', t => {
// Minimal synthetic CDP stream: one render-blocking document + one
// non-blocking subresource. The renderer in waterfall-tools matches
// `_renderBlocking === 'blocking'` (lowercase) to draw the orange ⊗
// marker, so we assert the casing here too.
const frameId = 'F1';
const baseMessages = (requestId, url, renderBlockingStatus) => [
const baseMessages = (requestId, url, renderBlockingBehavior) => [
{
method: 'Network.requestWillBeSent',
params: {
Expand All @@ -154,7 +154,7 @@ test('Lifts CDP renderBlockingStatus onto entries as `_renderBlocking`', t => {
wallTime: 1_700_000_000,
initiator: { type: 'other' },
type: requestId === '1' ? 'Document' : 'Script',
...(renderBlockingStatus ? { renderBlockingStatus } : {})
...(renderBlockingBehavior ? { renderBlockingBehavior } : {})
}
},
{
Expand Down Expand Up @@ -208,7 +208,7 @@ test('Lifts CDP renderBlockingStatus onto entries as `_renderBlocking`', t => {
});

test('Omits `_renderBlocking` when CDP did not report it', t => {
// Older Chrome builds don't emit renderBlockingStatus at all — make sure
// Older Chrome builds don't emit renderBlockingBehavior at all — make sure
// we don't materialise the field as `undefined` or an empty string in
// that case. Absent input → absent output.
const messages = [
Expand Down Expand Up @@ -270,6 +270,23 @@ test('Omits `_renderBlocking` when CDP did not report it', t => {
t.false('_renderBlocking' in har.log.entries[0]);
});

test('Lifts `_renderBlocking` from a real Chrome perflog', t => {
// Regression guard against the field-name typo this test file was first
// shipped with (`renderBlockingStatus` vs. the real CDP field
// `renderBlockingBehavior`). The synthetic tests above can't catch that
// class of mistake — they'd silently pass against either spelling
// because they author the input alongside the assertion. A real Chrome
// perflog can.
const perflogPath = perflog('soft-navigation-github-issues.json');
return parsePerflog(perflogPath).then(har => {
const values = new Set(
har.log.entries.map(e => e._renderBlocking).filter(v => v !== undefined)
);
t.true(values.has('nonblocking'));
t.true(values.has('nonblockingdynamic'));
});
});

test('Forwards the resource type value', t => {
const perflogPath = perflog('www.google.ru.json');
const expected = {
Expand Down