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: StringPage.navigate 默认返回的 frame_id。
known_targets: Mutex<Vec<String>>已存在的 target_id 集合 — page_* 命令查不到时返回 PageNotFound。
Implementations§
Source§impl MockServoBackend
impl MockServoBackend
Sourcepub fn new() -> MockServoBackend
pub fn new() -> MockServoBackend
构造默认 mock。
Sourcepub fn into_backend(self) -> Arc<dyn ServoBackend> ⓘ
pub fn into_backend(self) -> Arc<dyn ServoBackend> ⓘ
包装为 Arc<dyn ServoBackend>。
Sourcepub fn add_target(&self, target_id: impl Into<String>)
pub fn add_target(&self, target_id: impl Into<String>)
添加已知 target。
Trait Implementations§
Source§impl Default for MockServoBackend
impl Default for MockServoBackend
Source§fn default() -> MockServoBackend
fn default() -> MockServoBackend
Returns the “default value” for a type. Read more
Source§impl ServoBackend for MockServoBackend
impl ServoBackend for MockServoBackend
Page.navigate — 加载 URL。 Read more
Source§fn page_reload(&self, target_id: &str) -> Result<(), BridgeError>
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>
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>
fn page_frame_tree(&self, target_id: &str) -> Result<FrameTree, BridgeError>
Page.getFrameTree — 返回 frame 树。 Read more
Page.getNavigationHistory — 返回导航历史。 Read more
Page.navigateToHistoryEntry — 跳转历史条目。 Read more
Source§fn page_set_content(
&self,
target_id: &str,
html: &str,
) -> Result<(), BridgeError>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
fn network_enable(&self, target_id: &str) -> Result<(), BridgeError>
Network.enable — 启用 Network 域。 Read more
Source§fn network_disable(&self, target_id: &str) -> Result<(), BridgeError>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
fn debugger_enable(&self, target_id: &str) -> Result<(), BridgeError>
Debugger.enable — 启用 Debugger 域(servo
WantsLiveNotifications(true))。 Read moreSource§fn debugger_disable(&self, target_id: &str) -> Result<(), BridgeError>
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>
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>
fn debugger_remove_breakpoint( &self, target_id: &str, script_id: u32, line: u32, column: u32, ) -> Result<(), BridgeError>
Debugger.removeBreakpoint — 清除断点(servo
ClearBreakpoint)。 Read moreSource§fn debugger_pause(&self, target_id: &str) -> Result<(), BridgeError>
fn debugger_pause(&self, target_id: &str) -> Result<(), BridgeError>
Debugger.pause — 请求 SM 暂停(servo
Interrupt)。 Read moreSource§fn debugger_resume(
&self,
target_id: &str,
step_action: Option<DebugStepAction>,
) -> Result<(), BridgeError>
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>
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>
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>
fn debugger_get_script_source( &self, target_id: &str, script_id: u32, ) -> Result<String, BridgeError>
Debugger.getScriptSource — 返回 script 源码。 Read more
Auto Trait Implementations§
impl !Freeze for MockServoBackend
impl RefUnwindSafe for MockServoBackend
impl Send for MockServoBackend
impl Sync for MockServoBackend
impl Unpin for MockServoBackend
impl UnsafeUnpin for MockServoBackend
impl UnwindSafe for MockServoBackend
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert