Enable strict site isolation by default (see issue #2498)
This restores the default site isolation mode for Chromium on desktop platforms. Unit tests have been updated to reflect the new behavior expectations. Known behavior changes in CEF are as follows: - A spare renderer process may be created on initial browser creation or cross- origin navigation. This spare process may be used with a future cross-origin navigation or discarded on application shutdown. As a result CefRenderProcessHandler::OnRenderThreadCreated, which is called shortly after renderer process creation, can no longer be used to reliably transfer state for the currently in-progress navigation. Unit tests have been updated to use the CreateBrowser/OnBeforePopup |extra_info| value for transferring test state to CefRenderProcessHandler::OnBrowserCreated which will be called in the correct/expected renderer process. - Cross-origin navigations will again receive a new renderer process, as expected. This behavior had briefly regressed in M78 due to the ProcessSharingWithDefaultSiteInstances feature becoming enabled by default. - Cross-origin navigations initiated by calling LoadURL in the renderer process will now crash that process with "bad IPC message" reason INVALID_INITIATOR_ORIGIN (213). This is a security feature implemented in Chromium. - A DevTools browser created using CefBrowserHost::ShowDevTools will receive the same CefRenderProcessHandler::OnBrowserCreated |extra_info| value that was set via CreateBrowser/OnBeforePopup for the parent browser.
This commit is contained in:
parent
5da1649653
commit
eea1f6be63
|
@ -852,17 +852,6 @@ void CefContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
|
|||
#endif
|
||||
}
|
||||
|
||||
bool CefContentBrowserClient::ShouldEnableStrictSiteIsolation() {
|
||||
// TODO(cef): Enable this mode once we figure out why it breaks ceftests that
|
||||
// rely on command-line arguments passed to the renderer process. It looks
|
||||
// like the first renderer process is getting all of the callbacks despite
|
||||
// multiple renderer processes being launched.
|
||||
// For example, V8RendererTest::OnBrowserCreated appears to get the same
|
||||
// kV8TestCmdArg value twice when running with:
|
||||
// --gtest_filter=V8Test.ContextEvalCspBypassUnsafeEval:V8Test.ContextEntered
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CefContentBrowserClient::GetApplicationLocale() {
|
||||
return g_browser_process->GetApplicationLocale();
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
|||
void AdjustUtilityServiceProcessCommandLine(
|
||||
const service_manager::Identity& identity,
|
||||
base::CommandLine* command_line) override;
|
||||
bool ShouldEnableStrictSiteIsolation() override;
|
||||
std::string GetApplicationLocale() override;
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
GetSystemSharedURLLoaderFactory() override;
|
||||
|
|
|
@ -163,6 +163,7 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
|||
create_params.settings = new_settings;
|
||||
create_params.devtools_opener = inspected_browser;
|
||||
create_params.request_context = inspected_browser->GetRequestContext();
|
||||
create_params.extra_info = inspected_browser->browser_info()->extra_info();
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser =
|
||||
CefBrowserHostImpl::Create(create_params);
|
||||
|
|
|
@ -9,11 +9,6 @@ using client::ClientAppBrowser;
|
|||
using client::ClientAppRenderer;
|
||||
|
||||
void CreateBrowserDelegates(ClientAppBrowser::DelegateSet& delegates) {
|
||||
// Bring in the Frame tests.
|
||||
extern void CreateFrameBrowserTests(ClientAppBrowser::DelegateSet &
|
||||
delegates);
|
||||
CreateFrameBrowserTests(delegates);
|
||||
|
||||
// Bring in the Navigation tests.
|
||||
extern void CreateNavigationBrowserTests(ClientAppBrowser::DelegateSet &
|
||||
delegates);
|
||||
|
@ -28,15 +23,6 @@ void CreateBrowserDelegates(ClientAppBrowser::DelegateSet& delegates) {
|
|||
extern void CreatePreferenceBrowserTests(ClientAppBrowser::DelegateSet &
|
||||
delegates);
|
||||
CreatePreferenceBrowserTests(delegates);
|
||||
|
||||
// Bring in the RequestHandler tests.
|
||||
extern void CreateRequestHandlerBrowserTests(ClientAppBrowser::DelegateSet &
|
||||
delegates);
|
||||
CreateRequestHandlerBrowserTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8BrowserTests(ClientAppBrowser::DelegateSet & delegates);
|
||||
CreateV8BrowserTests(delegates);
|
||||
}
|
||||
|
||||
void CreateRenderDelegates(ClientAppRenderer::DelegateSet& delegates) {
|
||||
|
|
|
@ -85,13 +85,12 @@ enum FrameNavFactoryId {
|
|||
FNF_ID_NESTED_IFRAMES_DIFF_ORIGIN,
|
||||
};
|
||||
|
||||
// Command-line argument names.
|
||||
const char kTestArg[] = "test";
|
||||
const char kTestFactoryIdArg[] = "testfid";
|
||||
|
||||
// IPC message name.
|
||||
const char kFrameNavMsg[] = "FrameTest.Navigation";
|
||||
|
||||
// Extra info parameter keys.
|
||||
const char kFrameNavTestCmdKey[] = "frame-nav-test";
|
||||
|
||||
// Origins used in tests.
|
||||
const char kFrameNavOrigin0[] = "http://tests-framenav0.com/";
|
||||
const char kFrameNavOrigin1[] = "http://tests-framenav1.com/";
|
||||
|
@ -103,10 +102,6 @@ const char kFrameNavOrigin3[] = "http://tests-framenav3.com/";
|
|||
// below use cases.
|
||||
const int kMaxMultiNavNavigations = 4;
|
||||
|
||||
// Global variables identifying the currently running test.
|
||||
bool g_frame_nav_test = false;
|
||||
FrameNavFactoryId g_frame_nav_factory_id = FNF_ID_INVALID;
|
||||
|
||||
// Abstract base class representing expectations that result from a navigation.
|
||||
class FrameNavExpectations {
|
||||
public:
|
||||
|
@ -274,63 +269,24 @@ class FrameNavExpectationsFactoryRenderer : public FrameNavExpectationsFactory {
|
|||
virtual scoped_ptr<FrameNavExpectationsRenderer> Create(int nav) = 0;
|
||||
};
|
||||
|
||||
// Browser side app delegate.
|
||||
class FrameNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
FrameNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_frame_nav_test)
|
||||
return;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << g_frame_nav_factory_id;
|
||||
|
||||
// Indicate to the render process that the test should be run.
|
||||
command_line->AppendSwitchWithValue(kTestArg, kFrameNavMsg);
|
||||
command_line->AppendSwitchWithValue(kTestFactoryIdArg, ss.str());
|
||||
}
|
||||
|
||||
protected:
|
||||
IMPLEMENT_REFCOUNTING(FrameNavBrowserTest);
|
||||
};
|
||||
|
||||
// Renderer side handler.
|
||||
class FrameNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
FrameNavRendererTest() : run_test_(false), nav_(0) {}
|
||||
|
||||
void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
// The g_* values will be set when running in single-process mode.
|
||||
if (!g_frame_nav_test) {
|
||||
// Check that the test should be run.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& test = command_line->GetSwitchValue(kTestArg);
|
||||
if (test != kFrameNavMsg)
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
if (!extra_info->HasKey(kFrameNavTestCmdKey))
|
||||
return;
|
||||
}
|
||||
|
||||
FrameNavFactoryId factory_id = g_frame_nav_factory_id;
|
||||
if (factory_id == FNF_ID_INVALID) {
|
||||
// Retrieve the factory ID from the command-line.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
if (command_line->HasSwitch(kTestFactoryIdArg)) {
|
||||
factory_id = static_cast<FrameNavFactoryId>(
|
||||
atoi(command_line->GetSwitchValue(kTestFactoryIdArg)
|
||||
.ToString()
|
||||
.c_str()));
|
||||
if (factory_id == FNF_ID_INVALID)
|
||||
FrameNavFactoryId factory_id =
|
||||
static_cast<FrameNavFactoryId>(extra_info->GetInt(kFrameNavTestCmdKey));
|
||||
run_test_ = factory_id != FNF_ID_INVALID;
|
||||
if (!run_test_)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
run_test_ = true;
|
||||
factory_ = FrameNavExpectationsFactoryRenderer::FromID(factory_id);
|
||||
}
|
||||
|
||||
|
@ -416,26 +372,20 @@ class FrameNavTestHandler : public TestHandler {
|
|||
public:
|
||||
explicit FrameNavTestHandler(FrameNavFactoryId factory_id)
|
||||
: nav_(0),
|
||||
factory_(FrameNavExpectationsFactoryBrowser::FromID(factory_id)) {
|
||||
EXPECT_FALSE(g_frame_nav_test);
|
||||
EXPECT_EQ(FNF_ID_INVALID, g_frame_nav_factory_id);
|
||||
g_frame_nav_test = true;
|
||||
g_frame_nav_factory_id = factory_id;
|
||||
}
|
||||
factory_(FrameNavExpectationsFactoryBrowser::FromID(factory_id)) {}
|
||||
|
||||
~FrameNavTestHandler() override {
|
||||
EXPECT_TRUE(got_destroyed_);
|
||||
g_frame_nav_test = false;
|
||||
g_frame_nav_factory_id = FNF_ID_INVALID;
|
||||
}
|
||||
~FrameNavTestHandler() override { EXPECT_TRUE(got_destroyed_); }
|
||||
|
||||
void RunTest() override {
|
||||
// Create the first expectations object.
|
||||
expectations_ = factory_->Create(
|
||||
nav_, base::Bind(&FrameNavTestHandler::RunNextNav, this));
|
||||
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
extra_info->SetInt(kFrameNavTestCmdKey, factory_->GetID());
|
||||
|
||||
// Create the browser with the initial URL.
|
||||
CreateBrowser(expectations_->GetMainURL());
|
||||
CreateBrowser(expectations_->GetMainURL(), NULL, extra_info);
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
SetTestTimeout(15000);
|
||||
|
@ -2351,12 +2301,6 @@ FrameNavExpectationsFactoryRenderer::FromID(FrameNavFactoryId id) {
|
|||
|
||||
} // namespace
|
||||
|
||||
// Entry point for creating frame browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateFrameBrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new FrameNavBrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating frame renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateFrameRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
|
|
|
@ -20,10 +20,11 @@ using client::ClientAppRenderer;
|
|||
|
||||
namespace {
|
||||
|
||||
const char kHNav1[] = "http://tests-hnav/nav1.html";
|
||||
const char kHNav2[] = "http://tests-hnav/nav2.html";
|
||||
const char kHNav3[] = "http://tests-hnav/nav3.html";
|
||||
const char kHNav1[] = "http://tests-hnav.com/nav1.html";
|
||||
const char kHNav2[] = "http://tests-hnav.com/nav2.html";
|
||||
const char kHNav3[] = "http://tests-hnav.com/nav3.html";
|
||||
const char kHistoryNavMsg[] = "NavigationTest.HistoryNav";
|
||||
const char kHistoryNavTestCmdKey[] = "nav-history-test";
|
||||
|
||||
enum NavAction { NA_LOAD = 1, NA_BACK, NA_FORWARD, NA_CLEAR };
|
||||
|
||||
|
@ -49,45 +50,16 @@ static NavListItem kHNavList[] = {
|
|||
|
||||
#define NAV_LIST_SIZE() (sizeof(kHNavList) / sizeof(NavListItem))
|
||||
|
||||
bool g_history_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class HistoryNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
HistoryNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_history_nav_test)
|
||||
return;
|
||||
|
||||
// Indicate to the render process that the test should be run.
|
||||
command_line->AppendSwitchWithValue("test", kHistoryNavMsg);
|
||||
}
|
||||
|
||||
protected:
|
||||
IMPLEMENT_REFCOUNTING(HistoryNavBrowserTest);
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class HistoryNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
HistoryNavRendererTest() : run_test_(false), nav_(0) {}
|
||||
|
||||
void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_history_nav_test) {
|
||||
// Check that the test should be run.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& test = command_line->GetSwitchValue("test");
|
||||
if (test != kHistoryNavMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
run_test_ = true;
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
run_test_ = extra_info->HasKey(kHistoryNavTestCmdKey);
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
|
@ -311,8 +283,11 @@ class HistoryNavTestHandler : public TestHandler {
|
|||
"<html><head><title>Nav3</title><body>Nav3</body></html>",
|
||||
"text/html");
|
||||
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
extra_info->SetBool(kHistoryNavTestCmdKey, true);
|
||||
|
||||
// Create the browser.
|
||||
CreateBrowser(CefString());
|
||||
CreateBrowser(CefString(), NULL, extra_info);
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
SetTestTimeout();
|
||||
|
@ -537,10 +512,8 @@ class HistoryNavTestHandler : public TestHandler {
|
|||
|
||||
// Verify history navigation.
|
||||
TEST(NavigationTest, History) {
|
||||
g_history_nav_test = true;
|
||||
CefRefPtr<HistoryNavTestHandler> handler = new HistoryNavTestHandler();
|
||||
handler->ExecuteTest();
|
||||
g_history_nav_test = false;
|
||||
|
||||
for (size_t i = 0; i < NAV_LIST_SIZE(); ++i) {
|
||||
if (kHNavList[i].action != NA_CLEAR) {
|
||||
|
@ -571,8 +544,6 @@ namespace {
|
|||
const char kDynIfrNav1[] = "http://tests-dynframe/nav1.html";
|
||||
const char kDynIfrNav2[] = "http://tests-dynframe/nav2.html";
|
||||
|
||||
bool g_history_dynamic_iframes_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class HistoryDynamicIFramesNavTestHandler : public TestHandler {
|
||||
public:
|
||||
|
@ -689,11 +660,9 @@ class HistoryDynamicIFramesNavTestHandler : public TestHandler {
|
|||
// Verify history navigation of pages containing dynamically created iframes.
|
||||
// See issue #2022 for background.
|
||||
TEST(NavigationTest, HistoryDynamicIFrames) {
|
||||
g_history_dynamic_iframes_nav_test = true;
|
||||
CefRefPtr<HistoryDynamicIFramesNavTestHandler> handler =
|
||||
new HistoryDynamicIFramesNavTestHandler();
|
||||
handler->ExecuteTest();
|
||||
g_history_dynamic_iframes_nav_test = false;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
EXPECT_TRUE(handler->got_load_start_[i]);
|
||||
|
@ -1045,10 +1014,11 @@ TEST(NavigationTest, RedirectDestroy) {
|
|||
|
||||
namespace {
|
||||
|
||||
const char KONav1[] = "http://tests-onav/nav1.html";
|
||||
const char KONav2[] = "http://tests-onav/nav2.html";
|
||||
const char KONav1[] = "http://tests-onav.com/nav1.html";
|
||||
const char KONav2[] = "http://tests-onav.com/nav2.html";
|
||||
const char kOrderNavMsg[] = "NavigationTest.OrderNav";
|
||||
const char kOrderNavClosedMsg[] = "NavigationTest.OrderNavClosed";
|
||||
const char kOrderNavTestCmdKey[] = "nav-order-test";
|
||||
|
||||
void SetOrderNavExtraInfo(CefRefPtr<CefListValue> extra_info) {
|
||||
// Arbitrary data for testing.
|
||||
|
@ -1061,30 +1031,17 @@ void SetOrderNavExtraInfo(CefRefPtr<CefListValue> extra_info) {
|
|||
extra_info->SetString(3, "some string");
|
||||
}
|
||||
|
||||
bool g_order_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class OrderNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
OrderNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_order_nav_test)
|
||||
return;
|
||||
|
||||
// Indicate to the render process that the test should be run.
|
||||
command_line->AppendSwitchWithValue("test", kOrderNavMsg);
|
||||
}
|
||||
|
||||
void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_order_nav_test)
|
||||
return;
|
||||
|
||||
// Some data that we'll check for.
|
||||
// Some data that we'll check for. Note that this leaks into all renderer
|
||||
// process test cases, but that shouldn't be an issue since we only check
|
||||
// the result in this test case.
|
||||
SetOrderNavExtraInfo(extra_info);
|
||||
}
|
||||
|
||||
|
@ -1177,17 +1134,7 @@ class OrderNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
|
||||
void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_order_nav_test) {
|
||||
// Check that the test should be run.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& test = command_line->GetSwitchValue("test");
|
||||
if (test != kOrderNavMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
run_test_ = true;
|
||||
|
||||
EXPECT_FALSE(got_render_thread_created_);
|
||||
EXPECT_FALSE(got_webkit_initialized_);
|
||||
|
||||
got_render_thread_created_.yes();
|
||||
|
@ -1199,10 +1146,8 @@ class OrderNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
}
|
||||
|
||||
void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
EXPECT_TRUE(got_render_thread_created_);
|
||||
EXPECT_FALSE(got_webkit_initialized_);
|
||||
|
||||
got_webkit_initialized_.yes();
|
||||
}
|
||||
|
@ -1210,6 +1155,7 @@ class OrderNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
run_test_ = extra_info->HasKey(kOrderNavTestCmdKey);
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
|
@ -1413,13 +1359,21 @@ class OrderNavTestHandler : public TestHandler {
|
|||
state_popup_(true, true),
|
||||
got_message_(false) {}
|
||||
|
||||
// Returns state that will be checked in the renderer process via
|
||||
// OrderNavRendererTest::OnBrowserCreated.
|
||||
CefRefPtr<CefDictionaryValue> GetExtraInfo() {
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
extra_info->SetBool(kOrderNavTestCmdKey, true);
|
||||
return extra_info;
|
||||
}
|
||||
|
||||
void RunTest() override {
|
||||
// Add the resources that we will navigate to/from.
|
||||
AddResource(KONav1, "<html>Nav1</html>", "text/html");
|
||||
AddResource(KONav2, "<html>Nav2</html>", "text/html");
|
||||
|
||||
// Create the browser.
|
||||
CreateBrowser(KONav1);
|
||||
CreateBrowser(KONav1, NULL, GetExtraInfo());
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
SetTestTimeout();
|
||||
|
@ -1449,6 +1403,23 @@ class OrderNavTestHandler : public TestHandler {
|
|||
}
|
||||
}
|
||||
|
||||
bool OnBeforePopup(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
|
||||
bool user_gesture,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue>& extra_info,
|
||||
bool* no_javascript_access) override {
|
||||
extra_info = GetExtraInfo();
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override {
|
||||
TestHandler::OnAfterCreated(browser);
|
||||
|
||||
|
@ -1634,10 +1605,8 @@ class OrderNavTestHandler : public TestHandler {
|
|||
|
||||
// Verify the order of navigation-related callbacks.
|
||||
TEST(NavigationTest, Order) {
|
||||
g_order_nav_test = true;
|
||||
CefRefPtr<OrderNavTestHandler> handler = new OrderNavTestHandler();
|
||||
handler->ExecuteTest();
|
||||
g_order_nav_test = false;
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
|
@ -1647,27 +1616,7 @@ const char kLoadNav1[] = "http://tests-conav1.com/nav1.html";
|
|||
const char kLoadNavSameOrigin2[] = "http://tests-conav1.com/nav2.html";
|
||||
const char kLoadNavCrossOrigin2[] = "http://tests-conav2.com/nav2.html";
|
||||
const char kLoadNavMsg[] = "NavigationTest.LoadNav";
|
||||
|
||||
bool g_load_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class LoadNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
LoadNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_load_nav_test)
|
||||
return;
|
||||
|
||||
// Indicate to the render process that the test should be run.
|
||||
command_line->AppendSwitchWithValue("test", kLoadNavMsg);
|
||||
}
|
||||
|
||||
protected:
|
||||
IMPLEMENT_REFCOUNTING(LoadNavBrowserTest);
|
||||
};
|
||||
const char kLoadNavTestCmdKey[] = "nav-load-test";
|
||||
|
||||
// Renderer side.
|
||||
class LoadNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
|
@ -1676,42 +1625,13 @@ class LoadNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
LoadNavRendererTest() : run_test_(false), browser_id_(0), load_ct_(0) {}
|
||||
~LoadNavRendererTest() override { EXPECT_EQ(0, browser_id_); }
|
||||
|
||||
void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_load_nav_test) {
|
||||
// Check that the test should be run.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& test = command_line->GetSwitchValue("test");
|
||||
if (test != kLoadNavMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
run_test_ = true;
|
||||
|
||||
EXPECT_FALSE(got_webkit_initialized_);
|
||||
|
||||
got_render_thread_created_.yes();
|
||||
}
|
||||
|
||||
void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
EXPECT_TRUE(got_render_thread_created_);
|
||||
|
||||
got_webkit_initialized_.yes();
|
||||
}
|
||||
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
run_test_ = extra_info->HasKey(kLoadNavTestCmdKey);
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
EXPECT_TRUE(got_render_thread_created_);
|
||||
EXPECT_TRUE(got_webkit_initialized_);
|
||||
|
||||
EXPECT_EQ(0, browser_id_);
|
||||
browser_id_ = browser->GetIdentifier();
|
||||
EXPECT_GT(browser_id_, 0);
|
||||
|
@ -1723,9 +1643,6 @@ class LoadNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
if (!run_test_)
|
||||
return;
|
||||
|
||||
EXPECT_TRUE(got_render_thread_created_);
|
||||
EXPECT_TRUE(got_webkit_initialized_);
|
||||
|
||||
EXPECT_TRUE(got_browser_created_);
|
||||
EXPECT_TRUE(got_loading_state_end_);
|
||||
|
||||
|
@ -1746,9 +1663,6 @@ class LoadNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
bool canGoBack,
|
||||
bool canGoForward) override {
|
||||
if (!isLoading) {
|
||||
EXPECT_TRUE(got_render_thread_created_);
|
||||
EXPECT_TRUE(got_webkit_initialized_);
|
||||
|
||||
EXPECT_TRUE(got_browser_created_);
|
||||
|
||||
got_loading_state_end_.yes();
|
||||
|
@ -1780,9 +1694,6 @@ class LoadNavRendererTest : public ClientAppRenderer::Delegate,
|
|||
|
||||
bool run_test_;
|
||||
|
||||
TrackCallback got_render_thread_created_;
|
||||
TrackCallback got_webkit_initialized_;
|
||||
|
||||
int browser_id_;
|
||||
int load_ct_;
|
||||
TrackCallback got_browser_created_;
|
||||
|
@ -1808,11 +1719,7 @@ class LoadNavTestHandler : public TestHandler {
|
|||
same_origin_(same_origin),
|
||||
cancel_in_open_url_(cancel_in_open_url),
|
||||
browser_id_current_(0),
|
||||
renderer_load_ct_(0) {
|
||||
g_load_nav_test = true;
|
||||
}
|
||||
|
||||
~LoadNavTestHandler() override { g_load_nav_test = false; }
|
||||
renderer_load_ct_(0) {}
|
||||
|
||||
std::string GetURL2() const {
|
||||
return same_origin_ ? kLoadNavSameOrigin2 : kLoadNavCrossOrigin2;
|
||||
|
@ -1834,8 +1741,11 @@ class LoadNavTestHandler : public TestHandler {
|
|||
"text/html");
|
||||
AddResource(url2, "<html>Nav2</html>", "text/html");
|
||||
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
extra_info->SetBool(kLoadNavTestCmdKey, true);
|
||||
|
||||
// Create the browser.
|
||||
CreateBrowser(kLoadNav1);
|
||||
CreateBrowser(kLoadNav1, NULL, extra_info);
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
SetTestTimeout();
|
||||
|
@ -2062,19 +1972,11 @@ class LoadNavTestHandler : public TestHandler {
|
|||
if (same_origin_) {
|
||||
// The renderer process should always be reused.
|
||||
EXPECT_EQ(2, renderer_load_ct_);
|
||||
} else {
|
||||
if (mode_ != LOAD) {
|
||||
// For left click on link the renderer process will be reused.
|
||||
// For ctrl + left click or middle click on link the renderer process
|
||||
// will be reused when the ProcessSharingWithDefaultSiteInstances
|
||||
// feature is enabled (see https://crbug.com/958060).
|
||||
EXPECT_EQ(2, renderer_load_ct_);
|
||||
} else {
|
||||
// Each renderer process is only used for a single navigation.
|
||||
EXPECT_EQ(1, renderer_load_ct_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ExpectOpenURL())
|
||||
EXPECT_TRUE(got_open_url_from_tab_);
|
||||
|
@ -2105,7 +2007,7 @@ class LoadNavTestHandler : public TestHandler {
|
|||
} // namespace
|
||||
|
||||
// Verify navigation-related callbacks when browsing same-origin via LoadURL().
|
||||
TEST(NavigationTest, SameOriginLoadURL) {
|
||||
TEST(NavigationTest, LoadSameOriginLoadURL) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::LOAD, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2113,7 +2015,7 @@ TEST(NavigationTest, SameOriginLoadURL) {
|
|||
}
|
||||
|
||||
// Verify navigation-related callbacks when browsing same-origin via left-click.
|
||||
TEST(NavigationTest, SameOriginLeftClick) {
|
||||
TEST(NavigationTest, LoadSameOriginLeftClick) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::LEFT_CLICK, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2122,7 +2024,7 @@ TEST(NavigationTest, SameOriginLeftClick) {
|
|||
|
||||
// Verify navigation-related callbacks when browsing same-origin via middle-
|
||||
// click.
|
||||
TEST(NavigationTest, SameOriginMiddleClick) {
|
||||
TEST(NavigationTest, LoadSameOriginMiddleClick) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::MIDDLE_CLICK, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2130,7 +2032,7 @@ TEST(NavigationTest, SameOriginMiddleClick) {
|
|||
}
|
||||
|
||||
// Same as above but cancel the 2nd navigation in OnOpenURLFromTab.
|
||||
TEST(NavigationTest, SameOriginMiddleClickCancel) {
|
||||
TEST(NavigationTest, LoadSameOriginMiddleClickCancel) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::MIDDLE_CLICK, true, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2139,7 +2041,7 @@ TEST(NavigationTest, SameOriginMiddleClickCancel) {
|
|||
|
||||
// Verify navigation-related callbacks when browsing same-origin via ctrl+left-
|
||||
// click.
|
||||
TEST(NavigationTest, SameOriginCtrlLeftClick) {
|
||||
TEST(NavigationTest, LoadSameOriginCtrlLeftClick) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::CTRL_LEFT_CLICK, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2147,7 +2049,7 @@ TEST(NavigationTest, SameOriginCtrlLeftClick) {
|
|||
}
|
||||
|
||||
// Same as above but cancel the 2nd navigation in OnOpenURLFromTab.
|
||||
TEST(NavigationTest, SameOriginCtrlLeftClickCancel) {
|
||||
TEST(NavigationTest, LoadSameOriginCtrlLeftClickCancel) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::CTRL_LEFT_CLICK, true, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2155,7 +2057,7 @@ TEST(NavigationTest, SameOriginCtrlLeftClickCancel) {
|
|||
}
|
||||
|
||||
// Verify navigation-related callbacks when browsing cross-origin via LoadURL().
|
||||
TEST(NavigationTest, CrossOriginLoadURL) {
|
||||
TEST(NavigationTest, LoadCrossOriginLoadURL) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::LOAD, false);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2164,7 +2066,7 @@ TEST(NavigationTest, CrossOriginLoadURL) {
|
|||
|
||||
// Verify navigation-related callbacks when browsing cross-origin via left-
|
||||
// click.
|
||||
TEST(NavigationTest, CrossOriginLeftClick) {
|
||||
TEST(NavigationTest, LoadCrossOriginLeftClick) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::LEFT_CLICK, false);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2173,7 +2075,7 @@ TEST(NavigationTest, CrossOriginLeftClick) {
|
|||
|
||||
// Verify navigation-related callbacks when browsing cross-origin via middle-
|
||||
// click.
|
||||
TEST(NavigationTest, CrossOriginMiddleClick) {
|
||||
TEST(NavigationTest, LoadCrossOriginMiddleClick) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::MIDDLE_CLICK, false);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2181,7 +2083,7 @@ TEST(NavigationTest, CrossOriginMiddleClick) {
|
|||
}
|
||||
|
||||
// Same as above but cancel the 2nd navigation in OnOpenURLFromTab.
|
||||
TEST(NavigationTest, CrossOriginMiddleClickCancel) {
|
||||
TEST(NavigationTest, LoadCrossOriginMiddleClickCancel) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::MIDDLE_CLICK, false, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2190,7 +2092,7 @@ TEST(NavigationTest, CrossOriginMiddleClickCancel) {
|
|||
|
||||
// Verify navigation-related callbacks when browsing cross-origin via ctrl+left-
|
||||
// click.
|
||||
TEST(NavigationTest, CrossOriginCtrlLeftClick) {
|
||||
TEST(NavigationTest, LoadCrossOriginCtrlLeftClick) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::CTRL_LEFT_CLICK, false);
|
||||
handler->ExecuteTest();
|
||||
|
@ -2198,7 +2100,7 @@ TEST(NavigationTest, CrossOriginCtrlLeftClick) {
|
|||
}
|
||||
|
||||
// Same as above but cancel the 2nd navigation in OnOpenURLFromTab.
|
||||
TEST(NavigationTest, CrossOriginCtrlLeftClickCancel) {
|
||||
TEST(NavigationTest, LoadCrossOriginCtrlLeftClickCancel) {
|
||||
CefRefPtr<LoadNavTestHandler> handler =
|
||||
new LoadNavTestHandler(LoadNavTestHandler::CTRL_LEFT_CLICK, false, true);
|
||||
handler->ExecuteTest();
|
||||
|
@ -3428,10 +3330,12 @@ const char kExtraInfoUrl[] = "http://tests-extrainfonav.com/extra.html";
|
|||
const char kExtraInfoPopupUrl[] =
|
||||
"http://tests-extrainfonav.com/extra_popup.html";
|
||||
const char kExtraInfoNavMsg[] = "NavigationTest.ExtraInfoNav";
|
||||
|
||||
bool g_extra_info_nav_test = false;
|
||||
const char kExtraInfoTestCmdKey[] = "nav-extra-info-test";
|
||||
|
||||
void SetBrowserExtraInfo(CefRefPtr<CefDictionaryValue> extra_info) {
|
||||
// Necessary for identifying the test case.
|
||||
extra_info->SetBool(kExtraInfoTestCmdKey, true);
|
||||
|
||||
// Arbitrary data for testing.
|
||||
extra_info->SetBool("bool", true);
|
||||
CefRefPtr<CefDictionaryValue> dict = CefDictionaryValue::Create();
|
||||
|
@ -3442,45 +3346,15 @@ void SetBrowserExtraInfo(CefRefPtr<CefDictionaryValue> extra_info) {
|
|||
extra_info->SetString("string", "some string");
|
||||
}
|
||||
|
||||
// Browser side.
|
||||
class ExtraInfoNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
ExtraInfoNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_extra_info_nav_test)
|
||||
return;
|
||||
|
||||
// Indicate to the render process that the test should be run.
|
||||
command_line->AppendSwitchWithValue("test", kExtraInfoNavMsg);
|
||||
}
|
||||
|
||||
protected:
|
||||
IMPLEMENT_REFCOUNTING(ExtraInfoNavBrowserTest);
|
||||
};
|
||||
|
||||
// Renderer side
|
||||
class ExtraInfoNavRendererTest : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
ExtraInfoNavRendererTest() : run_test_(false) {}
|
||||
|
||||
void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
// Check that the test should be run.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& test = command_line->GetSwitchValue("test");
|
||||
if (test != kExtraInfoNavMsg)
|
||||
return;
|
||||
|
||||
run_test_ = true;
|
||||
}
|
||||
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
run_test_ = extra_info->HasKey(kExtraInfoTestCmdKey);
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
|
@ -3522,11 +3396,11 @@ class ExtraInfoNavTestHandler : public TestHandler {
|
|||
"text/html");
|
||||
AddResource(kExtraInfoPopupUrl, "<html>ExtraInfoPopup</html>", "text/html");
|
||||
|
||||
CefRefPtr<CefDictionaryValue> extra = CefDictionaryValue::Create();
|
||||
SetBrowserExtraInfo(extra);
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
SetBrowserExtraInfo(extra_info);
|
||||
|
||||
// Create the browser.
|
||||
CreateBrowser(kExtraInfoUrl, NULL, extra);
|
||||
CreateBrowser(kExtraInfoUrl, NULL, extra_info);
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
SetTestTimeout();
|
||||
|
@ -3610,20 +3484,15 @@ class ExtraInfoNavTestHandler : public TestHandler {
|
|||
} // namespace
|
||||
|
||||
TEST(NavigationTest, ExtraInfo) {
|
||||
g_extra_info_nav_test = true;
|
||||
CefRefPtr<ExtraInfoNavTestHandler> handler = new ExtraInfoNavTestHandler();
|
||||
handler->ExecuteTest();
|
||||
g_extra_info_nav_test = false;
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
// Entry point for creating navigation browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateNavigationBrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new HistoryNavBrowserTest);
|
||||
delegates.insert(new OrderNavBrowserTest);
|
||||
delegates.insert(new LoadNavBrowserTest);
|
||||
delegates.insert(new ExtraInfoNavBrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating navigation renderer test objects.
|
||||
|
|
|
@ -35,27 +35,7 @@ enum NetNotifyTestType {
|
|||
const char kNetNotifyOrigin1[] = "http://tests-netnotify1/";
|
||||
const char kNetNotifyOrigin2[] = "http://tests-netnotify2/";
|
||||
const char kNetNotifyMsg[] = "RequestHandlerTest.NetNotify";
|
||||
|
||||
bool g_net_notify_test = false;
|
||||
|
||||
// Browser side.
|
||||
class NetNotifyBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
NetNotifyBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_net_notify_test)
|
||||
return;
|
||||
|
||||
// Indicate to the render process that the test should be run.
|
||||
command_line->AppendSwitchWithValue("test", kNetNotifyMsg);
|
||||
}
|
||||
|
||||
protected:
|
||||
IMPLEMENT_REFCOUNTING(NetNotifyBrowserTest);
|
||||
};
|
||||
const char kNetNotifyTestCmdKey[] = "rh-net-notify-test";
|
||||
|
||||
// Browser side.
|
||||
class NetNotifyTestHandler : public TestHandler {
|
||||
|
@ -98,8 +78,11 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
CefRequestContext::CreateContext(settings, NULL);
|
||||
cookie_manager_ = request_context->GetCookieManager(NULL);
|
||||
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
extra_info->SetBool(kNetNotifyTestCmdKey, true);
|
||||
|
||||
// Create browser that loads the 1st URL.
|
||||
CreateBrowser(url1_, request_context);
|
||||
CreateBrowser(url1_, request_context, extra_info);
|
||||
}
|
||||
|
||||
void RunTest() override {
|
||||
|
@ -191,6 +174,9 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
// render process to be created. We therefore need some information in
|
||||
// the request itself to tell us that the navigation has already been
|
||||
// delayed.
|
||||
// Navigating cross-origin from the renderer process will cause the
|
||||
// process to be terminated with "bad IPC message" reason
|
||||
// INVALID_INITIATOR_ORIGIN (213).
|
||||
url += "&delayed=true";
|
||||
|
||||
if (test_type_ == NNTT_DELAYED_RENDERER) {
|
||||
|
@ -258,6 +244,19 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||
TerminationStatus status) override {
|
||||
got_process_terminated_ct_++;
|
||||
|
||||
// Termination is expected for cross-origin requests initiated from the
|
||||
// renderer process.
|
||||
if (!(test_type_ == NNTT_DELAYED_RENDERER && !same_origin_)) {
|
||||
TestHandler::OnRenderProcessTerminated(browser, status);
|
||||
}
|
||||
|
||||
FinishTest();
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetupCompleteIfDone() {
|
||||
if (got_load_end1_ && got_process_message1_)
|
||||
|
@ -316,17 +315,33 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
EXPECT_TRUE(got_cookie1_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_process_message1_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_before_browse2_) << " browser " << browser_id;
|
||||
|
||||
if (test_type_ == NNTT_DELAYED_RENDERER && !same_origin_) {
|
||||
EXPECT_EQ(1, got_process_terminated_ct_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_load_end2_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_before_resource_load2_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_get_resource_handler2_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_resource_load_complete2_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_cookie2_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_process_message2_) << " browser " << browser_id;
|
||||
} else {
|
||||
EXPECT_EQ(0, got_process_terminated_ct_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_load_end2_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_before_resource_load2_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_get_resource_handler2_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_resource_load_complete2_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_cookie2_) << " browser " << browser_id;
|
||||
EXPECT_TRUE(got_process_message2_) << " browser " << browser_id;
|
||||
}
|
||||
|
||||
if (test_type_ == NNTT_DELAYED_RENDERER ||
|
||||
test_type_ == NNTT_DELAYED_BROWSER) {
|
||||
EXPECT_TRUE(got_before_browse2_will_delay_) << " browser " << browser_id;
|
||||
if (test_type_ == NNTT_DELAYED_RENDERER && !same_origin_) {
|
||||
EXPECT_FALSE(got_before_browse2_delayed_) << " browser " << browser_id;
|
||||
} else {
|
||||
EXPECT_TRUE(got_before_browse2_delayed_) << " browser " << browser_id;
|
||||
}
|
||||
} else {
|
||||
EXPECT_FALSE(got_before_browse2_will_delay_) << " browser " << browser_id;
|
||||
EXPECT_FALSE(got_before_browse2_delayed_) << " browser " << browser_id;
|
||||
|
@ -360,6 +375,7 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
TrackCallback got_process_message2_;
|
||||
TrackCallback got_before_browse2_will_delay_;
|
||||
TrackCallback got_before_browse2_delayed_;
|
||||
int got_process_terminated_ct_ = 0;
|
||||
|
||||
int64 response_length1_;
|
||||
int64 response_length2_;
|
||||
|
@ -373,18 +389,10 @@ class NetNotifyRendererTest : public ClientAppRenderer::Delegate,
|
|||
public:
|
||||
NetNotifyRendererTest() : run_test_(false) {}
|
||||
|
||||
void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_net_notify_test) {
|
||||
// Check that the test should be run.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
const std::string& test = command_line->GetSwitchValue("test");
|
||||
if (test != kNetNotifyMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
run_test_ = true;
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
run_test_ = extra_info->HasKey(kNetNotifyTestCmdKey);
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
|
@ -443,8 +451,6 @@ class NetNotifyRendererTest : public ClientAppRenderer::Delegate,
|
|||
void RunNetNotifyTest(NetNotifyTestType test_type,
|
||||
bool same_origin,
|
||||
size_t count = 3U) {
|
||||
g_net_notify_test = true;
|
||||
|
||||
TestHandler::CompletionState completion_state(count);
|
||||
TestHandler::Collection collection(&completion_state);
|
||||
|
||||
|
@ -463,8 +469,6 @@ void RunNetNotifyTest(NetNotifyTestType test_type,
|
|||
handlers.erase(handlers.begin());
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
g_net_notify_test = false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -509,13 +513,6 @@ TEST(RequestHandlerTest, NotificationsCrossOriginDelayedBrowser) {
|
|||
RunNetNotifyTest(NNTT_DELAYED_BROWSER, false);
|
||||
}
|
||||
|
||||
// Entry point for creating request handler browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRequestHandlerBrowserTests(
|
||||
ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new NetNotifyBrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating request handler renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRequestHandlerRendererTests(
|
||||
|
|
|
@ -42,7 +42,7 @@ const char kV8HandlerCallOnReleasedContextUrl[] =
|
|||
const char kV8HandlerCallOnReleasedContextChildUrl[] =
|
||||
"http://tests/V8Test.HandlerCallOnReleasedContext/child.html";
|
||||
const char kV8TestMsg[] = "V8Test.Test";
|
||||
const char kV8TestCmdArg[] = "v8-test";
|
||||
const char kV8TestCmdKey[] = "v8-test";
|
||||
const char kV8RunTestMsg[] = "V8Test.RunTest";
|
||||
|
||||
enum V8TestMode {
|
||||
|
@ -96,31 +96,6 @@ enum V8TestMode {
|
|||
V8TEST_HANDLER_CALL_ON_RELEASED_CONTEXT,
|
||||
};
|
||||
|
||||
// Set to the current test being run in the browser process. Will always be
|
||||
// V8TEST_NONE in the render process.
|
||||
V8TestMode g_current_test_mode = V8TEST_NONE;
|
||||
|
||||
// Browser side.
|
||||
class V8BrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
V8BrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
CefString process_type = command_line->GetSwitchValue("type");
|
||||
if (process_type == "renderer") {
|
||||
// Add the current test mode to the render process command line arguments.
|
||||
char buff[33];
|
||||
sprintf(buff, "%d", g_current_test_mode);
|
||||
command_line->AppendSwitchWithValue(kV8TestCmdArg, buff);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(V8BrowserTest);
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class V8RendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
|
@ -2500,14 +2475,8 @@ class V8RendererTest : public ClientAppRenderer::Delegate,
|
|||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDictionaryValue> extra_info) override {
|
||||
test_mode_ = g_current_test_mode;
|
||||
if (test_mode_ == V8TEST_NONE) {
|
||||
// Retrieve the test mode from the command line.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
CefString value = command_line->GetSwitchValue(kV8TestCmdArg);
|
||||
if (!value.empty())
|
||||
test_mode_ = static_cast<V8TestMode>(atoi(value.ToString().c_str()));
|
||||
if (extra_info->HasKey(kV8TestCmdKey)) {
|
||||
test_mode_ = static_cast<V8TestMode>(extra_info->GetInt(kV8TestCmdKey));
|
||||
}
|
||||
if (test_mode_ > V8TEST_NONE)
|
||||
RunStartupTest();
|
||||
|
@ -2843,6 +2812,9 @@ class V8TestHandler : public TestHandler {
|
|||
: test_mode_(test_mode), test_url_(test_url) {}
|
||||
|
||||
void RunTest() override {
|
||||
CefRefPtr<CefDictionaryValue> extra_info = CefDictionaryValue::Create();
|
||||
extra_info->SetInt(kV8TestCmdKey, test_mode_);
|
||||
|
||||
// Nested script tag forces creation of the V8 context.
|
||||
if (test_mode_ == V8TEST_CONTEXT_EVAL_CSP_BYPASS_UNSAFE_EVAL ||
|
||||
test_mode_ == V8TEST_CONTEXT_EVAL_CSP_BYPASS_SANDBOX) {
|
||||
|
@ -2864,7 +2836,7 @@ class V8TestHandler : public TestHandler {
|
|||
"<p id='result' style='display:none'>CSP_BYPASSED</p>"
|
||||
"</body></html>",
|
||||
"text/html", headers);
|
||||
CreateBrowser(test_url_);
|
||||
CreateBrowser(test_url_, NULL, extra_info);
|
||||
} else if (test_mode_ == V8TEST_CONTEXT_ENTERED) {
|
||||
AddResource(kV8ContextParentTestUrl,
|
||||
"<html><body>"
|
||||
|
@ -2877,7 +2849,7 @@ class V8TestHandler : public TestHandler {
|
|||
"<html><body>"
|
||||
"<script>var i = 0;</script>CHILD</body></html>",
|
||||
"text/html");
|
||||
CreateBrowser(kV8ContextParentTestUrl);
|
||||
CreateBrowser(kV8ContextParentTestUrl, NULL, extra_info);
|
||||
} else if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
||||
test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
AddResource(kV8OnUncaughtExceptionTestUrl,
|
||||
|
@ -2889,7 +2861,7 @@ class V8TestHandler : public TestHandler {
|
|||
"</script>\n"
|
||||
"</body></html>\n",
|
||||
"text/html");
|
||||
CreateBrowser(kV8OnUncaughtExceptionTestUrl);
|
||||
CreateBrowser(kV8OnUncaughtExceptionTestUrl, NULL, extra_info);
|
||||
} else if (test_mode_ == V8TEST_HANDLER_CALL_ON_RELEASED_CONTEXT) {
|
||||
AddResource(kV8HandlerCallOnReleasedContextUrl,
|
||||
"<html><body onload='createFrame()'>"
|
||||
|
@ -2941,14 +2913,14 @@ class V8TestHandler : public TestHandler {
|
|||
"</script>"
|
||||
"</body></html>",
|
||||
"text/html");
|
||||
CreateBrowser(kV8HandlerCallOnReleasedContextUrl);
|
||||
CreateBrowser(kV8HandlerCallOnReleasedContextUrl, NULL, extra_info);
|
||||
} else {
|
||||
EXPECT_TRUE(test_url_ != NULL);
|
||||
AddResource(test_url_,
|
||||
"<html><body>"
|
||||
"<script>var i = 0;</script>TEST</body></html>",
|
||||
"text/html");
|
||||
CreateBrowser(test_url_);
|
||||
CreateBrowser(test_url_, NULL, extra_info);
|
||||
}
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
|
@ -3034,12 +3006,6 @@ class V8TestHandler : public TestHandler {
|
|||
|
||||
} // namespace
|
||||
|
||||
// Entry point for creating V8 browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateV8BrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new V8BrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating V8 renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateV8RendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
|
@ -3049,12 +3015,10 @@ void CreateV8RendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
|||
// Helpers for defining V8 tests.
|
||||
#define V8_TEST_EX(name, test_mode, test_url) \
|
||||
TEST(V8Test, name) { \
|
||||
g_current_test_mode = test_mode; \
|
||||
CefRefPtr<V8TestHandler> handler = new V8TestHandler(test_mode, test_url); \
|
||||
handler->ExecuteTest(); \
|
||||
EXPECT_TRUE(handler->got_message_); \
|
||||
EXPECT_TRUE(handler->got_success_); \
|
||||
g_current_test_mode = V8TEST_NONE; \
|
||||
ReleaseAndWaitForDestructor(handler); \
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue