Skip to content

Commit

Permalink
[soft navigations] Improve nested event scope handling
Browse files Browse the repository at this point in the history
This CL improves SoftNavigationEventScope's handling of nested event
scopes, which can happen when a user interaction event triggers a
synchronous navigation. (e.g. through the history/navigation API, or
through window.open)
It shouldn't comprise any functional change.

Change-Id: I396acf32c1bd851652064481e27dfc42594de5ea
Bug: 1505059
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5056838
Reviewed-by: Ian Clelland <[email protected]>
Commit-Queue: Yoav Weiss <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1230203}
  • Loading branch information
Yoav Weiss authored and chromium-wpt-export-bot committed Nov 28, 2023
1 parent 804b6ce commit 6cd9dc3
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions soft-navigation-heuristics/multiple_nested_events.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/soft-navigation-helper.js"></script>
</head>
<body>
<main id=main>
<a id=link>Click me!</a>
</main>
<script>
const link = document.getElementById("link");
let should_navigate = true;
navigation.addEventListener("navigate", () => {
if (should_navigate) {
// It's the last sync navigation that determines the soft nav URL.
history.pushState({}, '', 'foobar.html');
should_navigate = false;
}
});
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
// fully sync.
return false;
},
link: link,
eventName: "click",
eventTarget: link,
testName: "Test multiple nested navigate events"});
</script>
</body>
</html>

0 comments on commit 6cd9dc3

Please sign in to comment.