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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/api/webview_tag.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "chrome/browser/extensions/chrome_extension_test_notification_observer. h" 7 #include "chrome/browser/extensions/chrome_extension_test_notification_observer. h"
8 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" 8 #include "chrome/browser/extensions/chrome_extensions_browser_client.h"
9 #include "chrome/browser/extensions/chrome_test_extension_loader.h" 9 #include "chrome/browser/extensions/chrome_test_extension_loader.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 EXPECT_FALSE(event_router->ExtensionHasEventListener( 68 EXPECT_FALSE(event_router->ExtensionHasEventListener(
69 id, "webNavigation.onBeforeNavigate")); 69 id, "webNavigation.onBeforeNavigate"));
70 EXPECT_FALSE( 70 EXPECT_FALSE(
71 event_router->ExtensionHasEventListener(id, "webNavigation.onCommitted")); 71 event_router->ExtensionHasEventListener(id, "webNavigation.onCommitted"));
72 EXPECT_FALSE(event_router->ExtensionHasEventListener( 72 EXPECT_FALSE(event_router->ExtensionHasEventListener(
73 id, "webNavigation.onDOMContentLoaded")); 73 id, "webNavigation.onDOMContentLoaded"));
74 EXPECT_FALSE( 74 EXPECT_FALSE(
75 event_router->ExtensionHasEventListener(id, "webNavigation.onCompleted")); 75 event_router->ExtensionHasEventListener(id, "webNavigation.onCompleted"));
76 } 76 }
77 77
78 // Test that listeners for webview-related events are not stored (even for lazy
79 // contexts). See crbug.com/736381.
80 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebViewEventRegistration) {
81 ASSERT_TRUE(RunPlatformAppTest("events/webview_events")) << message_;
82 EventRouter* event_router = EventRouter::Get(profile());
83 // We should not register lazy listeners for any webview-related events.
84 EXPECT_FALSE(
85 event_router->HasLazyEventListenerForTesting("webViewInternal.onClose"));
86 EXPECT_FALSE(event_router->HasLazyEventListenerForTesting("webview.close"));
87 EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
88 "chromeWebViewInternal.onContextMenuShow"));
89 EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
90 "chromeWebViewInternal.onClicked"));
91 EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
92 "webViewInternal.contextMenus"));
93 // Chrome webview context menu events also use a "subevent" pattern, so we
94 // need to look for suffixed events. These seem to always be suffixed with
95 // "3" and "4", but look for the first 10 to be a bit safer.
96 for (int i = 0; i < 10; ++i) {
97 EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
98 base::StringPrintf("chromeWebViewInternal.onClicked/%d", i)));
99 EXPECT_FALSE(event_router->HasLazyEventListenerForTesting(
100 base::StringPrintf("chromeWebViewInternal.onContextMenuShow/%d", i)));
101 EXPECT_FALSE(
102 event_router->HasLazyEventListenerForTesting(base::StringPrintf(
103 "webViewInternal.declarativeWebRequest.onMessage/%d", i)));
104 }
105
106 // Sanity check: app.runtime.onLaunched should have a lazy listener.
107 EXPECT_TRUE(
108 event_router->HasLazyEventListenerForTesting("app.runtime.onLaunched"));
109 }
110
78 class EventsApiTest : public ExtensionApiTest { 111 class EventsApiTest : public ExtensionApiTest {
79 public: 112 public:
80 EventsApiTest() {} 113 EventsApiTest() {}
81 114
82 protected: 115 protected:
83 void SetUpOnMainThread() override { 116 void SetUpOnMainThread() override {
84 ExtensionApiTest::SetUpOnMainThread(); 117 ExtensionApiTest::SetUpOnMainThread();
85 EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 118 EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
86 } 119 }
87 120
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 EXPECT_TRUE(observed_extension_names().count("chrome updates listener")); 339 EXPECT_TRUE(observed_extension_names().count("chrome updates listener"));
307 EXPECT_FALSE(observed_extension_names().count("chrome updates non listener")); 340 EXPECT_FALSE(observed_extension_names().count("chrome updates non listener"));
308 341
309 EXPECT_TRUE(updates_listener()->WaitUntilSatisfied()); 342 EXPECT_TRUE(updates_listener()->WaitUntilSatisfied());
310 content::RunAllPendingInMessageLoop(); 343 content::RunAllPendingInMessageLoop();
311 content::RunAllBlockingPoolTasksUntilIdle(); 344 content::RunAllBlockingPoolTasksUntilIdle();
312 EXPECT_FALSE(failure_listener()->was_satisfied()); 345 EXPECT_FALSE(failure_listener()->was_satisfied());
313 } 346 }
314 347
315 } // namespace extensions 348 } // namespace extensions
OLDNEW
« 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