#include "extensions/browser/event_router.h"
#include <memory>
#include <string>
#include <utility>
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/values.h"
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
#include "content/public/test/mock_render_process_host.h"
#include "extensions/browser/event_listener_map.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/process_map_factory.h"
#include "extensions/browser/test_event_router_observer.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_api.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/simple_feature.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/mojom/event_dispatcher.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_database.mojom-blink-forward.h"
Value;
namespace extensions {
namespace {
class MockEventRouterObserver : public EventRouter::Observer { … };
class MockEventDispatcher : public mojom::EventDispatcher { … };
EventListenerConstructor;
std::unique_ptr<EventListener> CreateEventListenerForExtension(
const ExtensionId& extension_id,
const std::string& event_name,
content::RenderProcessHost* process,
base::Value::Dict filter) { … }
std::unique_ptr<EventListener> CreateEventListenerForURL(
const GURL& listener_url,
const std::string& event_name,
content::RenderProcessHost* process,
base::Value::Dict filter) { … }
std::unique_ptr<EventListener> CreateEventListenerForExtensionServiceWorker(
const ExtensionId& extension_id,
int64_t service_worker_version_id,
int worker_thread_id,
const std::string& event_name,
content::RenderProcessHost* process,
base::Value::Dict filter) { … }
scoped_refptr<const Extension> CreateExtension(bool component,
bool persistent) { … }
scoped_refptr<const Extension> CreateServiceWorkerExtension() { … }
base::Value::Dict CreateHostSuffixFilter(const std::string& suffix) { … }
}
bool operator<(const EventTarget& e1, const EventTarget& e2) { … }
bool operator==(const EventTarget& e1, const EventTarget& e2) { … }
std::ostream& operator<<(std::ostream& os, const EventTarget& e) { … }
class EventRouterTest : public ExtensionsTest { … };
class EventRouterFilterTest : public ExtensionsTest,
public testing::WithParamInterface<bool> { … };
TEST_F(EventRouterTest, GetBaseEventName) { … }
void EventRouterTest::RunEventRouterObserverTest(
const EventListenerConstructor& constructor) { … }
TEST_F(EventRouterTest, EventRouterObserverForExtensions) { … }
TEST_F(EventRouterTest, EventRouterObserverForURLs) { … }
TEST_F(EventRouterTest, EventRouterObserverForServiceWorkers) { … }
namespace {
class EventRouterObserver : public EventRouter::TestObserver { … };
class ProcessMapFake : public ProcessMap { … };
std::unique_ptr<KeyedService> BuildProcessMap(
content::BrowserContext* profile) { … }
}
TEST_F(EventRouterTest, WebUIEventsDoNotCrossIncognitoBoundaries) { … }
TEST_F(EventRouterTest, MultipleEventRouterObserver) { … }
TEST_F(EventRouterTest, TestReportEvent) { … }
TEST_P(EventRouterFilterTest, DISABLED_Basic) { … }
TEST_P(EventRouterFilterTest, DISABLED_URLBasedFilteredEventListener) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
class EventRouterDispatchTest : public ExtensionsTest { … };
TEST_F(EventRouterDispatchTest, TestDispatch) { … }
TEST_F(EventRouterDispatchTest, DISABLED_TestDispatchCallback) { … }
}