Skip to content

Commit 38b4fc6

Browse files
paulirishDevtools-frontend LUCI CQ
authored andcommitted
RPP: Simplify NavigationStart types
The delineation isn't worth the oddities of these types. Bug:1457310 Change-Id: I349b116491dd5d840618890a4fe598ac9230ceed Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6183083 Commit-Queue: Connor Clark <[email protected]> Auto-Submit: Paul Irish <[email protected]> Reviewed-by: Connor Clark <[email protected]>
1 parent 00f2a72 commit 38b4fc6

File tree

3 files changed

+24
-42
lines changed

3 files changed

+24
-42
lines changed

front_end/models/trace/handlers/MetaHandler.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ describe('MetaHandler', function() {
5050
tid: Trace.Types.Events.ThreadID(775),
5151
ts: Trace.Types.Timing.Micro(800),
5252
name: 'navigationStart',
53-
} as Trace.Types.Events.NavigationStartUnreliable,
53+
// Casting as NavStart, but it is ignored due to the empty documentLoaderURL
54+
} as Trace.Types.Events.NavigationStart,
5455
{
5556
...defaultTraceEvent,
5657
args: {

front_end/models/trace/insights/Common.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ describeWithEnvironment('Common', function() {
1717
throw new Error('missing metadata');
1818
}
1919

20-
const insightSetKey = getFirstOrError(data.Meta.navigationsByNavigationId.values()).args.data.navigationId;
20+
const firstNav = getFirstOrError(data.Meta.navigationsByNavigationId.values());
21+
if (!firstNav.args.data?.navigationId) {
22+
throw new Error('expected navigationId');
23+
}
24+
const insightSetKey = firstNav.args.data.navigationId;
2125
const insightSet = insights.get(insightSetKey);
2226
if (!insightSet) {
2327
throw new Error('missing insight set');

front_end/models/trace/types/TraceEvents.ts

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export const enum Phase {
5252
CLOCK_SYNC = 'c',
5353
}
5454

55-
export type NonEmptyString = string&{_tag: 'NonEmptyString'};
56-
5755
export function isNestableAsyncPhase(phase: Phase): boolean {
5856
return phase === Phase.ASYNC_NESTABLE_START || phase === Phase.ASYNC_NESTABLE_END ||
5957
phase === Phase.ASYNC_NESTABLE_INSTANT;
@@ -596,43 +594,29 @@ export interface Mark extends Event {
596594
ph: Phase.MARK;
597595
}
598596

599-
// An unreliable and non-legit navigationStart. See NavigationStartWithUrl
600-
export interface NavigationStartUnreliable extends Mark {
597+
export interface NavigationStart extends Mark {
601598
name: 'navigationStart';
602599
args: Args&{
603-
data?: ArgsData & {
604-
/** An empty documentLoaderURL means this navigationStart is unreliable noise and can be ignored. */
605-
documentLoaderURL: never,
600+
frame: string,
601+
data?: ArgsData&{
602+
/** Must be non-empty to be valid. An empty documentLoaderURL means the event can be ignored. */
603+
documentLoaderURL: string,
606604
isLoadingMainFrame: boolean,
607-
// isOutermostMainFrame was introduced in crrev.com/c/3625434 and exists
608-
// because of Fenced Frames
609-
// [github.com/WICG/fenced-frame/tree/master/explainer].
610-
// Fenced frames introduce a situation where isLoadingMainFrame could be
611-
// true for a navigation, but that navigation be within an embedded "main
612-
// frame", and therefore it wouldn't be on the top level main frame.
613-
// In situations where we need to distinguish that, we can rely on
614-
// isOutermostMainFrame, which will only be true for navigations on the
615-
// top level main frame.
616-
617-
// This flag is optional as it was introduced in May 2022; so users
618-
// reasonably may import traces from before that date that do not have
619-
// this field present.
620-
isOutermostMainFrame?: boolean, navigationId: string,
605+
navigationId: string,
606+
/**
607+
* `isOutermostMainFrame` was introduced in crrev.com/c/3625434 and exists because of Fenced Frames
608+
* [github.com/WICG/fenced-frame/tree/master/explainer]. Fenced frames introduce a situation where
609+
* `isLoadingMainFrame` could be true for a navigation, but that navigation be within an embedded "main frame", and
610+
* therefore it wouldn't be on the top level main frame. In situations where we need to distinguish that, we can
611+
* rely on `isOutermostMainFrame`, which will only be true for navigations on the top level main frame.
612+
* This flag is optional as it was introduced in May 2022; so users reasonably may import traces from before that
613+
* date that do not have this field present.
614+
*/
615+
isOutermostMainFrame?: boolean,
621616
/**
622617
* @deprecated use documentLoaderURL for navigation events URLs
623618
*/
624619
url?: string,
625-
},
626-
frame: string,
627-
};
628-
}
629-
630-
// NavigationStart but definitely has a populated documentLoaderURL
631-
export interface NavigationStart extends NavigationStartUnreliable {
632-
args: NavigationStartUnreliable['args']&{
633-
data: NavigationStartUnreliable['args']['data'] & {
634-
/** This navigationStart is valid, as the documentLoaderURL isn't empty. */
635-
documentLoaderURL: NonEmptyString,
636620
},
637621
};
638622
}
@@ -2050,13 +2034,6 @@ export function isCommitLoad(
20502034
return event.name === 'CommitLoad';
20512035
}
20522036

2053-
/** @deprecated You probably want `isNavigationStart` instead. */
2054-
export function isNavigationStartUnreliable(
2055-
event: Event,
2056-
): event is NavigationStartUnreliable {
2057-
return event.name === 'navigationStart';
2058-
}
2059-
20602037
export function isAnimation(
20612038
event: Event,
20622039
): event is Animation {
@@ -2210,7 +2187,7 @@ export function isPrePaint(
22102187

22112188
/** A VALID navigation start (as it has a populated documentLoaderURL) */
22122189
export function isNavigationStart(event: Event): event is NavigationStart {
2213-
return Boolean(isNavigationStartUnreliable(event) && event.args.data && event.args.data.documentLoaderURL !== '');
2190+
return event.name === 'navigationStart' && (event as NavigationStart).args?.data?.documentLoaderURL !== '';
22142191
}
22152192

22162193
export function isMainFrameViewport(

0 commit comments

Comments
 (0)