#include "extensions/browser/event_listener_map.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/mojom/event_dispatcher.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace extensions {
namespace {
const char kExt1Id[] = …;
const char kExt2Id[] = …;
const char kEvent1Name[] = …;
const char kEvent2Name[] = …;
const char kURL[] = …;
int64_t GetWorkerVersionId(bool lazy) { … }
int GetWorkerThreadId(bool lazy) { … }
EventListenerConstructor;
class EmptyDelegate : public EventListenerMap::Delegate { … };
class EventListenerMapTest : public ExtensionsTest { … };
class EventListenerMapWithContextTest
: public EventListenerMapTest,
public testing::WithParamInterface<bool > { … };
std::unique_ptr<EventListener> CreateEventListenerForExtension(
const ExtensionId& extension_id,
const std::string& event_name,
content::RenderProcessHost* process,
std::optional<base::Value::Dict> filter) { … }
std::unique_ptr<EventListener> CreateEventListenerForURL(
const GURL& listener_url,
const std::string& event_name,
content::RenderProcessHost* process,
std::optional<base::Value::Dict> filter) { … }
std::unique_ptr<EventListener> CreateEventListenerForExtensionServiceWorker(
const ExtensionId& extension_id,
const std::string& event_name,
content::RenderProcessHost* process,
std::optional<base::Value::Dict> filter) { … }
void EventListenerMapTest::TestUnfilteredEventsGoToAllListeners(
const EventListenerConstructor& constructor) { … }
TEST_F(EventListenerMapTest, UnfilteredEventsGoToAllListenersForExtensions) { … }
TEST_F(EventListenerMapTest, UnfilteredEventsGoToAllListenersForURLs) { … }
TEST_F(EventListenerMapTest,
UnfilteredEventsGoToAllListenersForExtensionServiceWorkers) { … }
TEST_F(EventListenerMapTest, FilteredEventsGoToAllMatchingListeners) { … }
TEST_P(EventListenerMapWithContextTest,
FilteredEventsOnlyGoToMatchingListeners) { … }
TEST_F(EventListenerMapTest, LazyAndUnlazyListenersGetReturned) { … }
void EventListenerMapTest::TestRemovingByProcess(
const EventListenerConstructor& constructor) { … }
TEST_F(EventListenerMapTest, TestRemovingByProcessForExtension) { … }
TEST_F(EventListenerMapTest, TestRemovingByProcessForURL) { … }
TEST_F(EventListenerMapTest, TestRemovingByProcessForExtensionServiceWorker) { … }
void EventListenerMapTest::TestRemovingByListener(
const EventListenerConstructor& constructor) { … }
TEST_F(EventListenerMapTest, TestRemovingByListenerForExtension) { … }
TEST_F(EventListenerMapTest, TestRemovingByListenerForURL) { … }
TEST_F(EventListenerMapTest, TestRemovingByListenerForExtensionServiceWorker) { … }
TEST_P(EventListenerMapWithContextTest, TestLazyDoubleAddIsUndoneByRemove) { … }
TEST_F(EventListenerMapTest, HostSuffixFilterEquality) { … }
TEST_F(EventListenerMapTest, RemoveListenersForExtension) { … }
TEST_P(EventListenerMapWithContextTest, AddExistingFilteredListener) { … }
void EventListenerMapTest::TestAddExistingUnfilteredListener(
const EventListenerConstructor& constructor) { … }
TEST_F(EventListenerMapTest, AddExistingUnfilteredListenerForExtensions) { … }
TEST_F(EventListenerMapTest, AddExistingUnfilteredListenerForURLs) { … }
TEST_F(EventListenerMapTest,
AddExistingUnfilteredListenerForExtensionServiceWorker) { … }
TEST_F(EventListenerMapTest, RemovingRouters) { … }
void EventListenerMapTest::TestHasListenerForEvent(
const EventListenerConstructor& constructor) { … }
TEST_F(EventListenerMapTest, HasListenerForEventForExtension) { … }
TEST_F(EventListenerMapTest, HasListenerForEventForURL) { … }
TEST_F(EventListenerMapTest, HasListenerForEventForExtensionServiceWorker) { … }
TEST_F(EventListenerMapTest, HasListenerForExtension) { … }
TEST_P(EventListenerMapWithContextTest, AddLazyListenersFromPreferences) { … }
TEST_F(EventListenerMapTest, CorruptedExtensionPrefsShouldntCrash) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
}
}