E592 when handling page headers, stop if pipeline closed already · servo/servo@b1d764f · GitHub
[go: up one dir, main page]

Skip to content

Commit b1d764f

Browse files
committed
when handling page headers, stop if pipeline closed already
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
1 parent d490c5c commit b1d764f

File tree

3 files changed

+58
-41
lines changed

3 files changed

+58
-41
lines changed

components/script/script_thread.rs

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,52 +2839,51 @@ impl ScriptThread {
28392839
metadata: Option<Metadata>,
28402840
can_gc: CanGc,
28412841
) -> Option<DomRoot<ServoParser>> {
2842-
let idx = self
2842+
if self.closed_pipelines.borrow().contains(id) {
2843+
// If the pipeline has already closed, stop.
2844+
return None;
2845+
}
2846+
2847+
let Some(idx) = self
28432848
.incomplete_loads
28442849
.borrow()
28452850
.iter()
2846-
.position(|load| load.pipeline_id == *id);
2847-
// The matching in progress load structure may not exist if
2848-
// the pipeline exited before the page load completed.
2849-
match idx {
2850-
Some(idx) => {
2851-
// https://html.spec.whatwg.org/multipage/#process-a-navigate-response
2852-
// 2. If response's status is 204 or 205, then abort these steps.
2853-
let is20x = match metadata {
2854-
Some(ref metadata) => metadata.status.in_range(204..=205),
2855-
_ => false,
2856-
};
2851+
.position(|load| load.pipeline_id == *id)
2852+
else {
2853+
unreachable!("Pipeline shouldn't have finished loading.");
2854+
};
28572855

2858-
if is20x {
2859-
// If we have an existing window that is being navigated:
2860-
if let Some(window) = self.documents.borrow().find_window(*id) {
2861-
let window_proxy = window.window_proxy();
2862-
// https://html.spec.whatwg.org/multipage/
2863-
// #navigating-across-documents:delaying-load-events-mode-2
2864-
if window_proxy.parent().is_some() {
2865-
// The user agent must take this nested browsing context
2866-
// out of the delaying load events mode
2867-
// when this navigation algorithm later matures,
2868-
// or when it terminates (whether due to having run all the steps,
2869-
// or being canceled, or being aborted), whichever happens first.
2870-
window_proxy.stop_delaying_load_events_mode();
2871-
}
2872-
}
2873-
self.senders
2874-
.pipeline_to_constellation_sender
2875-
.send((*id, ScriptToConstellationMessage::AbortLoadUrl))
2876-
.unwrap();
2877-
return None;
2878-
};
2856+
// https://html.spec.whatwg.org/multipage/#process-a-navigate-response
2857+
// 2. If response's status is 204 or 205, then abort these steps.
2858+
let is20x = match metadata {
2859+
Some(ref metadata) => metadata.status.in_range(204..=205),
2860+
_ => false,
2861+
};
28792862

2880-
let load = self.incomplete_loads.borrow_mut().remove(idx);
2881-
metadata.map(|meta| self.load(meta, load, can_gc))
2882-
},
2883-
None => {
2884-
assert!(self.closed_pipelines.borrow().contains(id));
2885-
None
2886-
},
2887-
}
2863+
if is20x {
2864+
// If we have an existing window that is being navigated:
2865+
if let Some(window) = self.documents.borrow().find_window(*id) {
2866+
let window_proxy = window.window_proxy();
2867+
// https://html.spec.whatwg.org/multipage/
2868+
// #navigating-across-documents:delaying-load-events-mode-2
2869+
if window_proxy.parent().is_some() {
2870+
// The user agent must take this nested browsing context
2871+
// out of the delaying load events mode
2872+
// when this navigation algorithm later matures,
2873+
// or when it terminates (whether due to having run all the steps,
2874+
// or being canceled, or being aborted), whichever happens first.
2875+
window_proxy.stop_delaying_load_events_mode();
2876+
}
2877+
}
2878+
self.senders
2879+
.pipeline_to_constellation_sender
2880+
.send((*id, ScriptToConstellationMessage::AbortLoadUrl))
2881+
.unwrap();
2882+
return None;
2883+
};
2884+
2885+
let load = self.incomplete_loads.borrow_mut().remove(idx);
2886+
metadata.map(|meta| self.load(meta, load, can_gc))
28882887
}
28892888

28902889
/// Handles a request for the window title.

tests/wpt/mozilla/meta/MANIFEST.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10658,6 +10658,10 @@
1065810658
"192c7235d061b439ef2b57d4b01b170b7412dcdc",
1065910659
[]
1066010660
],
10661+
"navigate_loop_crash.html": [
10662+
"626ca5d87cc9ebb3b5bcb0b8c478ed9a1a0e0c66",
10663+
[]
10664+
],
1066110665
"nested_asap_script.js": [
1066210666
"59562a8c9c39130cad411815059513c4ce0a7c04",
1066310667
[]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<title>Test for #36747: panic: Failed to get browsing context info from constellation.: Disconnected.</title>
3+
<style>
4+
#form { border-image-source: url(database64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7); border-style: solid; }
5+
</style>
6+
<script>
7+
window.addEventListener("load", _ => {
8+
form.submit();
9+
window.frames.stop();
10+
iframe.src = "data:text/html,";
11+
});
12+
</script>
13+
<form id="form">
14+
<iframe id="iframe"></iframe>

0 commit comments

Comments
 (0)
0