From d28efe8797a0c4e4301081ad97226583e6090b56 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 15 Oct 2019 15:06:09 +0200 Subject: [PATCH] Add warning to LoadRequest about INVALID_INITIATOR_ORIGIN (213) failure condition (see issue #2586) --- include/capi/cef_frame_capi.h | 6 +++++- include/cef_frame.h | 4 ++++ tests/cefclient/browser/test_runner.cc | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/capi/cef_frame_capi.h b/include/capi/cef_frame_capi.h index 0fdaa3ac9..1bc01eb19 100644 --- a/include/capi/cef_frame_capi.h +++ b/include/capi/cef_frame_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=6bef924a259845dbf03e9cf5084ff7feb2771034$ +// $hash=5f3cb132c1116a36c746c246ebeded195c917718$ // #ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_ @@ -131,6 +131,10 @@ typedef struct _cef_frame_t { /// // Load the request represented by the |request| object. + // + // WARNING: This function will fail with "bad IPC message" reason + // INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the request + // origin using some other mechanism (LoadURL, link click, etc). /// void(CEF_CALLBACK* load_request)(struct _cef_frame_t* self, struct _cef_request_t* request); diff --git a/include/cef_frame.h b/include/cef_frame.h index 6d1ac6bc7..5a94d46d8 100644 --- a/include/cef_frame.h +++ b/include/cef_frame.h @@ -131,6 +131,10 @@ class CefFrame : public virtual CefBaseRefCounted { /// // Load the request represented by the |request| object. + // + // WARNING: This method will fail with "bad IPC message" reason + // INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the + // request origin using some other mechanism (LoadURL, link click, etc). /// /*--cef()--*/ virtual void LoadRequest(CefRefPtr request) = 0; diff --git a/tests/cefclient/browser/test_runner.cc b/tests/cefclient/browser/test_runner.cc index cfa64ee00..e6574a592 100644 --- a/tests/cefclient/browser/test_runner.cc +++ b/tests/cefclient/browser/test_runner.cc @@ -100,6 +100,16 @@ void RunRequestTest(CefRefPtr browser) { // Create a new request CefRefPtr request(CefRequest::Create()); + if (browser->GetMainFrame()->GetURL().ToString().find("http://tests/") != 0) { + // The LoadRequest method will fail with "bad IPC message" reason + // INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the + // request origin using some other mechanism (LoadURL, link click, etc). + Alert(browser, + "Please first navigate to a http://tests/ URL. " + "For example, first load Tests > Other Tests."); + return; + } + // Set the request URL request->SetURL("http://tests/request");