Skip to content

Commit

Permalink
Soft navigations - handle hash-based navigations
Browse files Browse the repository at this point in the history
Currently soft navigation heuristics don't include hash-based soft
navigatons. This CL fixes that.

Bug: 1376597
Change-Id: Id8848ec71fd12dc6dbd7d5f9b7416d241e02a0a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020675
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Commit-Queue: Yoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1073368}
  • Loading branch information
Yoav Weiss authored and chromium-wpt-export-bot committed Nov 18, 2022
1 parent 3421aaf commit dbcd308
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
29 changes: 29 additions & 0 deletions soft-navigation-heuristics/hash.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Detect hashchange event.</title>
<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>
<div>
<a id=link>Click me!</a>
</div>
</main>
<script>
const link = document.getElementById("link");
testSoftNavigation({
addContent: () => {
addTextToDivOnMain();
},
link: link,
pushState: (url)=>{location.hash=url;},
test: "Location hash changes properly works with SoftNavigationHeuristics"});
</script>
</body>
</html>
28 changes: 28 additions & 0 deletions soft-navigation-heuristics/navigation-api-hash.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Detect intercepted navigate event.</title>
<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 href="#foobar.html" id=link>Click me!</a>
</main>
<script>
const link = document.getElementById("link");
testNavigationApi("Test soft navigation with the Navigation API", e => {
timestamps[counter]["eventStart"] = performance.now();
e.intercept({handler: async () => {
await addImageToMain();
main.appendChild(img);
}});
}, link);
</script>
</body>
</html>

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var counter = 0;
var clicked;
var timestamps = []
const MAX_CLICKS = 50;
const URL = "/foobar.html";
const URL = "foobar.html";
const readValue = (value, defaultValue) => {
return value != undefined ? value : defaultValue;
}
Expand Down

0 comments on commit dbcd308

Please sign in to comment.