@@ -2839,52 +2839,51 @@ impl ScriptThread {
2839
2839
metadata : Option < Metadata > ,
2840
2840
can_gc : CanGc ,
2841
2841
) -> 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
2843
2848
. incomplete_loads
2844
2849
. borrow ( )
2845
2850
. 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
+ } ;
2857
2855
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
+ } ;
2879
2862
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) )
2888
2887
}
2889
2888
2890
2889
/// Handles a request for the window title.
0 commit comments