Fix V8Test.OnUncaughtExceptionDevTools failure (see #3867)

Ignore multiple calls to OnContextCreated when the DevTools window
is open.

Simplify the related implementation in MessageListenerCallbackImpl
(should be a behavioral no-op).
This commit is contained in:
Marshall Greenblatt 2025-01-07 17:06:32 -05:00
parent dd81904a2f
commit 7588c9dcbf
2 changed files with 18 additions and 4 deletions

View File

@ -797,17 +797,26 @@ void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
}
v8::Isolate* isolate = CefV8IsolateManager::Get()->isolate();
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> v8Context = isolate->GetCurrentContext();
if (v8Context.IsEmpty()) {
return;
}
CefRefPtr<CefV8ContextImpl> context =
new CefV8ContextImpl(isolate, v8Context);
v8::Local<v8::StackTrace> v8Stack = message->GetStackTrace();
CefRefPtr<CefV8StackTrace> stackTrace =
new CefV8StackTraceImpl(isolate, v8Stack);
CefRefPtr<CefV8Exception> exception = new CefV8ExceptionImpl(
static_cast<CefV8ContextImpl*>(context.get())->GetV8Context(), message);
CefRefPtr<CefV8Exception> exception =
new CefV8ExceptionImpl(v8Context, message);
CefRefPtr<CefBrowser> browser = context->GetBrowser();
if (browser) {
handler->OnUncaughtException(browser, context->GetFrame(), context,
handler->OnUncaughtException(browser, context->GetFrame(), context.get(),
exception, stackTrace);
}
}

View File

@ -2931,6 +2931,11 @@ class V8RendererTest : public ClientAppRenderer::Delegate,
return;
}
if (!frame->GetV8Context()->IsSame(context)) {
// Only interested in the MainWorld context.
return;
}
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
if (!browser->IsPopup()) {
app_ = app;