mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #20629 - cbrewster:session_history_fixup, r=asajeffrey
Session history fixup <!-- Please describe your changes on the following line: --> When a browsing context was removed, its entries were not removed from the joint session history. The embedder should be notified that the history changed after a navigation matures. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach build-geckolib` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20629) <!-- Reviewable:end -->
This commit is contained in:
commit
e4472f7c1f
5 changed files with 64 additions and 4 deletions
|
@ -2453,13 +2453,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
self.trim_history(top_level_id);
|
self.trim_history(top_level_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.notify_history_changed(change.top_level_browsing_context_id);
|
||||||
self.update_frame_tree_if_active(change.top_level_browsing_context_id);
|
self.update_frame_tree_if_active(change.top_level_browsing_context_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trim_history(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
|
fn trim_history(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
|
||||||
let pipelines_to_evict = {
|
let pipelines_to_evict = {
|
||||||
let session_history = self.joint_session_histories.entry(top_level_browsing_context_id)
|
let session_history = self.get_joint_session_history(top_level_browsing_context_id);
|
||||||
.or_insert(JointSessionHistory::new());
|
|
||||||
|
|
||||||
let history_length = PREFS.get("session-history.max-length").as_u64().unwrap_or(20) as usize;
|
let history_length = PREFS.get("session-history.max-length").as_u64().unwrap_or(20) as usize;
|
||||||
|
|
||||||
|
@ -2493,8 +2493,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
self.close_pipeline(evicted_id, DiscardBrowsingContext::No, ExitPipelineMode::Normal);
|
self.close_pipeline(evicted_id, DiscardBrowsingContext::No, ExitPipelineMode::Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
let session_history = self.joint_session_histories.entry(top_level_browsing_context_id)
|
let session_history = self.get_joint_session_history(top_level_browsing_context_id);
|
||||||
.or_insert(JointSessionHistory::new());
|
|
||||||
|
|
||||||
for (alive_id, dead) in dead_pipelines {
|
for (alive_id, dead) in dead_pipelines {
|
||||||
session_history.replace(NeedsToReload::No(alive_id), dead);
|
session_history.replace(NeedsToReload::No(alive_id), dead);
|
||||||
|
@ -2778,6 +2777,11 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
Some(browsing_context) => browsing_context,
|
Some(browsing_context) => browsing_context,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
let session_history = self.get_joint_session_history(browsing_context.top_level_id);
|
||||||
|
session_history.remove_entries_for_browsing_context(browsing_context_id);
|
||||||
|
}
|
||||||
|
|
||||||
if BrowsingContextId::from(browsing_context.top_level_id) == browsing_context_id {
|
if BrowsingContextId::from(browsing_context.top_level_id) == browsing_context_id {
|
||||||
self.event_loops.remove(&browsing_context.top_level_id);
|
self.event_loops.remove(&browsing_context.top_level_id);
|
||||||
}
|
}
|
||||||
|
@ -2905,6 +2909,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_joint_session_history(&mut self, top_level_id: TopLevelBrowsingContextId) -> &mut JointSessionHistory {
|
||||||
|
self.joint_session_histories.entry(top_level_id).or_insert(JointSessionHistory::new())
|
||||||
|
}
|
||||||
|
|
||||||
// Convert a browsing context to a sendable form to pass to the compositor
|
// Convert a browsing context to a sendable form to pass to the compositor
|
||||||
fn browsing_context_to_sendable(&self, browsing_context_id: BrowsingContextId) -> Option<SendableFrameTree> {
|
fn browsing_context_to_sendable(&self, browsing_context_id: BrowsingContextId) -> Option<SendableFrameTree> {
|
||||||
self.browsing_contexts.get(&browsing_context_id).and_then(|browsing_context| {
|
self.browsing_contexts.get(&browsing_context_id).and_then(|browsing_context| {
|
||||||
|
|
|
@ -42,6 +42,15 @@ impl JointSessionHistory {
|
||||||
diff.replace(&old_reloader, &new_reloader);
|
diff.replace(&old_reloader, &new_reloader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_entries_for_browsing_context(&mut self, context_id: BrowsingContextId) {
|
||||||
|
self.past.retain(|&SessionHistoryDiff::BrowsingContextDiff { browsing_context_id, .. }| {
|
||||||
|
browsing_context_id != context_id
|
||||||
|
});
|
||||||
|
self.future.retain(|&SessionHistoryDiff::BrowsingContextDiff { browsing_context_id, .. }| {
|
||||||
|
browsing_context_id != context_id
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a pending change in a session history, that will be applied
|
/// Represents a pending change in a session history, that will be applied
|
||||||
|
|
|
@ -274059,6 +274059,11 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"html/browsers/history/joint-session-history/joint-session-history-filler.html": [
|
||||||
|
[
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"html/browsers/history/joint-session-history/joint-session-history-grandchild1.html": [
|
"html/browsers/history/joint-session-history/joint-session-history-grandchild1.html": [
|
||||||
[
|
[
|
||||||
{}
|
{}
|
||||||
|
@ -327276,6 +327281,12 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"html/browsers/history/joint-session-history/joint-session-history-remove-iframe.html": [
|
||||||
|
[
|
||||||
|
"/html/browsers/history/joint-session-history/joint-session-history-remove-iframe.html",
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"html/browsers/history/the-history-interface/001.html": [
|
"html/browsers/history/the-history-interface/001.html": [
|
||||||
[
|
[
|
||||||
"/html/browsers/history/the-history-interface/001.html",
|
"/html/browsers/history/the-history-interface/001.html",
|
||||||
|
@ -554639,6 +554650,10 @@
|
||||||
"c8309aa28105f557d99d7a36e86df977bfe003e9",
|
"c8309aa28105f557d99d7a36e86df977bfe003e9",
|
||||||
"support"
|
"support"
|
||||||
],
|
],
|
||||||
|
"html/browsers/history/joint-session-history/joint-session-history-filler.html": [
|
||||||
|
"54568c8fe456d139e05620c0639a4e60765c8f90",
|
||||||
|
"support"
|
||||||
|
],
|
||||||
"html/browsers/history/joint-session-history/joint-session-history-grandchild1.html": [
|
"html/browsers/history/joint-session-history/joint-session-history-grandchild1.html": [
|
||||||
"c4b5d65cf89e66fc6df209c7166ff56dd66bcf16",
|
"c4b5d65cf89e66fc6df209c7166ff56dd66bcf16",
|
||||||
"support"
|
"support"
|
||||||
|
@ -554651,6 +554666,10 @@
|
||||||
"e5087c8e51160b36134efab21ed2fbc200a9697d",
|
"e5087c8e51160b36134efab21ed2fbc200a9697d",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
|
"html/browsers/history/joint-session-history/joint-session-history-remove-iframe.html": [
|
||||||
|
"2ff693526c5637a11658831961c9ff0a738329de",
|
||||||
|
"testharness"
|
||||||
|
],
|
||||||
"html/browsers/history/the-history-interface/.gitkeep": [
|
"html/browsers/history/the-history-interface/.gitkeep": [
|
||||||
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
||||||
"support"
|
"support"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<body>Filler</body>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Joint session history length does not include entries from a removed iframe.</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body>
|
||||||
|
<iframe id="frame" src="about:blank"></iframe>
|
||||||
|
<script>
|
||||||
|
async_test(function(t) {
|
||||||
|
t.step_timeout(() => {
|
||||||
|
var child = document.getElementById("frame");
|
||||||
|
var old_history_len = history.length;
|
||||||
|
child.onload = () => {
|
||||||
|
assert_equals(old_history_len + 1, history.length);
|
||||||
|
document.body.removeChild(document.getElementById("frame"));
|
||||||
|
assert_equals(old_history_len, history.length);
|
||||||
|
t.done();
|
||||||
|
}
|
||||||
|
child.src = "joint-session-history-filler.html";
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue