Skip to content

Commit

Permalink
[SoftNavigations] Fix up ViewTransition test
Browse files Browse the repository at this point in the history
Bug: 1405448
Change-Id: I034ca223da8a55be0230195e648e48c32341878a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4369840
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1122098}
  • Loading branch information
Yoav Weiss authored and Chromium LUCI CQ committed Mar 25, 2023
1 parent 8a48adf commit e4f6e26
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion third_party/blink/web_tests/VirtualTestSuites
Expand Up @@ -1192,7 +1192,8 @@
"bases": ["external/wpt/css/css-view-transitions",
"wpt_internal/view-transition",
"view-transition",
"inspector-protocol/css/css-get-styles-for-view-transition.js"],
"inspector-protocol/css/css-get-styles-for-view-transition.js",
"external/wpt/soft-navigation-heuristics/navigation-api-view-transition.tentative.html"],
"exclusive_tests": "ALL",
"args": ["--enable-threaded-compositing"],
"expires": "Jul 1, 2023"
Expand Down
Expand Up @@ -26,17 +26,19 @@
timestamps[counter]["eventStart"] = performance.now();
e.intercept({
async handler() {
await document.startViewTransition(async () => {
const lcp_promise = new Promise(resolve => {
(new PerformanceObserver(list => resolve())).observe(
{type: 'largest-contentful-paint',
includeSoftNavigationObservations: true});
});
const transition = document.startViewTransition(async () => {
const main = document.getElementById('main');
main.innerHTML = '<img id="image" src="/images/blue.png?' +
Math.random() + '">';
const img = document.getElementById("image");
await new Promise(resolve => {
(new PerformanceObserver(list => resolve())).observe(
{type: 'largest-contentful-paint',
includeSoftNavigationObservations: true});
});
});
await transition.updateCallbackDone;
await lcp_promise;
}
});
};
Expand Down
Expand Up @@ -49,12 +49,17 @@ const testNavigationApi = (testName, navigateEventHandler, link) => {
promise_test(async t => {
const preClickLcp = await getLcpEntries();
navigation.addEventListener('navigate', navigateEventHandler);
const navigated = new Promise(resolve => {
navigation.addEventListener('navigatesuccess', resolve);
navigation.addEventListener('navigateerror', resolve);
});
click(link);
await new Promise(resolve => {
(new PerformanceObserver(() => resolve())).observe({
type: 'soft-navigation'
});
});
await navigated;
assert_equals(document.softNavigations, 1, 'Soft Navigation detected');
await validateSoftNavigationEntry(1, () => {}, 'foobar.html');

Expand Down

0 comments on commit e4f6e26

Please sign in to comment.