Skip to content

Commit 794fb36

Browse files
Michal Mocnychromium-wpt-export-bot
Michal Mocny
authored andcommitted
[soft navs] Fix failing CHECK in ProcessCustomWeakness
We expect that as long as we have one of two specific Member<SoftNavigationContext> references non nullptr, then we shouldn't ever have an empty list of potential soft navigations. However, we were previously accidentally setting the most_recent_ context to a context that comes from another window, which meant we could have a case where all interactions are GC-ed and yet one of these values was not null. Change to guard against this in the one place it could happen, but, also change the CHECK to NotFatalUntil since these are really not important to enforce, they are just extra cautious. Bug: 421199934, 40871933 Change-Id: I6d120389a032ec6ae51d660299170d8f85aab642 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6604294 Commit-Queue: Michal Mocny <mmocny@chromium.org> Reviewed-by: Scott Haseley <shaseley@chromium.org> Reviewed-by: Johannes Henkel <johannes@chromium.org> Cr-Commit-Position: refs/heads/main@{#1467654}
1 parent 02aea8f commit 794fb36

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
4+
<h1>This is some text</h1>
5+
6+
<script>
7+
function navigate() {
8+
history.pushState({}, "", "/different-url");
9+
}
10+
11+
async function getNextSoftNavEntry() {
12+
return new Promise(resolve => {
13+
new PerformanceObserver((list, observer) => {
14+
observer.disconnect();
15+
resolve(list.getEntries()[0]);
16+
}).observe({ type: "soft-navigation" });
17+
});
18+
}
19+
</script>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Scheduling soft navigations across windows.</title>
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<script src="/resources/testdriver.js"></script>
9+
<script src="/resources/testdriver-vendor.js"></script>
10+
<script></script>
11+
</head>
12+
<body>
13+
<button id="button" onclick="navigateChild()">Press Me!</button>
14+
15+
<script>
16+
const child = window.open('resources/other_window.html');
17+
const childLoaded = new Promise(resolve => child.onload = resolve);
18+
19+
function navigateChild() {
20+
// `child.navigate()` is a function declared in the `other_window.html`.
21+
child.navigate();
22+
}
23+
24+
promise_test(async (t) => {
25+
await childLoaded;
26+
27+
if (test_driver) {
28+
test_driver.click(document.getElementById("button"));
29+
}
30+
31+
new PerformanceObserver((list, observer) => t.step(() => {
32+
observer.disconnect();
33+
assert_unreached("Parent window should not detect a soft-navigation.");
34+
})).observe({ type: "soft-navigation" });
35+
36+
child.getNextSoftNavEntry().then((entry) => {
37+
assert_unreached("Child window should not detect a soft-navigation.");
38+
});
39+
40+
await new Promise(resolve => t.step_timeout(resolve, 2000));
41+
42+
}, "Opening a new window and updating a URL in it shouldn't crash");
43+
</script>
44+
</body>
45+
</html>

0 commit comments

Comments
 (0)