diff options
Diffstat (limited to 'components/script/dom/windowproxy.rs')
-rw-r--r-- | components/script/dom/windowproxy.rs | 425 |
1 files changed, 245 insertions, 180 deletions
diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index f7d677b37fc..d1b5c185565 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -97,15 +97,17 @@ pub struct WindowProxy { } impl WindowProxy { - pub fn new_inherited(browsing_context_id: BrowsingContextId, - top_level_browsing_context_id: TopLevelBrowsingContextId, - currently_active: Option<PipelineId>, - frame_element: Option<&Element>, - parent: Option<&WindowProxy>, - opener: Option<BrowsingContextId>) - -> WindowProxy - { - let name = frame_element.map_or(DOMString::new(), |e| e.get_string_attribute(&local_name!("name"))); + pub fn new_inherited( + browsing_context_id: BrowsingContextId, + top_level_browsing_context_id: TopLevelBrowsingContextId, + currently_active: Option<PipelineId>, + frame_element: Option<&Element>, + parent: Option<&WindowProxy>, + opener: Option<BrowsingContextId>, + ) -> WindowProxy { + let name = frame_element.map_or(DOMString::new(), |e| { + e.get_string_attribute(&local_name!("name")) + }); WindowProxy { reflector: Reflector::new(), browsing_context_id: browsing_context_id, @@ -121,14 +123,14 @@ impl WindowProxy { } #[allow(unsafe_code)] - pub fn new(window: &Window, - browsing_context_id: BrowsingContextId, - top_level_browsing_context_id: TopLevelBrowsingContextId, - frame_element: Option<&Element>, - parent: Option<&WindowProxy>, - opener: Option<BrowsingContextId>) - -> DomRoot<WindowProxy> - { + pub fn new( + window: &Window, + browsing_context_id: BrowsingContextId, + top_level_browsing_context_id: TopLevelBrowsingContextId, + frame_element: Option<&Element>, + parent: Option<&WindowProxy>, + opener: Option<BrowsingContextId>, + ) -> DomRoot<WindowProxy> { unsafe { let WindowProxyHandler(handler) = window.windowproxy_handler(); assert!(!handler.is_null()); @@ -136,7 +138,10 @@ impl WindowProxy { let cx = window.get_cx(); let window_jsobject = window.reflector().get_jsobject(); assert!(!window_jsobject.get().is_null()); - assert_ne!(((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL), 0); + assert_ne!( + ((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL), + 0 + ); let _ac = JSAutoCompartment::new(cx, window_jsobject.get()); // Create a new window proxy. @@ -156,26 +161,34 @@ impl WindowProxy { // The window proxy owns the browsing context. // When we finalize the window proxy, it drops the browsing context it owns. - SetProxyReservedSlot(js_proxy.get(), 0, &PrivateValue((&*window_proxy).as_void_ptr())); + SetProxyReservedSlot( + js_proxy.get(), + 0, + &PrivateValue((&*window_proxy).as_void_ptr()), + ); // Notify the JS engine about the new window proxy binding. SetWindowProxy(cx, window_jsobject, js_proxy.handle()); // Set the reflector. - debug!("Initializing reflector of {:p} to {:p}.", window_proxy, js_proxy.get()); + debug!( + "Initializing reflector of {:p} to {:p}.", + window_proxy, + js_proxy.get() + ); window_proxy.reflector.set_jsobject(js_proxy.get()); DomRoot::from_ref(&*Box::into_raw(window_proxy)) } } #[allow(unsafe_code)] - pub fn new_dissimilar_origin(global_to_clone_from: &GlobalScope, - browsing_context_id: BrowsingContextId, - top_level_browsing_context_id: TopLevelBrowsingContextId, - parent: Option<&WindowProxy>, - opener: Option<BrowsingContextId>) - -> DomRoot<WindowProxy> - { + pub fn new_dissimilar_origin( + global_to_clone_from: &GlobalScope, + browsing_context_id: BrowsingContextId, + top_level_browsing_context_id: TopLevelBrowsingContextId, + parent: Option<&WindowProxy>, + opener: Option<BrowsingContextId>, + ) -> DomRoot<WindowProxy> { unsafe { let handler = CreateWrapperProxyHandler(&XORIGIN_PROXY_HANDLER); assert!(!handler.is_null()); @@ -189,14 +202,17 @@ impl WindowProxy { None, None, parent, - opener + opener, )); // Create a new dissimilar-origin window. let window = DissimilarOriginWindow::new(global_to_clone_from, &*window_proxy); let window_jsobject = window.reflector().get_jsobject(); assert!(!window_jsobject.get().is_null()); - assert_ne!(((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL), 0); + assert_ne!( + ((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL), + 0 + ); let _ac = JSAutoCompartment::new(cx, window_jsobject.get()); // Create a new window proxy. @@ -205,30 +221,45 @@ impl WindowProxy { // The window proxy owns the browsing context. // When we finalize the window proxy, it drops the browsing context it owns. - SetProxyReservedSlot(js_proxy.get(), 0, &PrivateValue((&*window_proxy).as_void_ptr())); + SetProxyReservedSlot( + js_proxy.get(), + 0, + &PrivateValue((&*window_proxy).as_void_ptr()), + ); // Notify the JS engine about the new window proxy binding. SetWindowProxy(cx, window_jsobject, js_proxy.handle()); // Set the reflector. - debug!("Initializing reflector of {:p} to {:p}.", window_proxy, js_proxy.get()); + debug!( + "Initializing reflector of {:p} to {:p}.", + window_proxy, + js_proxy.get() + ); window_proxy.reflector.set_jsobject(js_proxy.get()); DomRoot::from_ref(&*Box::into_raw(window_proxy)) } } // https://html.spec.whatwg.org/multipage/#auxiliary-browsing-context - fn create_auxiliary_browsing_context(&self, name: DOMString, noopener: bool) -> Option<DomRoot<WindowProxy>> { + fn create_auxiliary_browsing_context( + &self, + name: DOMString, + noopener: bool, + ) -> Option<DomRoot<WindowProxy>> { let (chan, port) = ipc::channel().unwrap(); - let window = self.currently_active.get() - .and_then(|id| ScriptThread::find_document(id)) - .and_then(|doc| Some(DomRoot::from_ref(doc.window()))) - .unwrap(); + let window = self + .currently_active + .get() + .and_then(|id| ScriptThread::find_document(id)) + .and_then(|doc| Some(DomRoot::from_ref(doc.window()))) + .unwrap(); let msg = EmbedderMsg::AllowOpeningBrowser(chan); window.send_to_embedder(msg); if port.recv().unwrap() { let new_top_level_browsing_context_id = TopLevelBrowsingContextId::new(); - let new_browsing_context_id = BrowsingContextId::from(new_top_level_browsing_context_id); + let new_browsing_context_id = + BrowsingContextId::from(new_top_level_browsing_context_id); let new_pipeline_id = PipelineId::new(); let load_info = AuxiliaryBrowsingContextLoadInfo { opener_pipeline_id: self.currently_active.get().unwrap(), @@ -236,14 +267,18 @@ impl WindowProxy { new_top_level_browsing_context_id: new_top_level_browsing_context_id, new_pipeline_id: new_pipeline_id, }; - let document = self.currently_active.get() + let document = self + .currently_active + .get() .and_then(|id| ScriptThread::find_document(id)) .unwrap(); let blank_url = ServoUrl::parse("about:blank").ok().unwrap(); - let load_data = LoadData::new(blank_url, - None, - document.get_referrer_policy(), - Some(document.url().clone())); + let load_data = LoadData::new( + blank_url, + None, + document.get_referrer_policy(), + Some(document.url().clone()), + ); let (pipeline_sender, pipeline_receiver) = ipc::channel().unwrap(); let new_layout_info = NewLayoutInfo { parent_info: None, @@ -264,7 +299,8 @@ impl WindowProxy { window.send_to_embedder(msg); // TODO: if noopener is false, copy the sessionStorage storage area of the creator origin. // See step 14 of https://html.spec.whatwg.org/multipage/#creating-a-new-browsing-context - let auxiliary = ScriptThread::find_document(new_pipeline_id).and_then(|doc| doc.browsing_context()); + let auxiliary = + ScriptThread::find_document(new_pipeline_id).and_then(|doc| doc.browsing_context()); if let Some(proxy) = auxiliary { if name.to_lowercase() != "_blank" { proxy.set_name(name); @@ -272,7 +308,7 @@ impl WindowProxy { if noopener { proxy.disown(); } - return Some(proxy) + return Some(proxy); } } None @@ -287,17 +323,20 @@ impl WindowProxy { // https://html.spec.whatwg.org/multipage/#dom-opener pub unsafe fn opener(&self, cx: *mut JSContext) -> JSVal { if self.disowned.get() { - return NullValue() + return NullValue(); } let opener_id = match self.opener { Some(opener_browsing_context_id) => opener_browsing_context_id, - None => return NullValue() + None => return NullValue(), }; let opener_proxy = match ScriptThread::find_window_proxy(opener_id) { Some(window_proxy) => window_proxy, None => { let sender_pipeline_id = self.currently_active().unwrap(); - match ScriptThread::get_top_level_for_browsing_context(sender_pipeline_id, opener_id) { + match ScriptThread::get_top_level_for_browsing_context( + sender_pipeline_id, + opener_id, + ) { Some(opener_top_id) => { let global_to_clone_from = GlobalScope::from_context(cx); WindowProxy::new_dissimilar_origin( @@ -305,31 +344,32 @@ impl WindowProxy { opener_id, opener_top_id, None, - None + None, ) }, - None => return NullValue() + None => return NullValue(), } - } + }, }; if opener_proxy.is_browsing_context_discarded() { - return NullValue() + return NullValue(); } rooted!(in(cx) let mut val = UndefinedValue()); opener_proxy.to_jsval(cx, val.handle_mut()); - return val.get() + return val.get(); } // https://html.spec.whatwg.org/multipage/#window-open-steps - pub fn open(&self, - url: DOMString, - target: DOMString, - features: DOMString) - -> Option<DomRoot<WindowProxy>> { + pub fn open( + &self, + url: DOMString, + target: DOMString, + features: DOMString, + ) -> Option<DomRoot<WindowProxy>> { // Step 3. let non_empty_target = match target.as_ref() { "" => DOMString::from("_blank"), - _ => target + _ => target, }; // TODO Step 4, properly tokenize features. // Step 5 @@ -337,19 +377,22 @@ impl WindowProxy { // Step 6, 7 let (chosen, new) = match self.choose_browsing_context(non_empty_target, noopener) { (Some(chosen), new) => (chosen, new), - (None, _) => return None + (None, _) => return None, }; // TODO Step 8, set up browsing context features. let target_document = match chosen.document() { Some(target_document) => target_document, - None => return None + None => return None, }; let target_window = target_document.window(); // Step 9, and 10.2, will have happened elsewhere, // since we've created a new browsing context and loaded it with about:blank. if !url.is_empty() { - let existing_document = self.currently_active.get() - .and_then(|id| ScriptThread::find_document(id)).unwrap(); + let existing_document = self + .currently_active + .get() + .and_then(|id| ScriptThread::find_document(id)) + .unwrap(); // Step 10.1 let url = match existing_document.url().join(&url) { Ok(url) => url, @@ -360,14 +403,18 @@ impl WindowProxy { } if noopener { // Step 11 (Dis-owning has been done in create_auxiliary_browsing_context). - return None + return None; } // Step 12. - return target_document.browsing_context() + return target_document.browsing_context(); } // https://html.spec.whatwg.org/multipage/#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name - pub fn choose_browsing_context(&self, name: DOMString, noopener: bool) -> (Option<DomRoot<WindowProxy>>, bool) { + pub fn choose_browsing_context( + &self, + name: DOMString, + noopener: bool, + ) -> (Option<DomRoot<WindowProxy>>, bool) { match name.to_lowercase().as_ref() { "" | "_self" => { // Step 3. @@ -376,18 +423,15 @@ impl WindowProxy { "_parent" => { // Step 4 if let Some(parent) = self.parent() { - return (Some(DomRoot::from_ref(parent)), false) + return (Some(DomRoot::from_ref(parent)), false); } (None, false) - }, "_top" => { // Step 5 (Some(DomRoot::from_ref(self.top())), false) }, - "_blank" => { - (self.create_auxiliary_browsing_context(name, noopener), true) - }, + "_blank" => (self.create_auxiliary_browsing_context(name, noopener), true), _ => { // Step 6. // TODO: expand the search to all 'familiar' bc, @@ -395,9 +439,9 @@ impl WindowProxy { // See https://html.spec.whatwg.org/multipage/#familiar-with match ScriptThread::find_window_proxy_by_name(&name) { Some(proxy) => (Some(proxy), false), - None => (self.create_auxiliary_browsing_context(name, noopener), true) + None => (self.create_auxiliary_browsing_context(name, noopener), true), } - } + }, } } @@ -426,7 +470,8 @@ impl WindowProxy { } pub fn document(&self) -> Option<DomRoot<Document>> { - self.currently_active.get() + self.currently_active + .get() .and_then(|id| ScriptThread::find_document(id)) } @@ -456,7 +501,10 @@ impl WindowProxy { let window_jsobject = window.reflector().get_jsobject(); let old_js_proxy = self.reflector.get_jsobject(); assert!(!window_jsobject.get().is_null()); - assert_ne!(((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL), 0); + assert_ne!( + ((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL), + 0 + ); let _ac = JSAutoCompartment::new(cx, window_jsobject.get()); // The old window proxy no longer owns this browsing context. @@ -470,7 +518,11 @@ impl WindowProxy { // making the old window proxy a cross-compartment wrapper // pointing to the new window proxy. rooted!(in(cx) let new_js_proxy = NewWindowProxy(cx, window_jsobject, handler)); - debug!("Transplanting proxy from {:p} to {:p}.", old_js_proxy.get(), new_js_proxy.get()); + debug!( + "Transplanting proxy from {:p} to {:p}.", + old_js_proxy.get(), + new_js_proxy.get() + ); rooted!(in(cx) let new_js_proxy = JS_TransplantObject(cx, old_js_proxy, new_js_proxy.handle())); debug!("Transplanted proxy is {:p}.", new_js_proxy.get()); @@ -481,7 +533,11 @@ impl WindowProxy { SetWindowProxy(cx, window_jsobject, new_js_proxy.handle()); // Update the reflector. - debug!("Setting reflector of {:p} to {:p}.", self, new_js_proxy.get()); + debug!( + "Setting reflector of {:p} to {:p}.", + self, + new_js_proxy.get() + ); self.reflector.rootable().set(new_js_proxy.get()); } } @@ -519,7 +575,7 @@ impl WindowProxy { unsafe fn GetSubframeWindowProxy( cx: *mut JSContext, proxy: RawHandleObject, - id: RawHandleId + id: RawHandleId, ) -> Option<(DomRoot<WindowProxy>, u32)> { let index = get_array_index_from_id(cx, Handle::from_raw(id)); if let Some(index) = index { @@ -530,14 +586,17 @@ unsafe fn GetSubframeWindowProxy( let browsing_context_id = win.window_proxy().browsing_context_id(); let (result_sender, result_receiver) = ipc::channel().unwrap(); - let _ = win.upcast::<GlobalScope>().script_to_constellation_chan().send( - ScriptMsg::GetChildBrowsingContextId( + let _ = win + .upcast::<GlobalScope>() + .script_to_constellation_chan() + .send(ScriptMsg::GetChildBrowsingContextId( browsing_context_id, index as usize, - result_sender - ) - ); - return result_receiver.recv().ok() + result_sender, + )); + return result_receiver + .recv() + .ok() .and_then(|maybe_bcid| maybe_bcid) .and_then(ScriptThread::find_window_proxy) .map(|proxy| (proxy, (JSPROP_ENUMERATE | JSPROP_READONLY) as u32)); @@ -545,12 +604,16 @@ unsafe fn GetSubframeWindowProxy( let browsing_context_id = win.window_proxy().browsing_context_id(); let (result_sender, result_receiver) = ipc::channel().unwrap(); - let _ = win.global().script_to_constellation_chan().send(ScriptMsg::GetChildBrowsingContextId( - browsing_context_id, - index as usize, - result_sender - )); - return result_receiver.recv().ok() + let _ = win.global().script_to_constellation_chan().send( + ScriptMsg::GetChildBrowsingContextId( + browsing_context_id, + index as usize, + result_sender, + ), + ); + return result_receiver + .recv() + .ok() .and_then(|maybe_bcid| maybe_bcid) .and_then(ScriptThread::find_window_proxy) .map(|proxy| (proxy, JSPROP_READONLY as u32)); @@ -561,11 +624,12 @@ unsafe fn GetSubframeWindowProxy( } #[allow(unsafe_code)] -unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext, - proxy: RawHandleObject, - id: RawHandleId, - mut desc: RawMutableHandle<PropertyDescriptor>) - -> bool { +unsafe extern "C" fn getOwnPropertyDescriptor( + cx: *mut JSContext, + proxy: RawHandleObject, + id: RawHandleId, + mut desc: RawMutableHandle<PropertyDescriptor>, +) -> bool { let window = GetSubframeWindowProxy(cx, proxy, id); if let Some((window, attrs)) = window { rooted!(in(cx) let mut val = UndefinedValue()); @@ -592,12 +656,13 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext, } #[allow(unsafe_code)] -unsafe extern "C" fn defineProperty(cx: *mut JSContext, - proxy: RawHandleObject, - id: RawHandleId, - desc: RawHandle<PropertyDescriptor>, - res: *mut ObjectOpResult) - -> bool { +unsafe extern "C" fn defineProperty( + cx: *mut JSContext, + proxy: RawHandleObject, + id: RawHandleId, + desc: RawHandle<PropertyDescriptor>, + res: *mut ObjectOpResult, +) -> bool { if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() { // Spec says to Reject whether this is a supported index or not, // since we have no indexed setter or indexed creator. That means @@ -614,11 +679,12 @@ unsafe extern "C" fn defineProperty(cx: *mut JSContext, } #[allow(unsafe_code)] -unsafe extern "C" fn has(cx: *mut JSContext, - proxy: RawHandleObject, - id: RawHandleId, - bp: *mut bool) - -> bool { +unsafe extern "C" fn has( + cx: *mut JSContext, + proxy: RawHandleObject, + id: RawHandleId, + bp: *mut bool, +) -> bool { let window = GetSubframeWindowProxy(cx, proxy, id); if window.is_some() { *bp = true; @@ -638,12 +704,13 @@ unsafe extern "C" fn has(cx: *mut JSContext, } #[allow(unsafe_code)] -unsafe extern "C" fn get(cx: *mut JSContext, - proxy: RawHandleObject, - receiver: RawHandleValue, - id: RawHandleId, - vp: RawMutableHandleValue) - -> bool { +unsafe extern "C" fn get( + cx: *mut JSContext, + proxy: RawHandleObject, + receiver: RawHandleValue, + id: RawHandleId, + vp: RawMutableHandleValue, +) -> bool { let window = GetSubframeWindowProxy(cx, proxy, id); if let Some((window, _attrs)) = window { window.to_jsval(cx, MutableHandle::from_raw(vp)); @@ -657,13 +724,14 @@ unsafe extern "C" fn get(cx: *mut JSContext, } #[allow(unsafe_code)] -unsafe extern "C" fn set(cx: *mut JSContext, - proxy: RawHandleObject, - id: RawHandleId, - v: RawHandleValue, - receiver: RawHandleValue, - res: *mut ObjectOpResult) - -> bool { +unsafe extern "C" fn set( + cx: *mut JSContext, + proxy: RawHandleObject, + id: RawHandleId, + v: RawHandleValue, + receiver: RawHandleValue, + res: *mut ObjectOpResult, +) -> bool { if get_array_index_from_id(cx, Handle::from_raw(id)).is_some() { // Reject (which means throw if and only if strict) the set. (*res).code_ = JSErrNum::JSMSG_READ_ONLY as ::libc::uintptr_t; @@ -673,20 +741,16 @@ unsafe extern "C" fn set(cx: *mut JSContext, let mut slot = UndefinedValue(); GetProxyPrivate(*proxy.ptr, &mut slot); rooted!(in(cx) let target = slot.to_object()); - JS_ForwardSetPropertyTo(cx, - target.handle().into(), - id, - v, - receiver, - res) + JS_ForwardSetPropertyTo(cx, target.handle().into(), id, v, receiver, res) } #[allow(unsafe_code)] -unsafe extern "C" fn get_prototype_if_ordinary(_: *mut JSContext, - _: RawHandleObject, - is_ordinary: *mut bool, - _: RawMutableHandleObject) - -> bool { +unsafe extern "C" fn get_prototype_if_ordinary( + _: *mut JSContext, + _: RawHandleObject, + is_ordinary: *mut bool, + _: RawMutableHandleObject, +) -> bool { // Window's [[GetPrototypeOf]] trap isn't the ordinary definition: // // https://html.spec.whatwg.org/multipage/#windowproxy-getprototypeof @@ -737,9 +801,7 @@ static PROXY_HANDLER: ProxyTraps = ProxyTraps { #[allow(unsafe_code)] pub fn new_window_proxy_handler() -> WindowProxyHandler { - unsafe { - WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER)) - } + unsafe { WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER)) } } // The proxy traps for cross-origin windows. @@ -756,12 +818,12 @@ unsafe fn throw_security_error(cx: *mut JSContext) -> bool { } #[allow(unsafe_code)] -unsafe extern "C" fn has_xorigin(cx: *mut JSContext, - proxy: RawHandleObject, - id: RawHandleId, - bp: *mut bool) - -> bool -{ +unsafe extern "C" fn has_xorigin( + cx: *mut JSContext, + proxy: RawHandleObject, + id: RawHandleId, + bp: *mut bool, +) -> bool { let mut slot = UndefinedValue(); GetProxyPrivate(*proxy.ptr, &mut slot); rooted!(in(cx) let target = slot.to_object()); @@ -776,69 +838,69 @@ unsafe extern "C" fn has_xorigin(cx: *mut JSContext, } #[allow(unsafe_code)] -unsafe extern "C" fn get_xorigin(cx: *mut JSContext, - proxy: RawHandleObject, - receiver: RawHandleValue, - id: RawHandleId, - vp: RawMutableHandleValue) - -> bool -{ +unsafe extern "C" fn get_xorigin( + cx: *mut JSContext, + proxy: RawHandleObject, + receiver: RawHandleValue, + id: RawHandleId, + vp: RawMutableHandleValue, +) -> bool { let mut found = false; has_xorigin(cx, proxy, id, &mut found); found && get(cx, proxy, receiver, id, vp) } #[allow(unsafe_code)] -unsafe extern "C" fn set_xorigin(cx: *mut JSContext, - _: RawHandleObject, - _: RawHandleId, - _: RawHandleValue, - _: RawHandleValue, - _: *mut ObjectOpResult) - -> bool -{ +unsafe extern "C" fn set_xorigin( + cx: *mut JSContext, + _: RawHandleObject, + _: RawHandleId, + _: RawHandleValue, + _: RawHandleValue, + _: *mut ObjectOpResult, +) -> bool { throw_security_error(cx) } #[allow(unsafe_code)] -unsafe extern "C" fn delete_xorigin(cx: *mut JSContext, - _: RawHandleObject, - _: RawHandleId, - _: *mut ObjectOpResult) - -> bool -{ +unsafe extern "C" fn delete_xorigin( + cx: *mut JSContext, + _: RawHandleObject, + _: RawHandleId, + _: *mut ObjectOpResult, +) -> bool { throw_security_error(cx) } #[allow(unsafe_code)] -unsafe extern "C" fn getOwnPropertyDescriptor_xorigin(cx: *mut JSContext, - proxy: RawHandleObject, - id: RawHandleId, - desc: RawMutableHandle<PropertyDescriptor>) - -> bool -{ +unsafe extern "C" fn getOwnPropertyDescriptor_xorigin( + cx: *mut JSContext, + proxy: RawHandleObject, + id: RawHandleId, + desc: RawMutableHandle<PropertyDescriptor>, +) -> bool { let mut found = false; has_xorigin(cx, proxy, id, &mut found); found && getOwnPropertyDescriptor(cx, proxy, id, desc) } #[allow(unsafe_code)] -unsafe extern "C" fn defineProperty_xorigin(cx: *mut JSContext, - _: RawHandleObject, - _: RawHandleId, - _: RawHandle<PropertyDescriptor>, - _: *mut ObjectOpResult) - -> bool -{ +unsafe extern "C" fn defineProperty_xorigin( + cx: *mut JSContext, + _: RawHandleObject, + _: RawHandleId, + _: RawHandle<PropertyDescriptor>, + _: *mut ObjectOpResult, +) -> bool { throw_security_error(cx) } #[allow(unsafe_code)] -unsafe extern "C" fn preventExtensions_xorigin(cx: *mut JSContext, - _: RawHandleObject, - _: *mut ObjectOpResult) - -> bool -{ +unsafe extern "C" fn preventExtensions_xorigin( + cx: *mut JSContext, + _: RawHandleObject, + _: *mut ObjectOpResult, +) -> bool { throw_security_error(cx) } @@ -877,7 +939,7 @@ static XORIGIN_PROXY_HANDLER: ProxyTraps = ProxyTraps { // How WindowProxy objects are garbage collected. #[allow(unsafe_code)] -unsafe extern fn finalize(_fop: *mut JSFreeOp, obj: *mut JSObject) { +unsafe extern "C" fn finalize(_fop: *mut JSFreeOp, obj: *mut JSObject) { let mut slot = UndefinedValue(); GetProxyReservedSlot(obj, 0, &mut slot); let this = slot.to_private() as *mut WindowProxy; @@ -886,12 +948,15 @@ unsafe extern fn finalize(_fop: *mut JSFreeOp, obj: *mut JSObject) { return; } let jsobject = (*this).reflector.get_jsobject().get(); - debug!("WindowProxy finalize: {:p}, with reflector {:p} from {:p}.", this, jsobject, obj); + debug!( + "WindowProxy finalize: {:p}, with reflector {:p} from {:p}.", + this, jsobject, obj + ); let _ = Box::from_raw(this); } #[allow(unsafe_code)] -unsafe extern fn trace(trc: *mut JSTracer, obj: *mut JSObject) { +unsafe extern "C" fn trace(trc: *mut JSTracer, obj: *mut JSObject) { let mut slot = UndefinedValue(); GetProxyReservedSlot(obj, 0, &mut slot); let this = slot.to_private() as *const WindowProxy; |