From d5071ff45cbf5ef7b9144527eb9e76651806fb96 Mon Sep 17 00:00:00 2001 From: Blink WPT Bot Date: Thu, 18 Jan 2024 18:57:26 +0000 Subject: [PATCH] Bug 1873933 [wpt PR 43920] - Reland: [soft navigations] Ignore non-attributed LCP before softnav detection, a=testonly Automatic update from web-platform-tests Reland: [soft navigations] Ignore non-attributed LCP before softnav detection (#43920) This relands a commit from pre-121 branch, with a number of fixes applied as well as tests and changes to adapt to commits landed since that branch. ------------------------------------------------------------------------ Original commit message: This CL ignores LCPs that are not attributed to the soft navigation task after a user interaction and before a soft navigation was detected, as discussed in [1]. It also fixes a bug in soft navigation detection in the case where all paints arrive before the URL was changed. Currently in such cases, a soft navigation entry is not emitted. This CL fixes that. [1] https://github.com/WICG/soft-navigations/issues/29#issuecomment-1831386977 ------------------------------------------------------------------------ The full set of relanded patches here is: * commit 6e358318d16c22292d0e57ed7542fe3761c42a72. "[soft navigations] Ignore non-attributed LCP before softnav detection" * commit 81fd9fb434f38f1411baae1e30835c21011974e8. "[soft-navigations] Fix crash when user interaction precedes softnav" * commit 596e49410759e65ee39d5ffb22f8e4789b5d836b. "Create ScriptState::Scope in SetCurrentTimeAsStartTime()" * commit 6039f57d5e4bf6817f6ca4e75ea65e864fcfc2cf. "Move SoftNavigation end of event emission to a handle based on isolate" * commit afec46c737c5547302fa35a3944624df44fad755. "Fix crash by adding v8::HandleScope in SameDocumentCommit" Bug: 1505994 Change-Id: Ibf6d7d22375a1b0fc74e0fe31178831a738d8a46 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185654 Reviewed-by: Michal Mocny Commit-Queue: Ian Clelland Cr-Commit-Position: refs/heads/main@{#1248389} Co-authored-by: Ian Clelland -- wpt-commits: 2cc070d161f7e6fbd9a1d5bd0507aba48d42f1e6 wpt-pr: 43920 --- ...re-detection-second-softnav.tentative.html | 60 +++++++++++++++ .../image-lcp-before-detection.tentative.html | 54 +++++++++++++ ...tion-with-paint-before-back.tentative.html | 76 +++++++++++++++++++ .../resources/soft-navigation-helper.js | 11 +-- ...re-detection-second-softnav.tentative.html | 62 +++++++++++++++ .../text-lcp-before-detection.tentative.html | 55 ++++++++++++++ 6 files changed, 313 insertions(+), 5 deletions(-) create mode 100644 testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection-second-softnav.tentative.html create mode 100644 testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection.tentative.html create mode 100644 testing/web-platform/tests/soft-navigation-heuristics/interaction-with-paint-before-back.tentative.html create mode 100644 testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection-second-softnav.tentative.html create mode 100644 testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection.tentative.html diff --git a/testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection-second-softnav.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection-second-softnav.tentative.html new file mode 100644 index 0000000000000..4d26bb926955f --- /dev/null +++ b/testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection-second-softnav.tentative.html @@ -0,0 +1,60 @@ + + + + + + + + + + + +
+
+ +
+
+ + + + + + diff --git a/testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection.tentative.html new file mode 100644 index 0000000000000..0de675d372b68 --- /dev/null +++ b/testing/web-platform/tests/soft-navigation-heuristics/image-lcp-before-detection.tentative.html @@ -0,0 +1,54 @@ + + + + + + + + + + + +
+
+ +
+
+ + + + + diff --git a/testing/web-platform/tests/soft-navigation-heuristics/interaction-with-paint-before-back.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/interaction-with-paint-before-back.tentative.html new file mode 100644 index 0000000000000..b587411991383 --- /dev/null +++ b/testing/web-platform/tests/soft-navigation-heuristics/interaction-with-paint-before-back.tentative.html @@ -0,0 +1,76 @@ + + + + + + + + + + + +
+
+ + +
+
+ + + + + + + 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 685bc21f43c03..d405adb4e7eb7 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 @@ -6,7 +6,7 @@ const MAX_CLICKS = 50; const MAX_PAINT_ENTRIES = 51; const URL = "foobar.html"; const readValue = (value, defaultValue) => { - return value != undefined ? value : defaultValue; + return value !== undefined ? value : defaultValue; } const testSoftNavigation = options => { @@ -291,15 +291,16 @@ const getLcpEntriesWithoutSoftNavs = async () => { return entries; }; -const addImage = async (element, url="blue.png") => { +const addImage = async (element, url="blue.png", id = "imagelcp") => { const img = new Image(); img.src = '/images/'+ url + "?" + Math.random(); - img.id="imagelcp"; + img.id=id + img.setAttribute("elementtiming", id); await img.decode(); element.appendChild(img); }; -const addImageToMain = async (url="blue.png") => { - await addImage(document.getElementById('main'), url); +const addImageToMain = async (url="blue.png", id = "imagelcp") => { + await addImage(document.getElementById('main'), url, id); }; const addTextParagraphToMain = (text, element_timing = "") => { diff --git a/testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection-second-softnav.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection-second-softnav.tentative.html new file mode 100644 index 0000000000000..bed27c3506914 --- /dev/null +++ b/testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection-second-softnav.tentative.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + +
+
+ +
+
+ + + + + + + diff --git a/testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection.tentative.html b/testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection.tentative.html new file mode 100644 index 0000000000000..11e82e539ff08 --- /dev/null +++ b/testing/web-platform/tests/soft-navigation-heuristics/text-lcp-before-detection.tentative.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + +
+
+ +
+
+ + + +