Rewild Your Web
web browser dweb

constellation: ensure non embedded iframes are not considered as top-level BC

+18 -13
+18 -13
patches/components/constellation/constellation.rs.patch
··· 88 88 let new_pipeline_info = NewPipelineInfo { 89 89 parent_info: parent_pipeline_id, 90 90 new_pipeline_id, 91 - @@ -1051,6 +1085,8 @@ 91 + @@ -1051,6 +1085,13 @@ 92 92 viewport_details: initial_viewport_details, 93 93 user_content_manager_id, 94 94 theme, 95 - + is_embedded_webview: self.embedded_webview_to_iframe.contains_key(&webview_id), 95 + + // Only set is_embedded_webview=true if this browsing context IS the embedded webview itself, 96 + + // not for regular iframes inside the embedded webview that happen to share the same webview_id 97 + + is_embedded_webview: self 98 + + .embedded_webview_to_iframe 99 + + .get(&webview_id) 100 + + .is_some_and(|(embedded_bc_id, _)| *embedded_bc_id == browsing_context_id), 96 101 + hide_focus, 97 102 }; 98 103 let pipeline = match Pipeline::spawn(new_pipeline_info, event_loop, self, throttled) { 99 104 Ok(pipeline) => pipeline, 100 - @@ -1522,11 +1558,7 @@ 105 + @@ -1522,11 +1563,7 @@ 101 106 } 102 107 }, 103 108 EmbedderToConstellationMessage::PreferencesUpdated(updates) => { ··· 110 115 let _ = event_loop.send(ScriptThreadMessage::PreferencesUpdated( 111 116 updates 112 117 .iter() 113 - @@ -1550,6 +1582,18 @@ 118 + @@ -1550,6 +1587,18 @@ 114 119 EmbedderToConstellationMessage::UpdatePinchZoomInfos(pipeline_id, pinch_zoom) => { 115 120 self.handle_update_pinch_zoom_infos(pipeline_id, pinch_zoom); 116 121 }, ··· 129 134 } 130 135 } 131 136 132 - @@ -1773,6 +1817,12 @@ 137 + @@ -1773,6 +1822,12 @@ 133 138 self.broadcast_channels 134 139 .remove_broadcast_channel_router(router_id); 135 140 }, ··· 142 147 ScriptToConstellationMessage::ScheduleBroadcast(router_id, message) => { 143 148 if self 144 149 .check_origin_against_pipeline(&source_pipeline_id, &message.origin) 145 - @@ -1803,6 +1853,12 @@ 150 + @@ -1803,6 +1858,12 @@ 146 151 ScriptToConstellationMessage::CreateAuxiliaryWebView(load_info) => { 147 152 self.handle_script_new_auxiliary(load_info); 148 153 }, ··· 155 160 ScriptToConstellationMessage::ChangeRunningAnimationsState(animation_state) => { 156 161 self.handle_change_running_animations_state(source_pipeline_id, animation_state) 157 162 }, 158 - @@ -1969,6 +2025,23 @@ 163 + @@ -1969,6 +2030,23 @@ 159 164 new_value, 160 165 ); 161 166 }, ··· 179 184 ScriptToConstellationMessage::MediaSessionEvent(pipeline_id, event) => { 180 185 // Unlikely at this point, but we may receive events coming from 181 186 // different media sessions, so we set the active media session based 182 - @@ -2037,6 +2110,129 @@ 187 + @@ -2037,6 +2115,129 @@ 183 188 ScriptToConstellationMessage::RespondToScreenshotReadinessRequest(response) => { 184 189 self.handle_screenshot_readiness_response(source_pipeline_id, response); 185 190 }, ··· 309 314 } 310 315 } 311 316 312 - @@ -3135,6 +3331,13 @@ 317 + @@ -3135,6 +3336,13 @@ 313 318 /// <https://html.spec.whatwg.org/multipage/#destroy-a-top-level-traversable> 314 319 fn handle_close_top_level_browsing_context(&mut self, webview_id: WebViewId) { 315 320 debug!("{webview_id}: Closing"); ··· 323 328 let browsing_context_id = BrowsingContextId::from(webview_id); 324 329 // Step 5. Remove traversable from the user agent's top-level traversable set. 325 330 let browsing_context = 326 - @@ -3411,8 +3614,27 @@ 331 + @@ -3411,8 +3619,27 @@ 327 332 opener_webview_id, 328 333 opener_pipeline_id, 329 334 response_sender, ··· 351 356 let Some((webview_id_sender, webview_id_receiver)) = generic_channel::channel() else { 352 357 warn!("Failed to create channel"); 353 358 let _ = response_sender.send(None); 354 - @@ -3510,6 +3732,359 @@ 359 + @@ -3510,6 +3737,359 @@ 355 360 }); 356 361 } 357 362 ··· 711 716 #[servo_tracing::instrument(skip_all)] 712 717 fn handle_refresh_cursor(&self, pipeline_id: PipelineId) { 713 718 let Some(pipeline) = self.pipelines.get(&pipeline_id) else { 714 - @@ -4632,7 +5207,7 @@ 719 + @@ -4632,7 +5212,7 @@ 715 720 } 716 721 717 722 #[servo_tracing::instrument(skip_all)] ··· 720 725 // Send a flat projection of the history to embedder. 721 726 // The final vector is a concatenation of the URLs of the past 722 727 // entries, the current entry and the future entries. 723 - @@ -4735,9 +5310,23 @@ 728 + @@ -4735,9 +5315,23 @@ 724 729 ); 725 730 self.embedder_proxy.send(EmbedderMsg::HistoryChanged( 726 731 webview_id,