0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2025-01-11 08:34:01 -05:00

feat: add V8InspectorSession::can_dispatch_method (#746)

This commit is contained in:
Bartek Iwańczuk 2021-08-09 15:53:30 +02:00 committed by GitHub
parent 24bef1e54b
commit c525555e42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 0 deletions

View file

@ -2122,6 +2122,11 @@ void v8_inspector__V8Inspector__contextCreated(
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(
v8_inspector::V8InspectorSession* self) {
delete self;

View file

@ -82,6 +82,9 @@ extern "C" {
break_reason: StringView,
break_details: StringView,
);
fn v8_inspector__V8InspectorSession__canDispatchMethod(
method: StringView,
) -> bool;
fn v8_inspector__StringBuffer__DELETE(this: &mut StringBuffer);
fn v8_inspector__StringBuffer__string(this: &StringBuffer) -> StringView;
@ -598,6 +601,10 @@ impl Debug for V8InspectorClientBase {
pub struct V8InspectorSession(Opaque);
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) {
unsafe {
v8_inspector__V8InspectorSession__dispatchProtocolMessage(self, message)

View file

@ -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]
fn inspector_dispatch_protocol_message() {
let _setup_guard = setup();