Skip to content

Commit 703a840

Browse files
Replace 2 tests with a subtest of smoke/tentative/almost-soft-navigation.html.
replacestate.tentative.html is already covered with the replace-state subtest, l. 59 in almost-soft-navigation.html in this change. soft-navigation-no-url.tentative.html is getting covered with noUrlPassedToPushState, in this change. The tests I'm deleting make use of testSoftNavigationNotDetected in soft-navigation-helper.js, the replacements don't. Because the replacements don't wait for a timeout after each of these "almost softnavs" and run in the same doc and browser instance, they should be faster. I'm also adding a global_test_id variable to make the actual-softnavigation (which follows each attempted soft navigation) go to a unique and predictable URL. Change-Id: Id0d832540cc9293fbbeae2d99fce9a2e6d122a8c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6545933 Commit-Queue: Johannes Henkel <[email protected]> Reviewed-by: Michal Mocny <[email protected]> Cr-Commit-Position: refs/heads/main@{#1460312}
1 parent cea07df commit 703a840

File tree

3 files changed

+18
-63
lines changed

3 files changed

+18
-63
lines changed

soft-navigation-heuristics/replacestate.tentative.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

soft-navigation-heuristics/smoke/tentative/almost-soft-navigation.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
<script src="/resources/testdriver.js"></script>
99
<script src="/resources/testdriver-vendor.js"></script>
1010
<script>
11+
// We append this value to the URL of actualSoftNavigation() to
12+
// identify the test, and to ensure it's unique.
13+
let global_test_id;
14+
1115
// This click handler *does* cause a soft navigation, and *each test
1216
// ends with detecting it*. This is by design a very simple soft
1317
// navigation which we reliably detect - the same as in basic.html.
1418
function actualSoftNavigation() {
1519
const greeting = document.createElement("div");
1620
greeting.textContent = "Hello, World.";
1721
document.body.appendChild(greeting);
18-
history.pushState({}, "", "/actual-softnavigation");
22+
history.pushState({}, "", "/actual-softnavigation?" + global_test_id);
1923
}
2024

2125
// This click handler won't cause a soft navigation, because it
@@ -58,6 +62,15 @@
5862
document.body.appendChild(greeting);
5963
history.replaceState({}, "", "/replace-state");
6064
}
65+
66+
// This click handler won't cause a soft navigation, because it
67+
// doesn't pass a URL to pushState().
68+
function noUrlPassedToPushState() {
69+
const greeting = document.createElement("div");
70+
greeting.textContent = "Hello, World.";
71+
document.body.appendChild(greeting);
72+
history.pushState({}, "");
73+
}
6174
</script>
6275
</head>
6376
<body>
@@ -67,6 +80,7 @@
6780
<div id="no-dom-change" onclick="noDomChange()">Click here!</div>
6881
<div id="no-paint" onclick="noPaint()">Click here!</div>
6982
<div id="replace-state" onclick="replaceState()">Click here!</div>
83+
<div id="no-url-passed-to-push-state" onclick="noUrlPassedToPushState()">Click here!</div>
7084

7185
<script>
7286
function test_template(test_id, description) {
@@ -75,12 +89,13 @@
7589
const entries = [];
7690
new PerformanceObserver((list, observer) => {
7791
entries.push(...list.getEntries());
78-
if (entries[entries.length - 1].name.endsWith("actual-softnavigation")) {
92+
if (entries[entries.length - 1].name.endsWith("actual-softnavigation?" + test_id)) {
7993
observer.disconnect();
8094
resolve(entries);
8195
}
8296
}).observe({ type: "soft-navigation" });
8397
if (test_driver) {
98+
global_test_id = test_id;
8499
test_driver.click(document.getElementById(test_id));
85100
test_driver.click(document.getElementById("actual-softnavigation"));
86101
}
@@ -99,6 +114,7 @@
99114
test_template("no-paint", "Doesn't paint because the element is hidden.");
100115
test_template("no-dom-change", "The DOM change is missing.");
101116
test_template("replace-state", "Uses replaceState() instead of pushState().");
117+
test_template("no-url-passed-to-push-state", "Doesn't pass a URL to pushState().");
102118
</script>
103119
</body>
104120
</html>

soft-navigation-heuristics/soft-navigation-no-url.tentative.html

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)