Skip to content

Commit

Permalink
Add v8::V8Inspector::context_destroyed API (#1125)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Nov 22, 2022
1 parent d992c50 commit dd5fa70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,11 @@ void v8_inspector__V8Inspector__contextCreated(
ptr_to_local(&context), contextGroupId, humanReadableName));
}

void v8_inspector__V8Inspector__contextDestroyed(
v8_inspector::V8Inspector* self, const v8::Context& context) {
self->contextDestroyed(ptr_to_local(&context));
}

bool v8_inspector__V8InspectorSession__canDispatchMethod(
v8_inspector::StringView method) {
return v8_inspector::V8InspectorSession::canDispatchMethod(method);
Expand Down
8 changes: 8 additions & 0 deletions src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ extern "C" {
contextGroupId: int,
humanReadableName: StringView,
);
fn v8_inspector__V8Inspector__contextDestroyed(
this: *mut V8Inspector,
context: *const Context,
);
}

#[no_mangle]
Expand Down Expand Up @@ -947,6 +951,10 @@ impl V8Inspector {
)
}
}

pub fn context_destroyed(&mut self, context: Local<Context>) {
unsafe { v8_inspector__V8Inspector__contextDestroyed(self, &*context) }
}
}

impl Drop for V8Inspector {
Expand Down
1 change: 1 addition & 0 deletions tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5143,6 +5143,7 @@ fn inspector_dispatch_protocol_message() {
assert_eq!(channel.count_send_response, 1);
assert_eq!(channel.count_send_notification, 0);
assert_eq!(channel.count_flush_protocol_notifications, 0);
inspector.context_destroyed(context);
}

#[test]
Expand Down

0 comments on commit dd5fa70

Please sign in to comment.