2013-09-03 18:43:31 +02:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2014-07-15 20:10:40 +02:00
|
|
|
#include "include/base/cef_bind.h"
|
2013-09-03 18:43:31 +02:00
|
|
|
#include "include/cef_request_context.h"
|
|
|
|
#include "include/cef_request_context_handler.h"
|
2014-07-15 20:10:40 +02:00
|
|
|
#include "include/wrapper/cef_closure_task.h"
|
2016-11-15 18:56:02 +01:00
|
|
|
#include "include/wrapper/cef_scoped_temp_dir.h"
|
2016-11-18 18:31:21 +01:00
|
|
|
#include "tests/ceftests/test_handler.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/gtest/include/gtest/gtest.h"
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
TEST(RequestContextTest, GetGlobalContext) {
|
|
|
|
CefRefPtr<CefRequestContext> context1 =
|
|
|
|
CefRequestContext::GetGlobalContext();
|
|
|
|
EXPECT_TRUE(context1.get());
|
|
|
|
EXPECT_TRUE(context1->IsGlobal());
|
|
|
|
EXPECT_TRUE(context1->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context2 =
|
|
|
|
CefRequestContext::GetGlobalContext();
|
|
|
|
EXPECT_TRUE(context2.get());
|
|
|
|
EXPECT_TRUE(context2->IsGlobal());
|
|
|
|
EXPECT_TRUE(context2->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context2));
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
EXPECT_TRUE(context1->IsSame(context2));
|
|
|
|
EXPECT_TRUE(context2->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, CreateContext) {
|
|
|
|
class Handler : public CefRequestContextHandler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefCookieManager> GetCookieManager() override { return NULL; }
|
2013-09-03 18:43:31 +02:00
|
|
|
private:
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
2013-09-03 21:12:22 +02:00
|
|
|
CefRefPtr<CefRequestContextHandler> handler = new Handler();
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContextSettings settings;
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
CefRefPtr<CefRequestContext> context1 =
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContext::CreateContext(settings, handler.get());
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(context1.get());
|
|
|
|
EXPECT_FALSE(context1->IsGlobal());
|
|
|
|
EXPECT_TRUE(context1->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_EQ(context1->GetHandler().get(), handler.get());
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context2 =
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContext::CreateContext(settings, handler.get());
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(context2.get());
|
|
|
|
EXPECT_FALSE(context2->IsGlobal());
|
|
|
|
EXPECT_TRUE(context2->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context2));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_EQ(context2->GetHandler().get(), handler.get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(context1->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context1->IsSharingWith(context2));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context2->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context2->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context3 =
|
|
|
|
CefRequestContext::GetGlobalContext();
|
|
|
|
EXPECT_TRUE(context3.get());
|
|
|
|
EXPECT_FALSE(context3->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context3->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context3->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context3->IsSharingWith(context2));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context1->IsSame(context3));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context1->IsSharingWith(context3));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context2->IsSame(context3));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context2->IsSharingWith(context3));
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, CreateContextNoHandler) {
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContextSettings settings;
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
CefRefPtr<CefRequestContext> context1 =
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContext::CreateContext(settings, NULL);
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(context1.get());
|
|
|
|
EXPECT_FALSE(context1->IsGlobal());
|
|
|
|
EXPECT_TRUE(context1->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context1->GetHandler().get());
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context2 =
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContext::CreateContext(settings, NULL);
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(context2.get());
|
|
|
|
EXPECT_FALSE(context2->IsGlobal());
|
|
|
|
EXPECT_TRUE(context2->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context2));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context2->GetHandler().get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(context1->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context1->IsSharingWith(context2));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context2->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context2->IsSharingWith(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context3 =
|
|
|
|
CefRequestContext::GetGlobalContext();
|
|
|
|
EXPECT_TRUE(context3.get());
|
|
|
|
EXPECT_FALSE(context3->IsSame(context1));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context3->IsSharingWith(context1));
|
|
|
|
EXPECT_FALSE(context3->IsSame(context2));
|
|
|
|
EXPECT_FALSE(context3->IsSharingWith(context2));
|
|
|
|
EXPECT_FALSE(context1->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context1->IsSharingWith(context3));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context2->IsSharingWith(context3));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, CreateContextSharedGlobal) {
|
|
|
|
CefRequestContextSettings settings;
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context1 =
|
|
|
|
CefRequestContext::GetGlobalContext();
|
|
|
|
EXPECT_TRUE(context1.get());
|
|
|
|
EXPECT_TRUE(context1->IsGlobal());
|
|
|
|
EXPECT_TRUE(context1->IsSame(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context1));
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context2 =
|
|
|
|
CefRequestContext::CreateContext(context1, NULL);
|
|
|
|
EXPECT_TRUE(context2.get());
|
|
|
|
EXPECT_FALSE(context2->IsGlobal());
|
|
|
|
EXPECT_TRUE(context2->IsSame(context2));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context1));
|
|
|
|
EXPECT_FALSE(context1->IsSame(context2));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context2));
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context3 =
|
|
|
|
CefRequestContext::CreateContext(context2, NULL);
|
|
|
|
EXPECT_TRUE(context3.get());
|
|
|
|
EXPECT_FALSE(context3->IsGlobal());
|
|
|
|
EXPECT_TRUE(context3->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context3->IsSame(context2));
|
|
|
|
EXPECT_FALSE(context3->IsSame(context1));
|
|
|
|
EXPECT_FALSE(context1->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context3));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context3));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context3));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context3));
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context4 =
|
|
|
|
CefRequestContext::CreateContext(context1, NULL);
|
|
|
|
EXPECT_TRUE(context4.get());
|
|
|
|
EXPECT_FALSE(context4->IsGlobal());
|
|
|
|
EXPECT_TRUE(context4->IsSame(context4));
|
|
|
|
EXPECT_FALSE(context4->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context4->IsSame(context2));
|
|
|
|
EXPECT_FALSE(context4->IsSame(context1));
|
|
|
|
EXPECT_FALSE(context1->IsSame(context4));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context4));
|
|
|
|
EXPECT_FALSE(context3->IsSame(context4));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context4));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context3));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context4));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context4));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context4));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, CreateContextSharedOnDisk) {
|
2016-11-15 18:56:02 +01:00
|
|
|
CefScopedTempDir tempdir;
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(tempdir.CreateUniqueTempDir());
|
|
|
|
|
|
|
|
CefRequestContextSettings settings;
|
2016-11-15 18:56:02 +01:00
|
|
|
CefString(&settings.cache_path) = tempdir.GetPath();
|
2015-03-02 21:25:14 +01:00
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context1 =
|
|
|
|
CefRequestContext::CreateContext(settings, NULL);
|
|
|
|
EXPECT_TRUE(context1.get());
|
|
|
|
EXPECT_FALSE(context1->IsGlobal());
|
|
|
|
EXPECT_TRUE(context1->IsSame(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context1));
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context2 =
|
|
|
|
CefRequestContext::CreateContext(context1, NULL);
|
|
|
|
EXPECT_TRUE(context2.get());
|
|
|
|
EXPECT_FALSE(context2->IsGlobal());
|
|
|
|
EXPECT_TRUE(context2->IsSame(context2));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context1));
|
|
|
|
EXPECT_FALSE(context1->IsSame(context2));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context2));
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context3 =
|
|
|
|
CefRequestContext::CreateContext(context2, NULL);
|
|
|
|
EXPECT_TRUE(context3.get());
|
|
|
|
EXPECT_FALSE(context3->IsGlobal());
|
|
|
|
EXPECT_TRUE(context3->IsSame(context3));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context3->IsSame(context2));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_FALSE(context3->IsSame(context1));
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_FALSE(context1->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context3));
|
2015-03-02 21:25:14 +01:00
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context3));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context3));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context3));
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context4 =
|
|
|
|
CefRequestContext::CreateContext(context1, NULL);
|
|
|
|
EXPECT_TRUE(context4.get());
|
|
|
|
EXPECT_FALSE(context4->IsGlobal());
|
|
|
|
EXPECT_TRUE(context4->IsSame(context4));
|
|
|
|
EXPECT_FALSE(context4->IsSame(context3));
|
|
|
|
EXPECT_FALSE(context4->IsSame(context2));
|
|
|
|
EXPECT_FALSE(context4->IsSame(context1));
|
|
|
|
EXPECT_FALSE(context1->IsSame(context4));
|
|
|
|
EXPECT_FALSE(context2->IsSame(context4));
|
|
|
|
EXPECT_FALSE(context3->IsSame(context4));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context4));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context3));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context2));
|
|
|
|
EXPECT_TRUE(context4->IsSharingWith(context1));
|
|
|
|
EXPECT_TRUE(context1->IsSharingWith(context4));
|
|
|
|
EXPECT_TRUE(context2->IsSharingWith(context4));
|
|
|
|
EXPECT_TRUE(context3->IsSharingWith(context4));
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class CookieTestHandler : public TestHandler {
|
|
|
|
public:
|
|
|
|
class RequestContextHandler : public CefRequestContextHandler {
|
|
|
|
public:
|
|
|
|
explicit RequestContextHandler(CookieTestHandler* handler)
|
|
|
|
: handler_(handler) {}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefCookieManager> GetCookieManager() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(handler_);
|
|
|
|
handler_->got_get_cookie_manager_.yes();
|
|
|
|
return handler_->cookie_manager_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Detach() {
|
|
|
|
handler_ = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CookieTestHandler* handler_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(RequestContextHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
CookieTestHandler(const std::string& url)
|
|
|
|
: url_(url) {}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void RunTest() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
AddResource(url_,
|
|
|
|
"<html>"
|
|
|
|
"<head><script>document.cookie='name1=value1';</script></head>"
|
|
|
|
"<body>Nav1</body>"
|
|
|
|
"</html>", "text/html");
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContextSettings settings;
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
context_handler_ = new RequestContextHandler(this);
|
2015-03-02 21:25:14 +01:00
|
|
|
context_ =
|
|
|
|
CefRequestContext::CreateContext(settings, context_handler_.get());
|
|
|
|
cookie_manager_ = CefCookieManager::CreateManager(CefString(), true, NULL);
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
// Create browser that loads the 1st URL.
|
|
|
|
CreateBrowser(url_, context_);
|
2015-01-10 00:40:26 +01:00
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout();
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
int httpStatusCode) override {
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRefPtr<CefRequestContext> context =
|
|
|
|
browser->GetHost()->GetRequestContext();
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
EXPECT_TRUE(context->IsSame(context_));
|
|
|
|
EXPECT_FALSE(context->IsGlobal());
|
|
|
|
EXPECT_EQ(context->GetHandler().get(), context_handler_.get());
|
|
|
|
|
|
|
|
FinishTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void FinishTest() {
|
|
|
|
// Verify that the cookie was set correctly.
|
|
|
|
class TestVisitor : public CefCookieVisitor {
|
|
|
|
public:
|
|
|
|
explicit TestVisitor(CookieTestHandler* handler)
|
|
|
|
: handler_(handler) {
|
|
|
|
}
|
2014-11-12 20:25:15 +01:00
|
|
|
~TestVisitor() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
// Destroy the test.
|
|
|
|
CefPostTask(TID_UI,
|
2014-07-15 20:10:40 +02:00
|
|
|
base::Bind(&CookieTestHandler::DestroyTest, handler_));
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Visit(const CefCookie& cookie, int count, int total,
|
|
|
|
bool& deleteCookie) override {
|
2013-09-03 18:43:31 +02:00
|
|
|
const std::string& name = CefString(&cookie.name);
|
|
|
|
const std::string& value = CefString(&cookie.value);
|
|
|
|
if (name == "name1" && value == "value1")
|
|
|
|
handler_->got_cookie_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CookieTestHandler* handler_;
|
|
|
|
IMPLEMENT_REFCOUNTING(TestVisitor);
|
|
|
|
};
|
|
|
|
|
|
|
|
cookie_manager_->VisitAllCookies(new TestVisitor(this));
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void DestroyTest() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
// Verify test expectations.
|
|
|
|
EXPECT_TRUE(got_get_cookie_manager_);
|
|
|
|
EXPECT_TRUE(got_cookie_);
|
|
|
|
|
|
|
|
context_handler_->Detach();
|
|
|
|
context_handler_ = NULL;
|
|
|
|
context_ = NULL;
|
|
|
|
|
|
|
|
TestHandler::DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string url_;
|
|
|
|
CefRefPtr<CefRequestContext> context_;
|
|
|
|
CefRefPtr<RequestContextHandler> context_handler_;
|
|
|
|
CefRefPtr<CefCookieManager> cookie_manager_;
|
|
|
|
|
|
|
|
TrackCallback got_get_cookie_manager_;
|
|
|
|
TrackCallback got_cookie_;
|
2015-09-09 16:05:39 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CookieTestHandler);
|
2013-09-03 18:43:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// Test that the cookie manager is retrieved via the associated request context.
|
|
|
|
TEST(RequestContextTest, GetCookieManager) {
|
|
|
|
CefRefPtr<CookieTestHandler> handler =
|
|
|
|
new CookieTestHandler(
|
|
|
|
"http://tests-simple-rch.com/nav1.html");
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class PopupTestHandler : public TestHandler {
|
|
|
|
public:
|
|
|
|
class RequestContextHandler : public CefRequestContextHandler {
|
|
|
|
public:
|
|
|
|
explicit RequestContextHandler(PopupTestHandler* handler)
|
|
|
|
: handler_(handler) {}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefCookieManager> GetCookieManager() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(handler_);
|
|
|
|
if (url_ == handler_->url_)
|
|
|
|
handler_->got_get_cookie_manager1_.yes();
|
|
|
|
else if (url_ == handler_->popup_url_)
|
|
|
|
handler_->got_get_cookie_manager2_.yes();
|
|
|
|
return handler_->cookie_manager_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetURL(const std::string& url) {
|
|
|
|
url_ = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Detach() {
|
|
|
|
handler_ = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PopupTestHandler* handler_;
|
|
|
|
std::string url_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(RequestContextHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
MODE_WINDOW_OPEN,
|
|
|
|
MODE_TARGETED_LINK,
|
|
|
|
MODE_NOREFERRER_LINK,
|
|
|
|
};
|
|
|
|
|
|
|
|
PopupTestHandler(bool same_origin,
|
|
|
|
Mode mode)
|
|
|
|
: mode_(mode) {
|
|
|
|
url_ = "http://tests-simple-rch1.com/nav1.html";
|
|
|
|
if (same_origin)
|
|
|
|
popup_url_ = "http://tests-simple-rch1.com/pop1.html";
|
|
|
|
else
|
|
|
|
popup_url_ = "http://tests-simple-rch2.com/pop1.html";
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void RunTest() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
std::string link;
|
|
|
|
if (mode_ == MODE_TARGETED_LINK) {
|
|
|
|
link = "<a href=\"" + std::string(popup_url_) +
|
|
|
|
"\" target=\"mytarget\"\">CLICK ME</a>";
|
|
|
|
} else if (mode_ == MODE_NOREFERRER_LINK) {
|
|
|
|
link = "<a href=\"" + std::string(popup_url_) +
|
|
|
|
"\" rel=\"noreferrer\" target=\"_blank\"\">CLICK ME</a>";
|
|
|
|
}
|
|
|
|
|
|
|
|
AddResource(url_,
|
|
|
|
"<html>"
|
|
|
|
"<head><script>document.cookie='name1=value1';"
|
|
|
|
"function doPopup() { window.open('" + std::string(popup_url_) + "'); }"
|
|
|
|
"</script></head>"
|
|
|
|
"<body><h1>" + link + "</h1></body>"
|
|
|
|
"</html>", "text/html");
|
|
|
|
|
|
|
|
AddResource(popup_url_,
|
|
|
|
"<html>"
|
|
|
|
"<head><script>document.cookie='name2=value2';</script></head>"
|
|
|
|
"<body>Nav1</body>"
|
|
|
|
"</html>", "text/html");
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContextSettings settings;
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
context_handler_ = new RequestContextHandler(this);
|
|
|
|
context_handler_->SetURL(url_);
|
2015-03-02 21:25:14 +01:00
|
|
|
context_ =
|
|
|
|
CefRequestContext::CreateContext(settings, context_handler_.get());
|
|
|
|
cookie_manager_ = CefCookieManager::CreateManager(CefString(), true, NULL);
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
// Create browser that loads the 1st URL.
|
|
|
|
CreateBrowser(url_, context_);
|
2015-01-10 00:40:26 +01:00
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout();
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
int httpStatusCode) override {
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRefPtr<CefRequestContext> context =
|
|
|
|
browser->GetHost()->GetRequestContext();
|
2013-09-03 18:43:31 +02:00
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
EXPECT_TRUE(context->IsSame(context_));
|
|
|
|
EXPECT_FALSE(context->IsGlobal());
|
|
|
|
|
|
|
|
EXPECT_TRUE(frame->IsMain());
|
|
|
|
|
|
|
|
const std::string& url = frame->GetURL();
|
|
|
|
if (url == url_) {
|
|
|
|
got_load_end1_.yes();
|
|
|
|
context_handler_->SetURL(popup_url_);
|
|
|
|
LaunchPopup(browser);
|
|
|
|
} if (url == popup_url_) {
|
|
|
|
got_load_end2_.yes();
|
|
|
|
EXPECT_TRUE(browser->IsPopup());
|
|
|
|
// Close the popup window.
|
2016-01-19 21:09:01 +01:00
|
|
|
CloseBrowser(browser, true);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
const CefString& target_url,
|
|
|
|
const CefString& target_frame_name,
|
2015-03-09 21:22:31 +01:00
|
|
|
cef_window_open_disposition_t target_disposition,
|
2015-03-06 22:38:38 +01:00
|
|
|
bool user_gesture,
|
2014-11-12 20:25:15 +01:00
|
|
|
const CefPopupFeatures& popupFeatures,
|
|
|
|
CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient>& client,
|
|
|
|
CefBrowserSettings& settings,
|
|
|
|
bool* no_javascript_access) override {
|
2013-09-03 18:43:31 +02:00
|
|
|
got_on_before_popup_.yes();
|
|
|
|
|
|
|
|
const std::string& url = target_url;
|
|
|
|
EXPECT_STREQ(url.c_str(), popup_url_.c_str());
|
2015-03-06 22:38:38 +01:00
|
|
|
|
|
|
|
EXPECT_EQ(WOD_NEW_FOREGROUND_TAB, target_disposition);
|
|
|
|
|
|
|
|
if (mode_ == MODE_WINDOW_OPEN)
|
|
|
|
EXPECT_FALSE(user_gesture);
|
|
|
|
else
|
|
|
|
EXPECT_TRUE(user_gesture);
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override {
|
2013-09-03 18:43:31 +02:00
|
|
|
TestHandler::OnBeforeClose(browser);
|
|
|
|
|
|
|
|
if (browser->IsPopup())
|
|
|
|
FinishTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void LaunchPopup(CefRefPtr<CefBrowser> browser) {
|
|
|
|
if (mode_ == MODE_WINDOW_OPEN) {
|
|
|
|
browser->GetMainFrame()->ExecuteJavaScript("doPopup()", url_, 0);
|
|
|
|
} else if (mode_ == MODE_TARGETED_LINK ||
|
|
|
|
mode_ == MODE_NOREFERRER_LINK) {
|
|
|
|
CefMouseEvent mouse_event;
|
|
|
|
mouse_event.x = 20;
|
|
|
|
mouse_event.y = 20;
|
|
|
|
mouse_event.modifiers = 0;
|
|
|
|
browser->GetHost()->SendMouseClickEvent(
|
|
|
|
mouse_event, MBT_LEFT, false, 1);
|
|
|
|
browser->GetHost()->SendMouseClickEvent(
|
|
|
|
mouse_event, MBT_LEFT, true, 1);
|
|
|
|
} else {
|
|
|
|
EXPECT_TRUE(false); // Not reached.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FinishTest() {
|
|
|
|
// Verify that the cookies were set correctly.
|
|
|
|
class TestVisitor : public CefCookieVisitor {
|
|
|
|
public:
|
|
|
|
explicit TestVisitor(PopupTestHandler* handler)
|
|
|
|
: handler_(handler) {
|
|
|
|
}
|
2014-11-12 20:25:15 +01:00
|
|
|
~TestVisitor() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
// Destroy the test.
|
|
|
|
CefPostTask(TID_UI,
|
2014-07-15 20:10:40 +02:00
|
|
|
base::Bind(&PopupTestHandler::DestroyTest, handler_));
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Visit(const CefCookie& cookie, int count, int total,
|
|
|
|
bool& deleteCookie) override {
|
2013-09-03 18:43:31 +02:00
|
|
|
const std::string& name = CefString(&cookie.name);
|
|
|
|
const std::string& value = CefString(&cookie.value);
|
|
|
|
if (name == "name1" && value == "value1")
|
|
|
|
handler_->got_cookie1_.yes();
|
|
|
|
else if (name == "name2" && value == "value2")
|
|
|
|
handler_->got_cookie2_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PopupTestHandler* handler_;
|
|
|
|
IMPLEMENT_REFCOUNTING(TestVisitor);
|
|
|
|
};
|
|
|
|
|
|
|
|
cookie_manager_->VisitAllCookies(new TestVisitor(this));
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void DestroyTest() override {
|
2013-09-03 18:43:31 +02:00
|
|
|
// Verify test expectations.
|
|
|
|
EXPECT_TRUE(got_get_cookie_manager1_);
|
|
|
|
EXPECT_TRUE(got_load_end1_);
|
|
|
|
EXPECT_TRUE(got_on_before_popup_);
|
|
|
|
EXPECT_TRUE(got_get_cookie_manager2_);
|
|
|
|
EXPECT_TRUE(got_load_end2_);
|
|
|
|
EXPECT_TRUE(got_cookie1_);
|
|
|
|
EXPECT_TRUE(got_cookie2_);
|
|
|
|
|
|
|
|
context_handler_->Detach();
|
|
|
|
context_handler_ = NULL;
|
|
|
|
context_ = NULL;
|
|
|
|
|
|
|
|
TestHandler::DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string url_;
|
|
|
|
std::string popup_url_;
|
|
|
|
Mode mode_;
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context_;
|
|
|
|
CefRefPtr<RequestContextHandler> context_handler_;
|
|
|
|
CefRefPtr<CefCookieManager> cookie_manager_;
|
|
|
|
|
|
|
|
TrackCallback got_get_cookie_manager1_;
|
|
|
|
TrackCallback got_load_end1_;
|
|
|
|
TrackCallback got_on_before_popup_;
|
|
|
|
TrackCallback got_get_cookie_manager2_;
|
|
|
|
TrackCallback got_load_end2_;
|
|
|
|
TrackCallback got_cookie1_;
|
|
|
|
TrackCallback got_cookie2_;
|
2015-09-09 16:05:39 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(PopupTestHandler);
|
2013-09-03 18:43:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// Test that a popup created using window.open() will get the same request
|
|
|
|
// context as the parent browser.
|
|
|
|
TEST(RequestContextTest, WindowOpenSameOrigin) {
|
|
|
|
CefRefPtr<PopupTestHandler> handler =
|
|
|
|
new PopupTestHandler(true,
|
|
|
|
PopupTestHandler::MODE_WINDOW_OPEN);
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, WindowOpenDifferentOrigin) {
|
|
|
|
CefRefPtr<PopupTestHandler> handler =
|
|
|
|
new PopupTestHandler(false,
|
|
|
|
PopupTestHandler::MODE_WINDOW_OPEN);
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test that a popup created using a targeted link will get the same request
|
|
|
|
// context as the parent browser.
|
|
|
|
TEST(RequestContextTest, TargetedLinkSameOrigin) {
|
|
|
|
CefRefPtr<PopupTestHandler> handler =
|
|
|
|
new PopupTestHandler(true,
|
|
|
|
PopupTestHandler::MODE_TARGETED_LINK);
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, TargetedLinkDifferentOrigin) {
|
|
|
|
CefRefPtr<PopupTestHandler> handler =
|
|
|
|
new PopupTestHandler(false,
|
|
|
|
PopupTestHandler::MODE_TARGETED_LINK);
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Test that a popup created using a noreferrer link will get the same
|
|
|
|
// request context as the parent browser. A new render process will
|
|
|
|
// be created for the popup browser.
|
|
|
|
TEST(RequestContextTest, NoReferrerLinkSameOrigin) {
|
|
|
|
CefRefPtr<PopupTestHandler> handler =
|
|
|
|
new PopupTestHandler(true,
|
|
|
|
PopupTestHandler::MODE_NOREFERRER_LINK);
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RequestContextTest, NoReferrerLinkDifferentOrigin) {
|
|
|
|
CefRefPtr<PopupTestHandler> handler =
|
|
|
|
new PopupTestHandler(false,
|
|
|
|
PopupTestHandler::MODE_NOREFERRER_LINK);
|
|
|
|
handler->ExecuteTest();
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|
2016-02-23 20:29:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2016-02-24 00:27:05 +01:00
|
|
|
const char kResolveOrigin[] = "http://www.google.com";
|
|
|
|
|
2016-02-23 20:29:18 +01:00
|
|
|
class MethodTestHandler : public TestHandler {
|
|
|
|
public:
|
|
|
|
enum Method {
|
|
|
|
METHOD_CLEAR_CERTIFICATE_EXCEPTIONS,
|
|
|
|
METHOD_CLOSE_ALL_CONNECTIONS,
|
2016-02-24 00:27:05 +01:00
|
|
|
METHOD_RESOLVE_HOST,
|
2016-02-23 20:29:18 +01:00
|
|
|
};
|
|
|
|
|
2016-02-24 00:27:05 +01:00
|
|
|
class CompletionCallback : public CefCompletionCallback,
|
|
|
|
public CefResolveCallback {
|
2016-02-23 20:29:18 +01:00
|
|
|
public:
|
2016-02-24 00:27:05 +01:00
|
|
|
CompletionCallback(MethodTestHandler* test_handler,
|
|
|
|
CefRefPtr<CefBrowser> browser)
|
|
|
|
: test_handler_(test_handler),
|
|
|
|
browser_(browser) {
|
2016-02-23 20:29:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~CompletionCallback() override {
|
|
|
|
// OnComplete should be executed.
|
|
|
|
EXPECT_FALSE(test_handler_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnComplete() override {
|
|
|
|
EXPECT_UI_THREAD();
|
|
|
|
|
|
|
|
// OnComplete should be executed only one time.
|
|
|
|
EXPECT_TRUE(test_handler_);
|
2016-02-24 00:27:05 +01:00
|
|
|
test_handler_->OnCompleteCallback(browser_);
|
2016-02-23 20:29:18 +01:00
|
|
|
test_handler_ = nullptr;
|
2016-02-24 00:27:05 +01:00
|
|
|
browser_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnResolveCompleted(
|
|
|
|
cef_errorcode_t result,
|
|
|
|
const std::vector<CefString>& resolved_ips) override {
|
|
|
|
EXPECT_EQ(ERR_NONE, result);
|
|
|
|
EXPECT_TRUE(!resolved_ips.empty());
|
|
|
|
OnComplete();
|
2016-02-23 20:29:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MethodTestHandler* test_handler_;
|
2016-02-24 00:27:05 +01:00
|
|
|
CefRefPtr<CefBrowser> browser_;
|
2016-02-23 20:29:18 +01:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CompletionCallback);
|
|
|
|
};
|
|
|
|
|
|
|
|
MethodTestHandler(bool global_context,
|
|
|
|
Method method)
|
|
|
|
: global_context_(global_context),
|
|
|
|
method_(method) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunTest() override {
|
|
|
|
const char kUrl[] = "http://tests/method.html";
|
|
|
|
|
|
|
|
AddResource(kUrl, "<html><body>Method</body></html>", "text/html");
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> request_context;
|
|
|
|
if (!global_context_) {
|
|
|
|
CefRequestContextSettings settings;
|
|
|
|
request_context = CefRequestContext::CreateContext(settings, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateBrowser(kUrl, request_context);
|
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
int httpStatusCode) override {
|
|
|
|
CefRefPtr<CefRequestContext> context =
|
|
|
|
browser->GetHost()->GetRequestContext();
|
2016-02-24 00:27:05 +01:00
|
|
|
CefRefPtr<CompletionCallback> callback =
|
|
|
|
new CompletionCallback(this, browser);
|
2016-02-23 20:29:18 +01:00
|
|
|
if (method_ == METHOD_CLEAR_CERTIFICATE_EXCEPTIONS)
|
|
|
|
context->ClearCertificateExceptions(callback);
|
|
|
|
else if (method_ == METHOD_CLOSE_ALL_CONNECTIONS)
|
|
|
|
context->CloseAllConnections(callback);
|
2016-02-24 00:27:05 +01:00
|
|
|
else if (method_ == METHOD_RESOLVE_HOST)
|
|
|
|
context->ResolveHost(kResolveOrigin, callback);
|
2016-02-23 20:29:18 +01:00
|
|
|
}
|
|
|
|
|
2016-02-24 00:27:05 +01:00
|
|
|
void OnCompleteCallback(CefRefPtr<CefBrowser> browser) {
|
2016-02-23 20:29:18 +01:00
|
|
|
EXPECT_UI_THREAD();
|
|
|
|
EXPECT_FALSE(got_completion_callback_);
|
|
|
|
got_completion_callback_.yes();
|
2016-02-24 00:27:05 +01:00
|
|
|
|
|
|
|
if (method_ == METHOD_RESOLVE_HOST) {
|
|
|
|
// Now try a cached request.
|
|
|
|
CefPostTask(TID_IO,
|
|
|
|
base::Bind(&MethodTestHandler::ResolveHostCached, this, browser));
|
|
|
|
} else {
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResolveHostCached(CefRefPtr<CefBrowser> browser) {
|
|
|
|
EXPECT_IO_THREAD();
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestContext> context =
|
|
|
|
browser->GetHost()->GetRequestContext();
|
|
|
|
std::vector<CefString> resolved_ips;
|
|
|
|
cef_errorcode_t result =
|
|
|
|
context->ResolveHostCached(kResolveOrigin, resolved_ips);
|
|
|
|
EXPECT_EQ(ERR_NONE, result);
|
|
|
|
EXPECT_TRUE(!resolved_ips.empty());
|
|
|
|
|
|
|
|
CefPostTask(TID_UI, base::Bind(&MethodTestHandler::DestroyTest, this));
|
2016-02-23 20:29:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void DestroyTest() override {
|
|
|
|
EXPECT_TRUE(got_completion_callback_);
|
|
|
|
TestHandler::DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool global_context_;
|
|
|
|
const Method method_;
|
|
|
|
|
|
|
|
TrackCallback got_completion_callback_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(MethodTestHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// Test CefRequestContext::ClearCertificateExceptions with the global context.
|
|
|
|
TEST(RequestContextTest, ClearCertificateExceptionsGlobal) {
|
|
|
|
CefRefPtr<MethodTestHandler> handler =
|
|
|
|
new MethodTestHandler(true,
|
|
|
|
MethodTestHandler::METHOD_CLEAR_CERTIFICATE_EXCEPTIONS);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test CefRequestContext::ClearCertificateExceptions with a custom context.
|
|
|
|
TEST(RequestContextTest, ClearCertificateExceptionsCustom) {
|
|
|
|
CefRefPtr<MethodTestHandler> handler =
|
|
|
|
new MethodTestHandler(false,
|
|
|
|
MethodTestHandler::METHOD_CLEAR_CERTIFICATE_EXCEPTIONS);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test CefRequestContext::CloseAllConnections with the global context.
|
|
|
|
TEST(RequestContextTest, CloseAllConnectionsGlobal) {
|
|
|
|
CefRefPtr<MethodTestHandler> handler =
|
|
|
|
new MethodTestHandler(true,
|
|
|
|
MethodTestHandler::METHOD_CLOSE_ALL_CONNECTIONS);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test CefRequestContext::CloseAllConnections with a custom context.
|
|
|
|
TEST(RequestContextTest, CloseAllConnectionsCustom) {
|
|
|
|
CefRefPtr<MethodTestHandler> handler =
|
|
|
|
new MethodTestHandler(false,
|
|
|
|
MethodTestHandler::METHOD_CLOSE_ALL_CONNECTIONS);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
2016-02-24 00:27:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test CefRequestContext::ResolveHost with the global context.
|
|
|
|
TEST(RequestContextTest, ResolveHostGlobal) {
|
|
|
|
CefRefPtr<MethodTestHandler> handler =
|
|
|
|
new MethodTestHandler(true,
|
|
|
|
MethodTestHandler::METHOD_RESOLVE_HOST);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test CefRequestContext::ResolveHost with a custom context.
|
|
|
|
TEST(RequestContextTest, ResolveHostCustom) {
|
|
|
|
CefRefPtr<MethodTestHandler> handler =
|
|
|
|
new MethodTestHandler(false,
|
|
|
|
MethodTestHandler::METHOD_RESOLVE_HOST);
|
|
|
|
handler->ExecuteTest();
|
|
|
|
ReleaseAndWaitForDestructor(handler);
|
|
|
|
}
|