Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: chrome/browser/extensions/events_apitest.cc

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/api/webview_tag.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/events_apitest.cc
diff --git a/chrome/browser/extensions/events_apitest.cc b/chrome/browser/extensions/events_apitest.cc
index da6bf4091a6cf3a1cc3cef36e53b88380902fc5e..3e0f4bbbcba21856cdf1f0e92d1386c0c305dcd5 100644
--- a/chrome/browser/extensions/events_apitest.cc
+++ b/chrome/browser/extensions/events_apitest.cc
@@ -75,6 +75,39 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, EventsAreUnregistered) {
event_router->ExtensionHasEventListener(id, "webNavigation.onCompleted"));
}
+// Test that listeners for webview-related events are not stored (even for lazy
+// contexts). See crbug.com/736381.
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebViewEventRegistration) {
+ ASSERT_TRUE(RunPlatformAppTest("events/webview_events")) << message_;
+ EventRouter* event_router = EventRouter::Get(profile());
+ // We should not register lazy listeners for any webview-related events.
+ EXPECT_FALSE(
+ event_router->HasLazyEventListenerForTesting("webViewInternal.onClose"));
+ EXPECT_FALSE(event_router->HasLazyEventListenerForTesting("webview.close"));
+ EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
+ "chromeWebViewInternal.onContextMenuShow"));
+ EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
+ "chromeWebViewInternal.onClicked"));
+ EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
+ "webViewInternal.contextMenus"));
+ // Chrome webview context menu events also use a "subevent" pattern, so we
+ // need to look for suffixed events. These seem to always be suffixed with
+ // "3" and "4", but look for the first 10 to be a bit safer.
+ for (int i = 0; i < 10; ++i) {
+ EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
+ base::StringPrintf("chromeWebViewInternal.onClicked/%d", i)));
+ EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
+ base::StringPrintf("chromeWebViewInternal.onContextMenuShow/%d", i)));
+ EXPECT_FALSE(
+ event_router->HasLazyEventListenerForTesting(base::StringPrintf(
+ "webViewInternal.declarativeWebRequest.onMessage/%d", i)));
+ }
+
+ // Sanity check: app.runtime.onLaunched should have a lazy listener.
+ EXPECT_TRUE(
+ event_router->HasLazyEventListenerForTesting("app.runtime.onLaunched"));
+}
+
class EventsApiTest : public ExtensionApiTest {
public:
EventsApiTest() {}
« no previous file with comments | « no previous file | chrome/common/extensions/api/webview_tag.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698