mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-11 16:42:32 -05:00
feat: add V8InspectorSession::can_dispatch_method (#746)
This commit is contained in:
parent
24bef1e54b
commit
c525555e42
3 changed files with 57 additions and 0 deletions
|
@ -2122,6 +2122,11 @@ void v8_inspector__V8Inspector__contextCreated(
|
||||||
ptr_to_local(&context), contextGroupId, humanReadableName));
|
ptr_to_local(&context), contextGroupId, humanReadableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool v8_inspector__V8InspectorSession__canDispatchMethod(
|
||||||
|
v8_inspector::StringView method) {
|
||||||
|
return v8_inspector::V8InspectorSession::canDispatchMethod(method);
|
||||||
|
}
|
||||||
|
|
||||||
void v8_inspector__V8InspectorSession__DELETE(
|
void v8_inspector__V8InspectorSession__DELETE(
|
||||||
v8_inspector::V8InspectorSession* self) {
|
v8_inspector::V8InspectorSession* self) {
|
||||||
delete self;
|
delete self;
|
||||||
|
|
|
@ -82,6 +82,9 @@ extern "C" {
|
||||||
break_reason: StringView,
|
break_reason: StringView,
|
||||||
break_details: StringView,
|
break_details: StringView,
|
||||||
);
|
);
|
||||||
|
fn v8_inspector__V8InspectorSession__canDispatchMethod(
|
||||||
|
method: StringView,
|
||||||
|
) -> bool;
|
||||||
|
|
||||||
fn v8_inspector__StringBuffer__DELETE(this: &mut StringBuffer);
|
fn v8_inspector__StringBuffer__DELETE(this: &mut StringBuffer);
|
||||||
fn v8_inspector__StringBuffer__string(this: &StringBuffer) -> StringView;
|
fn v8_inspector__StringBuffer__string(this: &StringBuffer) -> StringView;
|
||||||
|
@ -598,6 +601,10 @@ impl Debug for V8InspectorClientBase {
|
||||||
pub struct V8InspectorSession(Opaque);
|
pub struct V8InspectorSession(Opaque);
|
||||||
|
|
||||||
impl V8InspectorSession {
|
impl V8InspectorSession {
|
||||||
|
pub fn can_dispatch_method(method: StringView) -> bool {
|
||||||
|
unsafe { v8_inspector__V8InspectorSession__canDispatchMethod(method) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn dispatch_protocol_message(&mut self, message: StringView) {
|
pub fn dispatch_protocol_message(&mut self, message: StringView) {
|
||||||
unsafe {
|
unsafe {
|
||||||
v8_inspector__V8InspectorSession__dispatchProtocolMessage(self, message)
|
v8_inspector__V8InspectorSession__dispatchProtocolMessage(self, message)
|
||||||
|
|
|
@ -3584,6 +3584,51 @@ impl v8::inspector::ChannelImpl for ChannelCounter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inspector_can_dispatch_method() {
|
||||||
|
use v8::inspector::*;
|
||||||
|
|
||||||
|
let message = String::from("Runtime.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("Debugger.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("Profiler.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("HeapProfiler.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("Console.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("Schema.getDomains");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("Foo.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(!V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
|
||||||
|
let message = String::from("Bar.enable");
|
||||||
|
let message = &message.into_bytes()[..];
|
||||||
|
let string_view = StringView::from(message);
|
||||||
|
assert!(!V8InspectorSession::can_dispatch_method(string_view));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inspector_dispatch_protocol_message() {
|
fn inspector_dispatch_protocol_message() {
|
||||||
let _setup_guard = setup();
|
let _setup_guard = setup();
|
||||||
|
|
Loading…
Reference in a new issue