diff --git a/testing/web-platform/tests/soft-navigation-heuristics/click-event-bubbles.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/click-event-bubbles.tentative.html new file mode 100644 index 0000000000000..ee9d1e12335c8 --- /dev/null +++ b/testing/web-platform/tests/soft-navigation-heuristics/click-event-bubbles.tentative.html @@ -0,0 +1,28 @@ + + + + + + + + + + + +
+ Click me! +
+ + + diff --git a/testing/web-platform/tests/soft-navigation-heuristics/multiple_nested_events.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/multiple-nested-events.tentative.html similarity index 94% rename from testing/web-platform/tests/soft-navigation-heuristics/multiple_nested_events.tentative.html rename to testing/web-platform/tests/soft-navigation-heuristics/multiple-nested-events.tentative.html index 196cfa06868ca..e51841865d654 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/multiple_nested_events.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/multiple-nested-events.tentative.html @@ -24,7 +24,6 @@ }); testSoftNavigation({ eventPrepWork: url => { - timestamps[counter]["eventStart"] = performance.now(); addTextToDivOnMain(); history.pushState({}, '', 'foobar1.html'); // Here we're bypassing the regular test's event logic, as this test is diff --git a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-after-transition-commit.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-after-transition-commit.tentative.html index 5c7d8f4f7a4fa..ae17db7d59f4c 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-after-transition-commit.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-after-transition-commit.tentative.html @@ -16,11 +16,11 @@ diff --git a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-hash.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-hash.tentative.html index a63b177a63f49..e20578ea79ed7 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-hash.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-hash.tentative.html @@ -16,11 +16,11 @@ diff --git a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html index d6c61efb3cbc3..b7b2a24c94203 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-preventDefault.tentative.html @@ -19,12 +19,12 @@ testSoftNavigationNotDetected({ testName: "Aborted navigate event is not a soft navigation", eventHandler: e => { - timestamps[counter]["eventStart"] = performance.now(); e.intercept({handler: async () => { await addImageToMain(); main.appendChild(img); }}); e.preventDefault(); + timestamps[counter]["eventEnd"] = performance.now(); }, eventTarget: navigation, eventName: "navigate", diff --git a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-rejected.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-rejected.tentative.html index bcc0451d5bd80..693f876b6e188 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-rejected.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-rejected.tentative.html @@ -16,11 +16,11 @@ diff --git a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-view-transition.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-view-transition.tentative.html index 2755f9f9ac75b..4d88f3d0b7d9b 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-view-transition.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api-view-transition.tentative.html @@ -23,7 +23,6 @@ await new Promise(r => step_timeout(r, 0)); const navigate_callback = e => { - timestamps[counter]["eventStart"] = performance.now(); e.intercept({ async handler() { const lcp_promise = new Promise(resolve => { @@ -41,6 +40,7 @@ await lcp_promise; } }); + timestamps[counter]["eventEnd"] = performance.now(); }; const link = document.getElementById("link"); diff --git a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api.tentative.html index ca11f684f4990..2d61736a48612 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/navigation-api.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/navigation-api.tentative.html @@ -16,10 +16,10 @@ diff --git a/testing/web-platform/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html index 2a12a352bffc3..fd87f5f03e753 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/popstate-multiple-backs.tentative.html @@ -39,7 +39,10 @@ return t.popped == 2; } const link = document.getElementById("link"); - link.addEventListener("click", () => history.back()); + link.addEventListener("click", () => { + history.back(); + timestamps[counter]["eventEnd"] = performance.now(); + }); testSoftNavigation({ addContent: () => { // Add the content to the main element diff --git a/testing/web-platform/tests/soft-navigation-heuristics/popstate.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/popstate.tentative.html index 60a5ff72292c1..f89991d76b044 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/popstate.tentative.html +++ b/testing/web-platform/tests/soft-navigation-heuristics/popstate.tentative.html @@ -22,7 +22,10 @@ history.pushState({}, "", "another_one.html"); const link = document.getElementById("link"); - link.addEventListener("click", () => history.back()); + link.addEventListener("click", () => { + history.back(); + timestamps[counter]["eventEnd"] = performance.now(); + }); testSoftNavigation({ addContent: () => { // Add the content to the main element diff --git a/testing/web-platform/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js b/testing/web-platform/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js index 59fe7d6600908..71412b1b0f8dd 100644 --- a/testing/web-platform/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js +++ b/testing/web-platform/tests/soft-navigation-heuristics/resources/soft-navigation-helper.js @@ -144,10 +144,17 @@ const setEvent = (t, button, pushState, addContent, pushUrl, eventType, prepWork const eventObject = (eventType == 'click' || eventType.startsWith("key")) ? button : window; eventObject.addEventListener(eventType, async e => { + let prepWorkFailed = false; if (prepWork &&!prepWork(t)) { + prepWorkFailed = true; + } + + if (!timestamps[counter]["eventEnd"]) { + timestamps[counter]["eventEnd"] = performance.now(); + } + if (prepWorkFailed) { return; } - timestamps[counter]["eventStart"] = performance.now(); await new Promise(r => t.step_timeout(r, 0)); @@ -165,9 +172,9 @@ const setEvent = (t, button, pushState, addContent, pushUrl, eventType, prepWork await new Promise(r => t.step_timeout(r, 10)); await addContent(url); - ++counter; interacted = true; + ++counter; }); }; @@ -190,7 +197,7 @@ const validateSoftNavigationEntry = async (clicks, extraValidations, assert_less_than_equal(timestamps[i]["syncPostInteraction"], entryTimestamp, "Entry timestamp is lower than the post interaction one"); assert_greater_than_equal( - timestamps[i]['eventStart'], entryTimestamp, + entryTimestamp, timestamps[i]['eventEnd'], 'Event start timestamp matches'); assert_not_equals(entry.navigationId, performance.getEntriesByType("navigation")[0].navigationId,