1
1
var counter = 0 ;
2
- var interacted ;
2
+ var clicked ;
3
3
var timestamps = [ ]
4
4
const MAX_CLICKS = 50 ;
5
5
// Entries for one hard navigation + 50 soft navigations.
@@ -20,7 +20,6 @@ const testSoftNavigation =
20
20
const testName = options . testName ;
21
21
const pushUrl = readValue ( options . pushUrl , true ) ;
22
22
const eventType = readValue ( options . eventType , "click" ) ;
23
- const interactionType = readValue ( options . interactionType , 'click' ) ;
24
23
const expectLCP = options . validate != 'no-lcp' ;
25
24
promise_test ( async t => {
26
25
await waitInitialLCP ( ) ;
@@ -30,8 +29,8 @@ const testSoftNavigation =
30
29
const firstClick = ( i === 0 ) ;
31
30
let paint_entries_promise =
32
31
waitOnPaintEntriesPromise ( expectLCP && firstClick ) ;
33
- interacted = false ;
34
- interact ( link , interactionType ) ;
32
+ clicked = false ;
33
+ click ( link ) ;
35
34
36
35
await new Promise ( resolve => {
37
36
( new PerformanceObserver ( ( ) => resolve ( ) ) ) . observe ( {
@@ -62,7 +61,7 @@ const testNavigationApi = (testName, navigateEventHandler, link) => {
62
61
await waitInitialLCP ( ) ;
63
62
const preClickLcp = await getLcpEntries ( ) ;
64
63
let paint_entries_promise = waitOnPaintEntriesPromise ( ) ;
65
- interact ( link ) ;
64
+ click ( link ) ;
66
65
await new Promise ( resolve => {
67
66
( new PerformanceObserver ( ( ) => resolve ( ) ) ) . observe ( {
68
67
type : 'soft-navigation'
@@ -81,7 +80,7 @@ const testSoftNavigationNotDetected = options => {
81
80
promise_test ( async t => {
82
81
const preClickLcp = await getLcpEntries ( ) ;
83
82
options . eventTarget . addEventListener ( options . eventName , options . eventHandler ) ;
84
- interact ( options . link ) ;
83
+ click ( options . link ) ;
85
84
await new Promise ( ( resolve , reject ) => {
86
85
( new PerformanceObserver ( ( ) =>
87
86
reject ( "Soft navigation should not be triggered" ) ) ) . observe ( {
@@ -129,21 +128,15 @@ const runEntryValidations =
129
128
}
130
129
} ;
131
130
132
- const interact =
133
- ( link , interactionType = 'click' ) => {
134
- if ( test_driver ) {
135
- if ( interactionType == 'click' ) {
136
- test_driver . click ( link ) ;
137
- } else {
138
- test_driver . send_keys ( link , 'j' ) ;
139
- }
140
- timestamps [ counter ] = { "syncPostInteraction" : performance . now ( ) } ;
141
- }
142
- }
131
+ const click = link => {
132
+ if ( test_driver ) {
133
+ test_driver . click ( link ) ;
134
+ timestamps [ counter ] = { "syncPostClick" : performance . now ( ) } ;
135
+ }
136
+ }
143
137
144
138
const setEvent = ( t , button , pushState , addContent , pushUrl , eventType ) => {
145
- const eventObject =
146
- ( eventType == 'click' || eventType == 'keydown' ) ? button : window ;
139
+ const eventObject = ( eventType == "click" ) ? button : window ;
147
140
eventObject . addEventListener ( eventType , async e => {
148
141
timestamps [ counter ] [ "eventStart" ] = performance . now ( ) ;
149
142
// Jump through a task, to ensure task tracking is working properly.
@@ -165,7 +158,7 @@ const setEvent = (t, button, pushState, addContent, pushUrl, eventType) => {
165
158
await addContent ( url ) ;
166
159
++ counter ;
167
160
168
- interacted = true ;
161
+ clicked = true ;
169
162
} ) ;
170
163
} ;
171
164
@@ -185,7 +178,7 @@ const validateSoftNavigationEntry = async (clicks, extraValidations,
185
178
assert_true ( entry . name . includes ( pushUrl ? URL : document . location . href ) ,
186
179
"The soft navigation name is properly set" ) ;
187
180
const entryTimestamp = entry . startTime ;
188
- assert_less_than_equal ( timestamps [ i ] [ "syncPostInteraction " ] , entryTimestamp ) ;
181
+ assert_less_than_equal ( timestamps [ i ] [ "syncPostClick " ] , entryTimestamp ) ;
189
182
assert_greater_than_equal (
190
183
timestamps [ i ] [ 'eventStart' ] , entryTimestamp ,
191
184
'Event start timestamp matches' ) ;
0 commit comments