Update to Chromium revision 304f01a1 (#358063)

- Improve ordering of CefLoadHandler callbacks. OnLoadingStateChange will
  be called before and after all calls to OnLoadStart and OnLoadEnd.
  OnLoadStart/OnLoadEnd calls will occur as matching pairs
  (see http://crbug.com/539952#c2).
- Remove the |requesting_url| argument to CefGeolocationHandler::
  OnCancelGeolocationPermission. Clients can use the |request_id| argument
  to track this information themselves.
- Fix a crash when loading the PDF extension in multiple browsers with a
  custom CefRequestContext (issue #1757).
This commit is contained in:
Marshall Greenblatt
2015-11-10 15:18:16 -05:00
parent e0974ea64d
commit c6111d5947
92 changed files with 1918 additions and 902 deletions

View File

@@ -542,6 +542,11 @@ TEST(CookieTest, DomainCookieOnDisk) {
EXPECT_TRUE(manager.get());
TestDomainCookie(manager, event);
// The backing store will be closed on the DB thread after the CookieManager
// is destroyed.
manager = NULL;
WaitForDBThread();
}
// Test creation of a host cookie.
@@ -585,6 +590,11 @@ TEST(CookieTest, HostCookieOnDisk) {
EXPECT_TRUE(manager.get());
TestHostCookie(manager, event);
// The backing store will be closed on the DB thread after the CookieManager
// is destroyed.
manager = NULL;
WaitForDBThread();
}
// Test creation of multiple cookies.
@@ -628,6 +638,11 @@ TEST(CookieTest, MultipleCookiesOnDisk) {
EXPECT_TRUE(manager.get());
TestMultipleCookies(manager, event);
// The backing store will be closed on the DB thread after the CookieManager
// is destroyed.
manager = NULL;
WaitForDBThread();
}
TEST(CookieTest, AllCookiesGlobal) {
@@ -668,6 +683,11 @@ TEST(CookieTest, AllCookiesOnDisk) {
EXPECT_TRUE(manager.get());
TestAllCookies(manager, event);
// The backing store will be closed on the DB thread after the CookieManager
// is destroyed.
manager = NULL;
WaitForDBThread();
}
TEST(CookieTest, ChangeDirectoryGlobal) {

View File

@@ -7,6 +7,8 @@
// Include this first to avoid type conflicts with CEF headers.
#include "tests/unittests/chromium_includes.h"
#include "include/base/cef_bind.h"
#include "include/wrapper/cef_closure_task.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h"
@@ -29,7 +31,9 @@ const char kTitleStr3[] = "Title 3";
class TitleTestHandler : public TestHandler {
public:
TitleTestHandler()
: step_(0) {}
: step_(0),
got_title_change_(false),
got_loading_state_change_(false) {}
void RunTest() override {
// Add the resources that we will navigate to/from.
@@ -52,32 +56,57 @@ class TitleTestHandler : public TestHandler {
void OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) override {
// Ignore the 2nd OnTitleChange call which arrives after navigation
// completion.
if (got_title_change_)
return;
std::string title_str = title;
if (step_ == 0 || step_ == 2) {
EXPECT_STREQ(kTitleStr1, title_str.c_str());
} else if (step_ == 1 || step_ == 3) {
EXPECT_STREQ(kTitleStr2, title_str.c_str());
} else if (step_ == 4) {
// Ignore the unexpected notification of the page URL.
// Related bug: http://crbug.com/331351
if (title_str == &kTitleUrl2[7])
return;
EXPECT_STREQ(kTitleStr3, title_str.c_str());
}
got_title_[step_].yes();
if (step_ == 4)
if (step_ == 4) {
DestroyTest();
} else {
got_title_change_ = true;
NextIfReady(browser);
}
}
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode) override {
void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool isLoading,
bool canGoBack,
bool canGoForward) override {
if (isLoading)
return;
// Call NextIfReady asynchronously because an additional call to
// OnTitleChange will be triggered later in the current call stack due to
// navigation completion and we want that call to arrive before execution of
// NextIfReady.
got_loading_state_change_ = true;
CefPostTask(TID_UI,
base::Bind(&TitleTestHandler::NextIfReady, this, browser));
}
private:
void NextIfReady(CefRefPtr<CefBrowser> browser) {
if (!got_title_change_ || !got_loading_state_change_)
return;
got_title_change_ = false;
got_loading_state_change_ = false;
switch (step_++) {
case 0:
frame->LoadURL(kTitleUrl2);
browser->GetMainFrame()->LoadURL(kTitleUrl2);
break;
case 1:
browser->GoBack();
@@ -86,14 +115,13 @@ class TitleTestHandler : public TestHandler {
browser->GoForward();
break;
case 3:
frame->ExecuteJavaScript("setTitle()", kTitleUrl2, 0);
browser->GetMainFrame()->ExecuteJavaScript("setTitle()", kTitleUrl2, 0);
break;
default:
EXPECT_TRUE(false); // Not reached.
}
}
private:
void DestroyTest() override {
for (int i = 0; i < 5; ++i)
EXPECT_TRUE(got_title_[i]) << "step " << i;
@@ -103,6 +131,9 @@ class TitleTestHandler : public TestHandler {
int step_;
bool got_title_change_;
bool got_loading_state_change_;
TrackCallback got_title_[5];
IMPLEMENT_REFCOUNTING(TitleTestHandler);

View File

@@ -1823,7 +1823,8 @@ bool VerifyBrowserIframe(CefRefPtr<CefBrowser> browser,
V_EXPECT_TRUE(frame1b->GetIdentifier() == frame1id);
V_EXPECT_TRUE(frame2b->GetIdentifier() == frame2id);
V_EXPECT_TRUE(browser->GetFrameCount() == 3U);
size_t frame_count = browser->GetFrameCount();
V_EXPECT_TRUE(frame_count == 3U) << "actual " << frame_count;
// Verify the GetFrameNames result.
std::vector<CefString> names;
@@ -1958,6 +1959,8 @@ class FrameNavExpectationsBrowserTestNestedIframes :
} else if (frame_number == 2) {
V_EXPECT_TRUE(got_load_start_[0]);
V_EXPECT_TRUE(got_load_start_[1]);
} else {
V_EXPECT_TRUE(false); // Not reached.
}
got_load_start_[frame_number].yes();
@@ -1984,6 +1987,8 @@ class FrameNavExpectationsBrowserTestNestedIframes :
} else if (frame_number == 2) {
V_EXPECT_FALSE(got_load_end_[0]);
V_EXPECT_FALSE(got_load_end_[1]);
} else {
V_EXPECT_TRUE(false); // Not reached.
}
V_EXPECT_TRUE(VerifyBrowserIframe(browser, frame, origin_, frame_number)) <<

View File

@@ -110,13 +110,11 @@ class GeolocationTestHandler : public TestHandler {
void OnCancelGeolocationPermission(
CefRefPtr<CefBrowser> browser,
const CefString& requesting_url,
int request_id) override {
got_cancelgeolocationpermission_.yes();
EXPECT_TRUE(CefCurrentlyOn(TID_UI));
EXPECT_STREQ(kTestOrigin, requesting_url.ToString().c_str());
EXPECT_EQ(request_id, request_id_);
}

View File

@@ -64,13 +64,15 @@ class MRRenderDelegate : public ClientAppRenderer::Delegate {
CefRefPtr<CefBrowser> browser = context->GetBrowser();
CefRefPtr<CefFrame> frame = context->GetFrame();
const int64 frame_id = frame->GetIdentifier();
const bool is_main_frame = frame->IsMain();
CefRefPtr<CefProcessMessage> message =
CefProcessMessage::Create(kDoneMessageName);
CefRefPtr<CefListValue> args = message->GetArgumentList();
args->SetInt(0, CefInt64GetLow(frame_id));
args->SetInt(1, CefInt64GetHigh(frame_id));
args->SetString(2, msg);
args->SetBool(2, is_main_frame);
args->SetString(3, msg);
EXPECT_TRUE(browser->SendProcessMessage(PID_BROWSER, message));
return true;
} else {
@@ -251,16 +253,22 @@ class MRTestHandler : public TestHandler {
const std::string& message_name = message->GetName();
if (message_name == kDoneMessageName) {
CefRefPtr<CefListValue> args = message->GetArgumentList();
EXPECT_EQ(3U, args->GetSize());
EXPECT_EQ(4U, args->GetSize());
EXPECT_EQ(VTYPE_INT, args->GetType(0));
EXPECT_EQ(VTYPE_INT, args->GetType(1));
EXPECT_EQ(VTYPE_STRING, args->GetType(2));
EXPECT_EQ(VTYPE_BOOL, args->GetType(2));
EXPECT_EQ(VTYPE_STRING, args->GetType(3));
const int64 frame_id = CefInt64Set(args->GetInt(0), args->GetInt(1));
CefRefPtr<CefFrame> frame = browser->GetFrame(frame_id);
const bool is_main_frame = args->GetBool(2);
CefRefPtr<CefFrame> frame;
if (is_main_frame)
frame = browser->GetMainFrame();
else
frame = browser->GetFrame(frame_id);
EXPECT_TRUE(frame.get());
OnNotify(browser, frame, args->GetString(2));
OnNotify(browser, frame, args->GetString(3));
return true;
}
@@ -1268,6 +1276,7 @@ class MultiQueryManager : public CefMessageRouterBrowserSide::Handler {
query.browser_id = browser->GetIdentifier();
query.frame_id = frame->GetIdentifier();
query.is_main_frame = frame->IsMain();
if (query.type == SUCCESS) {
// Send the single success response.
@@ -1317,7 +1326,12 @@ class MultiQueryManager : public CefMessageRouterBrowserSide::Handler {
if (query.query_id == query_id) {
// Verify that browser and frame are the same.
EXPECT_EQ(query.browser_id, browser->GetIdentifier()) << i;
EXPECT_EQ(query.frame_id, frame->GetIdentifier()) << i;
if (query.is_main_frame) {
EXPECT_TRUE(frame->IsMain()) << i;
} else {
EXPECT_FALSE(frame->IsMain()) << i;
EXPECT_EQ(query.frame_id, frame->GetIdentifier()) << i;
}
// Verify a successful/expected result.
EXPECT_TRUE(WillCancel(query.type)) << i;
@@ -1414,6 +1428,7 @@ class MultiQueryManager : public CefMessageRouterBrowserSide::Handler {
: type(test_type),
browser_id(0),
frame_id(0),
is_main_frame(false),
query_id(0) {}
TestType type;
@@ -1421,6 +1436,7 @@ class MultiQueryManager : public CefMessageRouterBrowserSide::Handler {
// Set in OnQuery and verified in OnNotify or OnQueryCanceled.
int browser_id;
int64 frame_id;
bool is_main_frame;
// Used when a query is canceled.
int64 query_id;

View File

@@ -347,6 +347,7 @@ class HistoryNavTestHandler : public TestHandler {
HistoryNavTestHandler()
: nav_(0),
load_end_confirmation_(false),
load_state_change_loaded_confirmation_(false),
renderer_confirmation_(false) {}
void RunTest() override {
@@ -401,8 +402,10 @@ class HistoryNavTestHandler : public TestHandler {
}
void RunNextNavIfReady(CefRefPtr<CefBrowser> browser) {
if (load_end_confirmation_ && renderer_confirmation_) {
if (load_end_confirmation_ && load_state_change_loaded_confirmation_ &&
renderer_confirmation_) {
load_end_confirmation_ = false;
load_state_change_loaded_confirmation_ = false;
renderer_confirmation_ = false;
nav_++;
RunNav(browser);
@@ -470,6 +473,9 @@ class HistoryNavTestHandler : public TestHandler {
bool isLoading,
bool canGoBack,
bool canGoForward) override {
if (isLoading)
return;
const NavListItem& item = kHNavList[nav_];
got_loading_state_change_[nav_].yes();
@@ -478,6 +484,9 @@ class HistoryNavTestHandler : public TestHandler {
got_correct_can_go_back_[nav_].yes();
if (item.can_go_forward == canGoForward)
got_correct_can_go_forward_[nav_].yes();
load_state_change_loaded_confirmation_ = true;
RunNextNavIfReady(browser);
}
void OnLoadStart(CefRefPtr<CefBrowser> browser,
@@ -516,11 +525,6 @@ class HistoryNavTestHandler : public TestHandler {
if (url1 == item.target && url2 == item.target)
got_correct_load_end_url_[nav_].yes();
if (item.can_go_back == browser->CanGoBack())
got_correct_can_go_back2_[nav_].yes();
if (item.can_go_forward == browser->CanGoForward())
got_correct_can_go_forward2_[nav_].yes();
load_end_confirmation_ = true;
RunNextNavIfReady(browser);
}
@@ -549,6 +553,7 @@ class HistoryNavTestHandler : public TestHandler {
int nav_;
bool load_end_confirmation_;
bool load_state_change_loaded_confirmation_;
bool renderer_confirmation_;
TrackCallback got_before_browse_[NAV_LIST_SIZE()];
@@ -563,8 +568,6 @@ class HistoryNavTestHandler : public TestHandler {
TrackCallback got_load_end_[NAV_LIST_SIZE()];
TrackCallback got_correct_history_[NAV_LIST_SIZE()];
TrackCallback got_correct_load_end_url_[NAV_LIST_SIZE()];
TrackCallback got_correct_can_go_back2_[NAV_LIST_SIZE()];
TrackCallback got_correct_can_go_forward2_[NAV_LIST_SIZE()];
IMPLEMENT_REFCOUNTING(HistoryNavTestHandler);
};
@@ -597,8 +600,6 @@ TEST(NavigationTest, History) {
ASSERT_TRUE(handler->got_load_end_[i]) << "i = " << i;
ASSERT_TRUE(handler->got_correct_history_[i]) << "i = " << i;
ASSERT_TRUE(handler->got_correct_load_end_url_[i]) << "i = " << i;
ASSERT_TRUE(handler->got_correct_can_go_back2_[i]) << "i = " << i;
ASSERT_TRUE(handler->got_correct_can_go_forward2_[i]) << "i = " << i;
}
}
@@ -931,7 +932,7 @@ class OrderNavLoadState {
got_loading_state_start_.yes();
} else {
EXPECT_TRUE(Verify(true, false, true, false));
EXPECT_TRUE(Verify(true, false, true, true));
got_loading_state_end_.yes();
}
@@ -947,7 +948,7 @@ class OrderNavLoadState {
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode) {
EXPECT_TRUE(Verify(true, true, true, false));
EXPECT_TRUE(Verify(true, false, true, false));
got_load_end_.yes();
}

View File

@@ -35,10 +35,6 @@ class PluginBrowserTest : public client::ClientAppBrowser::Delegate {
void OnBeforeCommandLineProcessing(
CefRefPtr<client::ClientAppBrowser> app,
CefRefPtr<CefCommandLine> command_line) override {
// Enables testing of the plugin placeholder.
// See LoadablePluginPlaceholder::DidFinishLoadingCallback.
command_line->AppendSwitch("enable-plugin-placeholder-testing");
// Allow all plugin loading by default.
command_line->AppendSwitchWithValue("plugin-policy", "allow");
}
@@ -50,6 +46,9 @@ class PluginBrowserTest : public client::ClientAppBrowser::Delegate {
const char kPdfHtmlUrl[] = "http://tests/pdf.html";
const char kPdfDirectUrl[] = "http://tests/pdf.pdf";
// Delay waiting for the plugin placeholder to load.
const int64 kPlaceholderLoadDelayMs = 1000;
// Delay waiting for iframe tests to load the PDF file.
#if defined(OS_LINUX)
const int64 kPdfLoadDelayMs = 7000;
@@ -246,29 +245,12 @@ class PluginTestHandler : public RoutingTestHandler,
frame->ExecuteJavaScript(code, frame->GetURL(), 0);
}
void WaitForPlaceholderLoad(CefRefPtr<CefFrame> frame) const {
void WaitForPlaceholderLoad(CefRefPtr<CefFrame> frame) {
// Waits for the placeholder to load.
// See LoadablePluginPlaceholder::DidFinishLoadingCallback and
// chrome/browser/plugins/plugin_power_saver_browsertest.cc.
const std::string& code =
"var plugin = " + GetPluginNode() +";"
"if (plugin === undefined ||"
" (plugin.nodeName !== 'OBJECT' && plugin.nodeName !== 'EMBED')) {"
" window.testQuery({request:'placeholder_error'});"
"} else {"
" function handleEvent(event) {"
" if (event.data === 'placeholderLoaded') {"
" window.testQuery({request:'placeholder_ready'});"
" plugin.removeEventListener('message', handleEvent);"
" }"
" }"
" plugin.addEventListener('message', handleEvent);"
" if (plugin.hasAttribute('placeholderLoaded')) {"
" window.testQuery({request:'placeholder_ready'});"
" plugin.removeEventListener('message', handleEvent);"
" }"
"}";
frame->ExecuteJavaScript(code, frame->GetURL(), 0);
CefPostDelayedTask(TID_UI,
base::Bind(&PluginTestHandler::TriggerContextMenu, this,
frame->GetBrowser()),
kPlaceholderLoadDelayMs);
}
void WaitForPlaceholderHide(CefRefPtr<CefFrame> frame) const {
@@ -430,15 +412,7 @@ class PluginTestHandler : public RoutingTestHandler,
// Wait for the first PDF file to load.
WaitForPluginLoad(frame);
}
} else if (request == "placeholder_ready") {
EXPECT_FALSE(got_placeholder_ready_);
got_placeholder_ready_.yes();
// The plugin placeholder has loaded.
CefPostTask(TID_UI,
base::Bind(&PluginTestHandler::TriggerContextMenu, this, browser));
} else if (request == "placeholder_hidden") {
EXPECT_TRUE(got_placeholder_ready_);
EXPECT_FALSE(got_placeholder_hidden_);
got_placeholder_hidden_.yes();
@@ -536,11 +510,6 @@ class PluginTestHandler : public RoutingTestHandler,
context_handler_ = NULL;
}
if (HasBlock() || HasDisable())
EXPECT_TRUE(got_placeholder_ready_);
else
EXPECT_FALSE(got_placeholder_ready_);
if (HasContextHide()) {
EXPECT_TRUE(got_placeholder_hidden_);
EXPECT_FALSE(got_plugin_ready_);
@@ -614,7 +583,6 @@ class PluginTestHandler : public RoutingTestHandler,
TrackCallback got_on_load_end_pdf2_;
TrackCallback got_pdf_plugin_found_;
TrackCallback got_pdf_plugin_missing_;
TrackCallback got_placeholder_ready_;
TrackCallback got_placeholder_hidden_;
TrackCallback got_plugin_ready_;
TrackCallback got_run_context_menu_;

View File

@@ -317,6 +317,7 @@ void WaitForThread(CefRefPtr<CefTaskRunner> task_runner);
#define WaitForIOThread() WaitForThread(TID_IO)
#define WaitForUIThread() WaitForThread(TID_UI)
#define WaitForDBThread() WaitForThread(TID_DB)
// Returns true if the currently running test has failed.
bool TestFailed();