Commit a80e4d7d authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

[Extensions] Extensively expand EventListenerMap/EventRouter tests for workers.

This CL primarily expands EventListenerMap tests to account for
service workers. It does so by parameterizing EventListenerMapTest
with service worker / non-service worker param.

Bug: None
Change-Id: I11a657d1b5d9293d73c1c6546e81bede36319ee8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247548
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779195}
parent 57bdd8d3
......@@ -91,6 +91,19 @@ std::unique_ptr<EventListener> CreateEventListenerForURL(
std::move(filter));
}
std::unique_ptr<EventListener> CreateEventListenerForExtensionServiceWorker(
const std::string& extension_id,
int64_t service_worker_version_id,
int worker_thread_id,
const std::string& event_name,
content::RenderProcessHost* process,
std::unique_ptr<base::DictionaryValue> filter) {
return EventListener::ForExtensionServiceWorker(
event_name, extension_id, process,
Extension::GetBaseURLFromExtensionId(extension_id),
service_worker_version_id, worker_thread_id, std::move(filter));
}
// Creates an extension. If |component| is true, it is created as a component
// extension. If |persistent| is true, it is created with a persistent
// background page; otherwise it is created with an event page.
......@@ -314,6 +327,13 @@ TEST_F(EventRouterTest, EventRouterObserverForURLs) {
&CreateEventListenerForURL, GURL("http://google.com/path")));
}
TEST_F(EventRouterTest, EventRouterObserverForServiceWorkers) {
RunEventRouterObserverTest(base::BindRepeating(
&CreateEventListenerForExtensionServiceWorker, "extension_id",
// Dummy version_id and thread_id.
99, 199));
}
TEST_F(EventRouterTest, TestReportEvent) {
EventRouter router(browser_context(), nullptr);
scoped_refptr<const Extension> normal = ExtensionBuilder("Test").Build();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment