Rewild Your Web
18
fork

Configure Feed

Select the types of activity you want to include in your feed.

webview: setup proxy for cross origin webviews

Signed-off-by: webbeef <me@webbeef.org>

webbeef ab7ef537 6728377a

+47 -13
+47 -13
patches/components/script/dom/html/htmliframeelement.rs.patch
··· 8 8 use js::context::JSContext; 9 9 use js::rust::HandleObject; 10 10 use net_traits::ReferrerPolicy; 11 - @@ -18,37 +19,43 @@ 11 + @@ -18,40 +19,46 @@ 12 12 use profile_traits::ipc as ProfiledIpc; 13 13 use script_bindings::script_runtime::temp_cx; 14 14 use script_traits::{NewPipelineInfo, UpdatePipelineIdReason}; ··· 54 54 +use crate::dom::promise::Promise; 55 55 use crate::dom::trustedtypes::trustedhtml::TrustedHTML; 56 56 use crate::dom::virtualmethods::VirtualMethods; 57 - use crate::dom::windowproxy::WindowProxy; 57 + -use crate::dom::windowproxy::WindowProxy; 58 + +use crate::dom::windowproxy::{CreatorBrowsingContextInfo, WindowProxy}; 59 + use crate::navigation::{ 60 + determine_creation_sandboxing_flags, determine_iframe_element_referrer_policy, 61 + }; 58 62 @@ -80,6 +87,12 @@ 59 63 SrcDoc, 60 64 } ··· 108 112 }; 109 113 110 114 self.pipeline_id.set(Some(new_pipeline_id)); 111 - @@ -626,6 +665,128 @@ 115 + @@ -626,6 +665,158 @@ 112 116 ); 113 117 } 114 118 ··· 217 221 + self.pipeline_id.set(Some(response.new_pipeline_id)); 218 222 + self.webview_id.set(Some(response.new_webview_id)); 219 223 + 224 + + // Register a dissimilar-origin WindowProxy in the parent's 225 + + // script_window_proxies so that contentWindow works for 226 + + // cross-event-loop embedded webviews (e.g., for postMessage). 227 + + if self 228 + + .script_window_proxies 229 + + .find_window_proxy(response.new_browsing_context_id) 230 + + .is_none() 231 + + { 232 + + let global = window.as_global_scope(); 233 + + let cx = GlobalScope::get_cx(); 234 + + // Safety: we need a &mut JSContext for WindowProxy creation. 235 + + // GlobalScope::get_cx() returns SafeJSContext which derefs to *mut JSContext. 236 + + #[expect(unsafe_code)] 237 + + let window_proxy = unsafe { 238 + + let raw_cx = std::ptr::NonNull::new_unchecked(*cx); 239 + + let mut js_cx = js::context::JSContext::from_ptr(raw_cx); 240 + + WindowProxy::new_dissimilar_origin( 241 + + &mut js_cx, 242 + + global, 243 + + response.new_browsing_context_id, 244 + + response.new_webview_id, 245 + + None, 246 + + None, 247 + + CreatorBrowsingContextInfo::from(None, None), 248 + + ) 249 + + }; 250 + + self.script_window_proxies 251 + + .insert(response.new_browsing_context_id, window_proxy); 252 + + } 253 + + 220 254 + // The constellation already spawns the pipeline via Pipeline::spawn() 221 255 + // in handle_create_embedded_webview, so we don't need to spawn it here. 222 256 + }, ··· 237 271 fn destroy_nested_browsing_context(&self) { 238 272 self.pipeline_id.set(None); 239 273 self.pending_pipeline_id.set(None); 240 - @@ -688,6 +849,13 @@ 274 + @@ -688,6 +879,13 @@ 241 275 lazy_load_resumption_steps: Default::default(), 242 276 pending_navigation: Default::default(), 243 277 already_fired_synchronous_load_event: Default::default(), ··· 251 285 } 252 286 } 253 287 254 - @@ -723,6 +891,157 @@ 288 + @@ -723,6 +921,157 @@ 255 289 self.webview_id.get() 256 290 } 257 291 ··· 409 443 #[inline] 410 444 pub(crate) fn sandboxing_flag_set(&self) -> SandboxingFlagSet { 411 445 self.sandboxing_flag_set 412 - @@ -1107,6 +1426,89 @@ 446 + @@ -1107,6 +1456,89 @@ 413 447 414 448 // https://html.spec.whatwg.org/multipage/#dom-iframe-longdesc 415 449 make_url_setter!(SetLongDesc, "longdesc"); ··· 499 533 } 500 534 501 535 impl VirtualMethods for HTMLIFrameElement { 502 - @@ -1162,9 +1564,54 @@ 536 + @@ -1162,9 +1594,54 @@ 503 537 // may be in a different script thread. Instead, we check to see if the parent 504 538 // is in a document tree and has a browsing context, which is what causes 505 539 // the child browsing context to be created. ··· 556 590 } 557 591 }, 558 592 local_name!("loading") => { 559 - @@ -1229,6 +1676,23 @@ 593 + @@ -1229,6 +1706,23 @@ 560 594 561 595 debug!("<iframe> running post connection steps"); 562 596 ··· 580 614 // Step 1. Create a new child navigable for insertedNode. 581 615 self.create_nested_browsing_context(cx); 582 616 583 - @@ -1252,11 +1716,25 @@ 617 + @@ -1252,11 +1746,25 @@ 584 618 fn unbind_from_tree(&self, context: &UnbindContext, can_gc: CanGc) { 585 619 self.super_type().unwrap().unbind_from_tree(context, can_gc); 586 620 ··· 593 627 + let global = window.as_global_scope(); 594 628 + let msg = ScriptToConstellationMessage::RemoveEmbeddedWebView(embedded_webview_id); 595 629 + global.script_to_constellation_chan().send(msg).unwrap(); 596 - 597 - - // The iframe HTML element removing steps, given removedNode, are to destroy a child navigable given removedNode 598 - - self.destroy_child_navigable(&mut cx); 630 + + 599 631 + window 600 632 + .paint_api() 601 633 + .remove_embedded_webview(embedded_webview_id); ··· 603 635 + } else { 604 636 + // TODO: https://github.com/servo/servo/issues/42837 605 637 + let mut cx = unsafe { temp_cx() }; 606 - + 638 + 639 + - // The iframe HTML element removing steps, given removedNode, are to destroy a child navigable given removedNode 640 + - self.destroy_child_navigable(&mut cx); 607 641 + // The iframe HTML element removing steps, given removedNode, are to destroy a child navigable given removedNode 608 642 + self.destroy_child_navigable(&mut cx); 609 643 + }