Chromium Code Reviews| Index: chrome/browser/extensions/events_apitest.cc |
| diff --git a/chrome/browser/extensions/events_apitest.cc b/chrome/browser/extensions/events_apitest.cc |
| index 3420022dc8b3ba664a153583b7ed8d65c89ae699..5fec2efa8891ade2a7bf242f0e90079f5dfd6f0e 100644 |
| --- a/chrome/browser/extensions/events_apitest.cc |
| +++ b/chrome/browser/extensions/events_apitest.cc |
| @@ -4,6 +4,44 @@ |
| #include "chrome/browser/extensions/extension_apitest.h" |
| +#include "extensions/browser/event_router.h" |
| +#include "extensions/browser/extension_registry.h" |
| + |
| +using extensions::EventRouter; |
|
Devlin
2015/04/10 18:10:39
Can't we just shove this whole file into the exten
not at google - send to devlin
2015/04/10 18:39:01
Sure.
|
| +using extensions::Extension; |
| +using extensions::ExtensionRegistry; |
| + |
| IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Events) { |
| ASSERT_TRUE(RunExtensionTest("events")) << message_; |
| } |
| + |
| +// Tests that events are unregistered when an extension page shuts down. |
| +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, EventsAreUnregistered) { |
|
Devlin
2015/04/10 18:10:39
I trust this test fails without the rest of your p
not at google - send to devlin
2015/04/10 18:39:01
The test passes without my patch, as it should - t
|
| + // In this test, page1.html registers for a number of events, then navigates |
| + // to page2.html, which should unregister those events. page2.html notifies |
| + // pass, by which point the event should have been unregistered. |
| + EventRouter* event_router = EventRouter::Get(profile()); |
| + ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| + |
| + const char* test_extension_name = "events_are_unregistered"; |
|
Devlin
2015/04/10 18:10:39
nit: may as well make this a std::string, since it
not at google - send to devlin
2015/04/10 18:39:01
If you insist.
Plus I like the look of "const cha
|
| + ASSERT_TRUE(RunExtensionSubtest(test_extension_name, "page1.html")) |
| + << message_; |
| + |
| + // Find the extension we just installed by looking for the path. |
| + const Extension* extension = |
| + GetExtensionByPath(registry->enabled_extensions(), |
| + test_data_dir_.AppendASCII(test_extension_name)); |
| + ASSERT_TRUE(extension); |
| + std::string id = extension->id(); |
| + |
| + // The page has closed, so no matter what all events are no longer listened |
| + // to. |
| + EXPECT_FALSE( |
| + event_router->ExtensionHasEventListener(id, "browserAction.onClicked")); |
| + EXPECT_FALSE( |
| + event_router->ExtensionHasEventListener(id, "runtime.onStartup")); |
| + EXPECT_FALSE( |
| + event_router->ExtensionHasEventListener(id, "runtime.onSuspend")); |
| + EXPECT_FALSE( |
| + event_router->ExtensionHasEventListener(id, "runtime.onInstalled")); |
| +} |