chrome: Fix FrameTest and RequestHandlerTest failures (see issue #2969)

This commit is contained in:
Marshall Greenblatt 2021-04-09 22:24:44 -04:00
parent 5318dfe252
commit 1c04d96468
5 changed files with 22 additions and 7 deletions

View File

@ -28,11 +28,6 @@ const char* kTestPath = "/path/to/cookietest";
const int kIgnoreNumDeleted = -2;
bool IgnoreURL(const std::string& url) {
return IsChromeRuntimeEnabled() &&
url.find("/favicon.ico") != std::string::npos;
}
typedef std::vector<CefCookie> CookieVector;
class TestCompletionCallback : public CefCompletionCallback {

View File

@ -424,10 +424,13 @@ class FrameNavTestHandler : public TestHandler {
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) override {
const std::string& url = request->GetURL();
if (IgnoreURL(url))
return nullptr;
EXPECT_TRUE(expectations_->GetResourceHandler(browser, frame))
<< "nav = " << nav_;
const std::string& url = request->GetURL();
const std::string& content = expectations_->GetContentForURL(url);
EXPECT_TRUE(!content.empty()) << "nav = " << nav_;

View File

@ -101,6 +101,9 @@ class NetNotifyTestHandler : public TestHandler {
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
const std::string& url = request->GetURL();
if (IgnoreURL(url))
return RV_CONTINUE;
if (url.find(url1_) == 0)
got_before_resource_load1_.yes();
else if (url.find(url2_) == 0)
@ -118,6 +121,9 @@ class NetNotifyTestHandler : public TestHandler {
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
const std::string& url = request->GetURL();
if (IgnoreURL(url))
return nullptr;
if (url.find(url1_) == 0)
got_get_resource_handler1_.yes();
else if (url.find(url2_) == 0)
@ -135,9 +141,12 @@ class NetNotifyTestHandler : public TestHandler {
URLRequestStatus status,
int64 received_content_length) override {
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
EXPECT_EQ(UR_SUCCESS, status);
const std::string& url = request->GetURL();
if (IgnoreURL(url))
return;
EXPECT_EQ(UR_SUCCESS, status);
if (url.find(url1_) == 0) {
got_resource_load_complete1_.yes();
EXPECT_EQ(response_length1_, received_content_length);

View File

@ -291,6 +291,11 @@ bool IsChromeRuntimeEnabled() {
return state ? true : false;
}
bool IgnoreURL(const std::string& url) {
return IsChromeRuntimeEnabled() &&
url.find("/favicon.ico") != std::string::npos;
}
CefRefPtr<CefRequestContext> CreateTestRequestContext(
TestRequestContextMode mode,
const std::string& cache_path) {

View File

@ -84,6 +84,9 @@ bool TestOldResourceAPI();
// Returns true if the Chrome runtime is enabled.
bool IsChromeRuntimeEnabled();
// Returns true if requests for |url| should be ignored by tests.
bool IgnoreURL(const std::string& url);
// Return a RequestContext object matching the specified |mode|.
// |cache_path| may be specified for CUSTOM modes.
// Use the RC_TEST_GROUP_BASE macro to test all valid combinations.