Skip to main content

MockServoBackend

Struct MockServoBackend 

Source
pub struct MockServoBackend {
    pub call_log: Mutex<Vec<(String, String, String)>>,
    pub default_frame_id: String,
    pub known_targets: Mutex<Vec<String>>,
}
Expand description

Mock backend — 用于单元测试 command dispatcher。

默认所有方法返回成功空响应。可通过字段调整特定响应。

@trace REQ-BAO-API-004 [level:library]

Fields§

§call_log: Mutex<Vec<(String, String, String)>>

调用记录 (target_id, method, payload_summary)。

§default_frame_id: String

Page.navigate 默认返回的 frame_id。

§known_targets: Mutex<Vec<String>>

已存在的 target_id 集合 — page_* 命令查不到时返回 PageNotFound。

Implementations§

Source§

impl MockServoBackend

Source

pub fn new() -> MockServoBackend

构造默认 mock。

Source

pub fn into_backend(self) -> Arc<dyn ServoBackend>

包装为 Arc<dyn ServoBackend>

Source

pub fn add_target(&self, target_id: impl Into<String>)

添加已知 target。

Trait Implementations§

Source§

impl Default for MockServoBackend

Source§

fn default() -> MockServoBackend

Returns the “default value” for a type. Read more
Source§

impl ServoBackend for MockServoBackend

Source§

fn page_navigate( &self, target_id: &str, url: &str, ) -> Result<NavigateResult, BridgeError>

Page.navigate — 加载 URL。 Read more
Source§

fn page_reload(&self, target_id: &str) -> Result<(), BridgeError>

Page.reload — 重新加载当前页面。 Read more
Source§

fn page_screenshot( &self, target_id: &str, format: BridgeScreenshotFormat, ) -> Result<Vec<u8>, BridgeError>

Page.captureScreenshot — 截屏。 Read more
Source§

fn page_frame_tree(&self, target_id: &str) -> Result<FrameTree, BridgeError>

Page.getFrameTree — 返回 frame 树。 Read more
Source§

fn page_navigation_history( &self, target_id: &str, ) -> Result<NavigationHistory, BridgeError>

Page.getNavigationHistory — 返回导航历史。 Read more
Source§

fn page_navigate_to_history_entry( &self, target_id: &str, entry_id: i64, ) -> Result<(), BridgeError>

Page.navigateToHistoryEntry — 跳转历史条目。 Read more
Source§

fn page_set_content( &self, target_id: &str, html: &str, ) -> Result<(), BridgeError>

Page.setContent — 设置 HTML 内容。 Read more
Source§

fn page_close(&self, target_id: &str) -> Result<(), BridgeError>

Page.close — 关闭页面。 Read more
Source§

fn page_bring_to_front(&self, target_id: &str) -> Result<(), BridgeError>

Page.bringToFront — 把页面带到前台(No-op for headless)。 Read more
Source§

fn page_layout_metrics( &self, target_id: &str, ) -> Result<LayoutMetrics, BridgeError>

Page.getLayoutMetrics — 返回布局度量。 Read more
Source§

fn page_print_to_pdf(&self, target_id: &str) -> Result<Vec<u8>, BridgeError>

Page.printToPDF — 打印为 PDF(返回 PDF bytes;servo 无 PDF 渲染,实现可返回空)。 Read more
Source§

fn runtime_evaluate( &self, target_id: &str, expression: &str, ) -> Result<EvaluateResult, BridgeError>

Runtime.evaluate — 执行 JS 表达式。 Read more
Source§

fn runtime_call_function_on( &self, target_id: &str, object_id: &str, function_declaration: &str, args: &[Value], ) -> Result<EvaluateResult, BridgeError>

Runtime.callFunctionOn — 在指定对象上调用函数。 Read more
Source§

fn runtime_get_properties( &self, target_id: &str, object_id: &str, own_properties: bool, ) -> Result<Vec<PropertyDescriptor>, BridgeError>

Runtime.getProperties — 返回 RemoteObject 的属性。 Read more
Source§

fn runtime_release_object( &self, target_id: &str, object_id: &str, ) -> Result<(), BridgeError>

Runtime.releaseObject — 释放 RemoteObject。 Read more
Source§

fn runtime_enable(&self, target_id: &str) -> Result<(), BridgeError>

Runtime.enable — 启用 Runtime 域(状态切换,no-op for backend)。 Read more
Source§

fn runtime_disable(&self, target_id: &str) -> Result<(), BridgeError>

Runtime.disable — 禁用 Runtime 域。 Read more
Source§

fn dom_get_document( &self, target_id: &str, depth: i64, ) -> Result<NodeDescriptor, BridgeError>

DOM.getDocument — 返回 root document 节点。 Read more
Source§

fn dom_query_selector( &self, target_id: &str, node_id: i64, selector: &str, ) -> Result<Option<i64>, BridgeError>

DOM.querySelector — CSS selector 查询第一个匹配节点。 Read more
Source§

fn dom_query_selector_all( &self, target_id: &str, node_id: i64, selector: &str, ) -> Result<Vec<i64>, BridgeError>

DOM.querySelectorAll — CSS selector 查询所有匹配节点。 Read more
Source§

fn dom_get_box_model( &self, target_id: &str, node_id: i64, ) -> Result<BoxModel, BridgeError>

DOM.getBoxModel — 返回节点 box model。 Read more
Source§

fn dom_resolve_node( &self, target_id: &str, backend_node_id: i64, ) -> Result<RemoteObject, BridgeError>

DOM.resolveNode — 解析节点为 RemoteObject。 Read more
Source§

fn dom_describe_node( &self, target_id: &str, node_id: i64, depth: i64, ) -> Result<NodeDescriptor, BridgeError>

DOM.describeNode — 描述节点结构。 Read more
Source§

fn dom_set_attribute( &self, target_id: &str, node_id: i64, name: &str, value: &str, ) -> Result<(), BridgeError>

DOM.setAttributeValue — 设置属性。 Read more
Source§

fn dom_remove_attribute( &self, target_id: &str, node_id: i64, name: &str, ) -> Result<(), BridgeError>

DOM.removeAttribute — 移除属性。 Read more
Source§

fn dom_get_outer_html( &self, target_id: &str, node_id: i64, ) -> Result<String, BridgeError>

DOM.getOuterHTML — 返回 outerHTML 字符串。 Read more
Source§

fn dom_set_outer_html( &self, target_id: &str, node_id: i64, html: &str, ) -> Result<(), BridgeError>

DOM.setOuterHTML — 替换 outerHTML。 Read more
Source§

fn dom_request_node( &self, target_id: &str, object_id: &str, ) -> Result<i64, BridgeError>

DOM.requestNode — 请求节点(展开/确保可用)。 Read more
Source§

fn network_enable(&self, target_id: &str) -> Result<(), BridgeError>

Network.enable — 启用 Network 域。 Read more
Source§

fn network_disable(&self, target_id: &str) -> Result<(), BridgeError>

Network.disable — 禁用 Network 域。 Read more
Source§

fn network_get_response_body( &self, target_id: &str, request_id: &str, ) -> Result<ResponseBody, BridgeError>

Network.getResponseBody — 获取请求体。 Read more
Source§

fn network_set_cache_disabled( &self, target_id: &str, disabled: bool, ) -> Result<(), BridgeError>

Network.setCacheDisabled — 禁用/启用缓存。 Read more
Source§

fn input_dispatch_mouse_event( &self, target_id: &str, event: MouseEvent, ) -> Result<(), BridgeError>

Input.dispatchMouseEvent — 派发鼠标事件。 Read more
Source§

fn input_dispatch_key_event( &self, target_id: &str, event: KeyEvent, ) -> Result<(), BridgeError>

Input.dispatchKeyEvent — 派发键盘事件。 Read more
Source§

fn input_dispatch_touch_event( &self, target_id: &str, event_type: &str, touch_points: &[TouchPoint], ) -> Result<(), BridgeError>

Input.dispatchTouchEvent — 派发触摸事件。 Read more
Source§

fn input_set_ignore_input_events( &self, target_id: &str, ignore: bool, ) -> Result<(), BridgeError>

Input.setIgnoreInputEvents — 启用/禁用输入忽略。 Read more
Source§

fn emulation_set_device_metrics( &self, target_id: &str, metrics: DeviceMetrics, ) -> Result<(), BridgeError>

Emulation.setDeviceMetricsOverride — 设置设备度量覆盖。 Read more
Source§

fn emulation_clear_device_metrics( &self, target_id: &str, ) -> Result<(), BridgeError>

Emulation.clearDeviceMetricsOverride — 清除设备度量覆盖。 Read more
Source§

fn emulation_set_user_agent_override( &self, target_id: &str, user_agent: &str, ) -> Result<(), BridgeError>

Emulation.setUserAgentOverride — 覆盖 User-Agent。 Read more
Source§

fn emulation_set_geolocation_override( &self, target_id: &str, latitude: f64, longitude: f64, accuracy: f64, ) -> Result<(), BridgeError>

Emulation.setGeolocationOverride — 覆盖地理位置。 Read more
Source§

fn target_get_targets(&self) -> Result<Vec<TargetInfo>, BridgeError>

Target.getTargets — 列出所有 target。 Read more
Source§

fn target_create_target(&self, url: &str) -> Result<String, BridgeError>

Target.createTarget — 创建新页面(target)。 Read more
Source§

fn target_close_target(&self, target_id: &str) -> Result<(), BridgeError>

Target.closeTarget — 关闭 target。 Read more
Source§

fn target_attach_to_target( &self, target_id: &str, ) -> Result<String, BridgeError>

Target.attachToTarget — 附加到 target。 Read more
Source§

fn target_detach_from_target(&self, session_id: &str) -> Result<(), BridgeError>

Target.detachFromTarget — 分离 target。 Read more
Source§

fn target_set_auto_attach( &self, target_id: &str, auto_attach: bool, wait_for_debugger_on_start: bool, ) -> Result<(), BridgeError>

Target.setAutoAttach — 自动附加。 Read more
Source§

fn css_get_computed_style_for_node( &self, target_id: &str, node_id: i64, ) -> Result<Vec<CSSComputedStyleProperty>, BridgeError>

CSS.getComputedStyleForNode — 返回计算样式。 Read more
Source§

fn css_get_matched_styles_for_node( &self, target_id: &str, node_id: i64, ) -> Result<MatchedStyles, BridgeError>

CSS.getMatchedStylesForNode — 返回匹配样式。 Read more
Source§

fn debugger_enable(&self, target_id: &str) -> Result<(), BridgeError>

Debugger.enable — 启用 Debugger 域(servo WantsLiveNotifications(true))。 Read more
Source§

fn debugger_disable(&self, target_id: &str) -> Result<(), BridgeError>

Debugger.disable — 禁用 Debugger 域。 Read more
Source§

fn debugger_set_breakpoint_by_url( &self, target_id: &str, url: &str, line: u32, column: u32, ) -> Result<BreakpointResult, BridgeError>

Debugger.setBreakpointByUrl / setBreakpoint — 设置断点。 Read more
Source§

fn debugger_remove_breakpoint( &self, target_id: &str, script_id: u32, line: u32, column: u32, ) -> Result<(), BridgeError>

Debugger.removeBreakpoint — 清除断点(servo ClearBreakpoint)。 Read more
Source§

fn debugger_pause(&self, target_id: &str) -> Result<(), BridgeError>

Debugger.pause — 请求 SM 暂停(servo Interrupt)。 Read more
Source§

fn debugger_resume( &self, target_id: &str, step_action: Option<DebugStepAction>, ) -> Result<(), BridgeError>

Debugger.resume / stepOver / stepInto / stepOut — 恢复执行(可选单步)。 Read more
Source§

fn debugger_evaluate_on_call_frame( &self, target_id: &str, call_frame_id: &str, expression: &str, ) -> Result<DebuggerEvalResult, BridgeError>

Debugger.evaluateOnCallFrame — 在调用栈帧求值表达式。 Read more
Source§

fn debugger_get_possible_breakpoints( &self, target_id: &str, script_id: u32, ) -> Result<Vec<PossibleBreakpoint>, BridgeError>

Debugger.getPossibleBreakpoints — 列出可设置断点的位置。 Read more
Source§

fn debugger_get_script_source( &self, target_id: &str, script_id: u32, ) -> Result<String, BridgeError>

Debugger.getScriptSource — 返回 script 源码。 Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsCtxPtr for T
where T: ?Sized,

Source§

fn as_ctx_ptr(&self) -> *mut Self
where Self: Sized,

self’s address as *mut Self for deferred-task / scopeguard / ref_guard ctx slots. The closures/trampolines deref it as shared (&*p) — every method they reach is &self post-R-2, so no write provenance is required; the *mut spelling is purely to match the existing DerefOnDrop / HasAutoFlush / RefCount ABI.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Send for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> Sync for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more