Skip to content

Commit 4cb315e

Browse files
committed
refactor(browser): Make bfcache frame purely positional
`frame` no longer special-cases the `masked` reason value; it now reflects only the frame's position in the notRestoredReasons tree (`top`/`child`). The `masked` value already lives on the `reason` attribute, so tagging the frame as `masked` too was redundant. The integration no longer inspects any reason string - reasons pass through verbatim.
1 parent f051471 commit 4cb315e

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

dev-packages/e2e-tests/test-applications/browser-bfcache/tests/bfcache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ test('reports a miss with notRestoredReasons when an unload listener blocks bfca
4747
metric =>
4848
metric.name === 'browser.bfcache.not_restored' && attr(metric, 'browser.bfcache.reason') === 'unload-listener',
4949
);
50-
// Chrome reports a privacy-masked reason alongside the real one; the integration must classify it
51-
// as a `masked` frame. This is our only real-browser coverage of the masked-frame path.
50+
// Chrome reports a privacy-masked reason alongside the real one. It's a top-frame reason here, so
51+
// the integration must frame it positionally (`top`) and pass the value through untouched.
5252
const maskedReasonPromise = waitForMetric(
5353
PROXY_SERVER_NAME,
5454
metric => metric.name === 'browser.bfcache.not_restored' && attr(metric, 'browser.bfcache.reason') === 'masked',
@@ -82,7 +82,7 @@ test('reports a miss with notRestoredReasons when an unload listener blocks bfca
8282
expect(attr(unloadReason, 'browser.bfcache.frame')).toBe('top');
8383

8484
const maskedReason = await maskedReasonPromise;
85-
expect(attr(maskedReason, 'browser.bfcache.frame')).toBe('masked');
85+
expect(attr(maskedReason, 'browser.bfcache.frame')).toBe('top');
8686

8787
const reloadDuration = await reloadDurationPromise;
8888
expect(reloadDuration.type).toBe('distribution');

packages/browser/src/integrations/bfcache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { WINDOW } from '../helpers';
66
const INTEGRATION_NAME = 'BFCacheMetrics';
77
const DEFAULT_MAX_REASONS = 5;
88

9-
type BFCacheFrame = 'top' | 'child' | 'masked' | 'unknown';
9+
type BFCacheFrame = 'top' | 'child';
1010

1111
interface BFCacheIntegrationOptions {
1212
/**
@@ -158,7 +158,7 @@ function _collectReasonsFromFrame(
158158

159159
collectedReasons.push({
160160
reason: reasonValue,
161-
frame: reasonValue === 'masked' ? 'masked' : frameType,
161+
frame: frameType,
162162
});
163163
});
164164

packages/browser/test/integrations/bfcache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ describe('bfcacheMetricsIntegration', () => {
7171
expect(_collectNotRestoredReasons(tree, 5)).toEqual([{ reason: 'fetch', frame: 'child' }]);
7272
});
7373

74-
it('marks the "masked" reason as a masked frame regardless of depth', () => {
74+
it('frames every reason by its position, without special-casing the reason value', () => {
7575
const tree = {
7676
reasons: [{ reason: 'masked' }],
7777
children: [{ reasons: [{ reason: 'masked' }] }],
7878
};
7979

8080
expect(_collectNotRestoredReasons(tree, 5)).toEqual([
81-
{ reason: 'masked', frame: 'masked' },
82-
{ reason: 'masked', frame: 'masked' },
81+
{ reason: 'masked', frame: 'top' },
82+
{ reason: 'masked', frame: 'child' },
8383
]);
8484
});
8585

0 commit comments

Comments
 (0)