Add callbacks for unresponsive render process (fixes #3661)

The client can optionally wait or terminate the render process.

Expose process exit codes via OnRenderProcessTerminated and
CefGetExitCode (fixes #2126).

cefclient: Add a new https://tests/hang page for testing hang behavior.

cefclient: Move message and resource handling to a new BaseClientHandler
class to support loading of test pages in default Chrome UI windows.
This commit is contained in:
Marshall Greenblatt
2024-03-12 15:47:10 -04:00
parent 5e616b2df0
commit b8f91c5431
73 changed files with 1957 additions and 368 deletions

View File

@@ -8,6 +8,7 @@
#include <map>
#include <set>
#include <sstream>
#include <string>
#include "include/base/cef_callback.h"
#include "include/cef_parser.h"
@@ -16,10 +17,11 @@
#include "include/views/cef_browser_view.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_stream_resource_handler.h"
#include "tests/cefclient/browser/base_client_handler.h"
#include "tests/cefclient/browser/binary_transfer_test.h"
#include "tests/cefclient/browser/binding_test.h"
#include "tests/cefclient/browser/client_handler.h"
#include "tests/cefclient/browser/dialog_test.h"
#include "tests/cefclient/browser/hang_test.h"
#include "tests/cefclient/browser/main_context.h"
#include "tests/cefclient/browser/media_router_test.h"
#include "tests/cefclient/browser/preferences_test.h"
@@ -50,9 +52,7 @@ const char kTestGetTextPage[] = "get_text.html";
void LoadStringResourcePage(CefRefPtr<CefBrowser> browser,
const std::string& page,
const std::string& data) {
CefRefPtr<CefClient> client = browser->GetHost()->GetClient();
ClientHandler* client_handler = static_cast<ClientHandler*>(client.get());
client_handler->SetStringResource(page, data);
BaseClientHandler::GetForBrowser(browser)->SetStringResource(page, data);
browser->GetMainFrame()->LoadURL(kTestOrigin + page);
}
@@ -752,10 +752,29 @@ std::string GetErrorString(cef_errorcode_t code) {
CASE(ERR_CACHE_MISS);
CASE(ERR_INSECURE_RESPONSE);
default:
return "UNKNOWN";
return std::to_string(static_cast<int>(code));
}
}
std::string GetErrorString(cef_termination_status_t status) {
switch (status) {
case TS_ABNORMAL_TERMINATION:
return "ABNORMAL_TERMINATION";
case TS_PROCESS_WAS_KILLED:
return "PROCESS_WAS_KILLED";
case TS_PROCESS_CRASHED:
return "PROCESS_CRASHED";
case TS_PROCESS_OOM:
return "PROCESS_OOM";
case TS_LAUNCH_FAILED:
return "LAUNCH_FAILED";
case TS_INTEGRITY_FAILURE:
return "INTEGRITY_FAILURE";
}
NOTREACHED();
return std::string();
}
void SetupResourceManager(CefRefPtr<CefResourceManager> resource_manager,
StringResourceMap* string_resource_map) {
if (!CefCurrentlyOn(TID_IO)) {
@@ -851,6 +870,9 @@ void CreateMessageHandlers(MessageHandlerSet& handlers) {
// Create the dialog test handlers.
dialog_test::CreateMessageHandlers(handlers);
// Create the hang test handlers.
hang_test::CreateMessageHandlers(handlers);
// Create the media router test handlers.
media_router_test::CreateMessageHandlers(handlers);