Skip to content

Commit 6d22ad5

Browse files
haoliukLightning00Blade
authored andcommitted
Revert "[soft navigations] Enable keyboard shortcuts as soft navigation triggers"
This reverts commit 6efe71286a014d3d3872bc990e3ea2d08dd46dba. Reason for revert: One check added in this CL causes crash. see crbug.com/1480047 Original change's description: > [soft navigations] Enable keyboard shortcuts as soft navigation triggers > > Following the discussion on issue web-platform-tests#3 [1], this CL adds support to soft > navigations triggered by keyboard shortcuts, by adding unfocused keydown > events to the events that can trigger the soft navigation heuristic. > > [1] WICG/soft-navigations#3 > > Bug: 1478772 > Change-Id: Ib423a3cfc09eaf4dd9a2221b3494ab1016fa8668 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4839506 > Commit-Queue: Yoav Weiss <[email protected]> > Reviewed-by: Ian Clelland <[email protected]> > Cr-Commit-Position: refs/heads/main@{#1193004} Bug: 1478772 Change-Id: I3a518c165e6b19239a6bf7900e94c1ef9c3e5a5a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4859802 Reviewed-by: Ian Clelland <[email protected]> Commit-Queue: Hao Liu <[email protected]> Owners-Override: Daniel Cheng <[email protected]> Bot-Commit: Rubber Stamper <[email protected]> Cr-Commit-Position: refs/heads/main@{#1196100}
1 parent 757ce69 commit 6d22ad5

4 files changed

+17
-54
lines changed

soft-navigation-heuristics/image-lcp-followed-by-two-image-softnavs-lcp.tentative.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
const first_click_paint_promise = waitOnPaintEntriesPromise();
3333

34-
interact(link);
34+
click(link);
3535
await new Promise(resolve => {
3636
(new PerformanceObserver(resolve)).observe({
3737
type: 'soft-navigation'
@@ -54,7 +54,7 @@
5454

5555
const second_click_paint_promise = waitOnPaintEntriesPromise();
5656
const preClickLcp2 = await getLcpEntries();
57-
interact(link);
57+
click(link);
5858
await new Promise(resolve => {
5959
(new PerformanceObserver(() => resolve())).observe({
6060
type: 'soft-navigation'

soft-navigation-heuristics/keydown.tentative.html

-30
This file was deleted.

soft-navigation-heuristics/navigate-child.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
await new Promise(r => t.step_timeout(r, 10));
2121
}
2222
const link = document.getElementById("link");
23-
interact(link);
23+
click(link);
2424
while (!child.location.href.includes("2")) {
2525
await new Promise(r => t.step_timeout(r, 10));
2626
}

soft-navigation-heuristics/resources/soft-navigation-helper.js

+14-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var counter = 0;
2-
var interacted;
2+
var clicked;
33
var timestamps = []
44
const MAX_CLICKS = 50;
55
// Entries for one hard navigation + 50 soft navigations.
@@ -20,7 +20,6 @@ const testSoftNavigation =
2020
const testName = options.testName;
2121
const pushUrl = readValue(options.pushUrl, true);
2222
const eventType = readValue(options.eventType, "click");
23-
const interactionType = readValue(options.interactionType, 'click');
2423
const expectLCP = options.validate != 'no-lcp';
2524
promise_test(async t => {
2625
await waitInitialLCP();
@@ -30,8 +29,8 @@ const testSoftNavigation =
3029
const firstClick = (i === 0);
3130
let paint_entries_promise =
3231
waitOnPaintEntriesPromise(expectLCP && firstClick);
33-
interacted = false;
34-
interact(link, interactionType);
32+
clicked = false;
33+
click(link);
3534

3635
await new Promise(resolve => {
3736
(new PerformanceObserver(() => resolve())).observe({
@@ -62,7 +61,7 @@ const testNavigationApi = (testName, navigateEventHandler, link) => {
6261
await waitInitialLCP();
6362
const preClickLcp = await getLcpEntries();
6463
let paint_entries_promise = waitOnPaintEntriesPromise();
65-
interact(link);
64+
click(link);
6665
await new Promise(resolve => {
6766
(new PerformanceObserver(() => resolve())).observe({
6867
type: 'soft-navigation'
@@ -81,7 +80,7 @@ const testSoftNavigationNotDetected = options => {
8180
promise_test(async t => {
8281
const preClickLcp = await getLcpEntries();
8382
options.eventTarget.addEventListener(options.eventName, options.eventHandler);
84-
interact(options.link);
83+
click(options.link);
8584
await new Promise((resolve, reject) => {
8685
(new PerformanceObserver(() =>
8786
reject("Soft navigation should not be triggered"))).observe({
@@ -129,21 +128,15 @@ const runEntryValidations =
129128
}
130129
};
131130

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+
}
143137

144138
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;
147140
eventObject.addEventListener(eventType, async e => {
148141
timestamps[counter]["eventStart"] = performance.now();
149142
// Jump through a task, to ensure task tracking is working properly.
@@ -165,7 +158,7 @@ const setEvent = (t, button, pushState, addContent, pushUrl, eventType) => {
165158
await addContent(url);
166159
++counter;
167160

168-
interacted = true;
161+
clicked = true;
169162
});
170163
};
171164

@@ -185,7 +178,7 @@ const validateSoftNavigationEntry = async (clicks, extraValidations,
185178
assert_true(entry.name.includes(pushUrl ? URL : document.location.href),
186179
"The soft navigation name is properly set");
187180
const entryTimestamp = entry.startTime;
188-
assert_less_than_equal(timestamps[i]["syncPostInteraction"], entryTimestamp);
181+
assert_less_than_equal(timestamps[i]["syncPostClick"], entryTimestamp);
189182
assert_greater_than_equal(
190183
timestamps[i]['eventStart'], entryTimestamp,
191184
'Event start timestamp matches');

0 commit comments

Comments
 (0)