diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-03-29 04:11:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-29 08:11:27 +0000 |
commit | c30ad5a30e10b9aabe5842624db24b9846c3d5d4 (patch) | |
tree | c879104dc5ef15647d975da14a6b703d4099df4d /components/script/dom/servointernals.rs | |
parent | 2c9411095255f804a43c2abc05c5aaa2a0becca7 (diff) | |
download | servo-c30ad5a30e10b9aabe5842624db24b9846c3d5d4.tar.gz servo-c30ad5a30e10b9aabe5842624db24b9846c3d5d4.zip |
Miscellaneous script splitting preparation changes (#36216)
* script: Move num module to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Make JS reflector creation generic over DOM trait.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Move bindings-specific lock to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Move DOM proto array code to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Move finalizer implementations to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Move some error routines to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Move some DOM interface conversion routines to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Make is_array_like generic over DOM trait.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Use generic interfaces for conditional exposure functions.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Move a bunch of routines used by codegen to script_bindings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix clippy warnings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/servointernals.rs')
-rw-r--r-- | components/script/dom/servointernals.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/components/script/dom/servointernals.rs b/components/script/dom/servointernals.rs index 295bd838443..58d749d8227 100644 --- a/components/script/dom/servointernals.rs +++ b/components/script/dom/servointernals.rs @@ -5,7 +5,10 @@ use std::rc::Rc; use dom_struct::dom_struct; +use js::rust::HandleObject; use profile_traits::mem::MemoryReportResult; +use script_bindings::interfaces::ServoInternalsHelpers; +use script_bindings::script_runtime::JSContext; use script_traits::ScriptMsg; use crate::dom::bindings::codegen::Bindings::ServoInternalsBinding::ServoInternalsMethods; @@ -14,7 +17,7 @@ use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use crate::dom::promise::Promise; -use crate::realms::InRealm; +use crate::realms::{AlreadyInRealm, InRealm}; use crate::routed_promise::{RoutedPromiseListener, route_promise}; use crate::script_runtime::CanGc; @@ -57,3 +60,16 @@ impl RoutedPromiseListener<MemoryReportResult> for ServoInternals { promise.resolve_native(&response.content, can_gc); } } + +impl ServoInternalsHelpers for ServoInternals { + /// The navigator.servo api is only exposed to about: pages except about:blank + #[allow(unsafe_code)] + fn is_servo_internal(cx: JSContext, _global: HandleObject) -> bool { + unsafe { + let in_realm_proof = AlreadyInRealm::assert_for_cx(cx); + let global_scope = GlobalScope::from_context(*cx, InRealm::Already(&in_realm_proof)); + let url = global_scope.get_url(); + url.scheme() == "about" && url.as_str() != "about:blank" + } + } +} |