From c01b733523085bb9365601c252b7b49154383631 Mon Sep 17 00:00:00 2001 From: Taym Haddadi Date: Thu, 15 Aug 2024 15:42:50 +0200 Subject: [PATCH] Update codegen for GetOpener:inRealms in Bindings.conf (#33062) Signed-off-by: Bentaimia Haddadi --- components/script/dom/bindings/codegen/Bindings.conf | 2 +- components/script/dom/window.rs | 4 ++-- components/script/dom/windowproxy.rs | 9 +++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf index 6024f6e6fd2..7368034cb6e 100644 --- a/components/script/dom/bindings/codegen/Bindings.conf +++ b/components/script/dom/bindings/codegen/Bindings.conf @@ -69,7 +69,7 @@ DOMInterfaces = { }, 'Window': { - 'inRealms': ['Fetch', 'Opener'], + 'inRealms': ['Fetch', 'GetOpener'], }, 'WorkerGlobalScope': { diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 2208a00bac8..af01137b8e1 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -702,7 +702,7 @@ impl WindowMethods for Window { } // https://html.spec.whatwg.org/multipage/#dom-opener - fn GetOpener(&self, cx: JSContext) -> Fallible { + fn GetOpener(&self, cx: JSContext, in_realm_proof: InRealm) -> Fallible { // Step 1, Let current be this Window object's browsing context. let current = match self.window_proxy.get() { Some(proxy) => proxy, @@ -717,7 +717,7 @@ impl WindowMethods for Window { return Ok(NullValue()); } // Step 3 to 5. - Ok(current.opener(*cx)) + Ok(current.opener(*cx, in_realm_proof)) } #[allow(unsafe_code)] diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index 7ea90088509..0715108d757 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -418,7 +418,7 @@ impl WindowProxy { #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-opener - pub fn opener(&self, cx: *mut JSContext) -> JSVal { + pub fn opener(&self, cx: *mut JSContext, in_realm_proof: InRealm) -> JSVal { if self.disowned.get() { return NullValue(); } @@ -436,11 +436,8 @@ impl WindowProxy { opener_id, ) { Some(opener_top_id) => { - let in_realm_proof = - AlreadyInRealm::assert_for_cx(unsafe { SafeJSContext::from_ptr(cx) }); - let global_to_clone_from = unsafe { - GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof)) - }; + let global_to_clone_from = + unsafe { GlobalScope::from_context(cx, in_realm_proof) }; let creator = CreatorBrowsingContextInfo::from(parent_browsing_context, None); WindowProxy::new_dissimilar_origin(