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

Side by Side Diff: chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc

Issue 2908983002: [reland] Bring up BrowserActionInteractiveTest on Mac. (Closed)
Patch Set: still flaky - more robust answer Created 3 years, 6 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/browser/extensions/browser_action_test_util.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "build/build_config.h" 5 #include "build/build_config.h"
6 #include "chrome/browser/extensions/browser_action_test_util.h" 6 #include "chrome/browser/extensions/browser_action_test_util.h"
7 #include "chrome/browser/extensions/extension_action.h" 7 #include "chrome/browser/extensions/extension_action.h"
8 #include "chrome/browser/extensions/extension_action_manager.h" 8 #include "chrome/browser/extensions/extension_action_manager.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_types.h" 22 #include "content/public/browser/notification_types.h"
23 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
24 #include "extensions/browser/extension_system.h" 24 #include "extensions/browser/extension_system.h"
25 #include "extensions/browser/notification_types.h" 25 #include "extensions/browser/notification_types.h"
26 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
27 #include "extensions/common/extension_set.h" 27 #include "extensions/common/extension_set.h"
28 #include "extensions/common/permissions/permissions_data.h" 28 #include "extensions/common/permissions/permissions_data.h"
29 #include "extensions/test/extension_test_message_listener.h" 29 #include "extensions/test/extension_test_message_listener.h"
30 #include "extensions/test/result_catcher.h" 30 #include "extensions/test/result_catcher.h"
31 #include "ui/base/ui_features.h"
31 32
32 #if defined(OS_WIN) 33 #if defined(OS_WIN)
33 #include "ui/views/win/hwnd_util.h" 34 #include "ui/views/win/hwnd_util.h"
34 #endif 35 #endif
35 36
36 namespace extensions { 37 namespace extensions {
37 namespace { 38 namespace {
38 39
39 // chrome.browserAction API tests that interact with the UI in such a way that 40 // chrome.browserAction API tests that interact with the UI in such a way that
40 // they cannot be run concurrently (i.e. openPopup API tests that require the 41 // they cannot be run concurrently (i.e. openPopup API tests that require the
41 // window be focused/active). 42 // window be focused/active).
42 class BrowserActionInteractiveTest : public ExtensionApiTest { 43 class BrowserActionInteractiveTest : public ExtensionApiTest {
43 public: 44 public:
44 BrowserActionInteractiveTest() {} 45 BrowserActionInteractiveTest() {}
45 ~BrowserActionInteractiveTest() override {} 46 ~BrowserActionInteractiveTest() override {}
46 47
48 // BrowserTestBase:
49 void SetUpOnMainThread() override {
50 ExtensionApiTest::SetUpOnMainThread();
51 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
52 }
53
47 protected: 54 protected:
48 // Function to control whether to run popup tests for the current platform. 55 // Function to control whether to run popup tests for the current platform.
49 // These tests require RunExtensionSubtest to work as expected and the browser 56 // These tests require RunExtensionSubtest to work as expected and the browser
50 // window to able to be made active automatically. Returns false for platforms 57 // window to able to be made active automatically. Returns false for platforms
51 // where these conditions are not met. 58 // where these conditions are not met.
52 bool ShouldRunPopupTest() { 59 bool ShouldRunPopupTest() {
53 // TODO(justinlin): http://crbug.com/177163 60 // TODO(justinlin): http://crbug.com/177163
54 #if defined(OS_WIN) && !defined(NDEBUG) 61 #if defined(OS_WIN) && !defined(NDEBUG)
55 return false; 62 return false;
56 #elif defined(OS_MACOSX)
57 // TODO(justinlin): Browser window do not become active on Mac even when
58 // Activate() is called on them. Enable when/if it's possible to fix.
59 return false;
60 #else 63 #else
61 return true; 64 return true;
62 #endif 65 #endif
63 } 66 }
64 67
68 void EnsurePopupActive() {
69 BrowserActionTestUtil test_util(browser());
70 EXPECT_TRUE(test_util.HasPopup());
71 EXPECT_TRUE(test_util.WaitForPopup());
72 EXPECT_TRUE(test_util.HasPopup());
73 }
74
65 // Open an extension popup via the chrome.browserAction.openPopup API. 75 // Open an extension popup via the chrome.browserAction.openPopup API.
66 void OpenExtensionPopupViaAPI() { 76 void OpenPopupViaAPI() {
67 // Setup the notification observer to wait for the popup to finish loading. 77 // Setup the notification observer to wait for the popup to finish loading.
68 content::WindowedNotificationObserver frame_observer( 78 content::WindowedNotificationObserver frame_observer(
69 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 79 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
70 content::NotificationService::AllSources()); 80 content::NotificationService::AllSources());
71 // Show first popup in first window and expect it to have loaded. 81 // Show first popup in first window and expect it to have loaded.
72 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", 82 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup",
73 "open_popup_succeeds.html")) << message_; 83 "open_popup_succeeds.html")) << message_;
74 frame_observer.Wait(); 84 frame_observer.Wait();
85 EnsurePopupActive();
86 }
87
88 // Open an extension popup by clicking the browser action button.
89 void OpenPopupViaToolbar() {
90 content::WindowedNotificationObserver frame_observer(
91 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
92 content::NotificationService::AllSources());
93 BrowserActionTestUtil(browser()).Press(0);
94 frame_observer.Wait();
95 EnsurePopupActive();
96 }
97
98 // Click on the omnibox to close the extension popup.
99 void ClosePopupViaClick() {
75 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup()); 100 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
101 content::WindowedNotificationObserver observer(
102 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
103 content::NotificationService::AllSources());
104
105 #if defined(OS_MACOSX)
106 // ClickOnView() in an inactive window is not robust on Mac. The click does
107 // not guarantee window activation on trybots. So activate explicitly.
108 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
Devlin 2017/05/30 15:12:27 One worry: Extension popups are non-modal and dism
tapted 2017/05/31 10:53:35 Yeah I think the goal of this test step is merely
109 #endif
110
111 ui_test_utils::ClickOnView(browser(), VIEW_ID_OMNIBOX);
112
113 // The window disappears immediately.
114 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
115
116 // Wait for the notification to achieve a consistent state and verify that
117 // the popup was properly torn down.
118 observer.Wait();
119 base::RunLoop().RunUntilIdle();
76 } 120 }
77 }; 121 };
78 122
79 // Tests opening a popup using the chrome.browserAction.openPopup API. This test 123 // Tests opening a popup using the chrome.browserAction.openPopup API. This test
80 // opens a popup in the starting window, closes the popup, creates a new window 124 // opens a popup in the starting window, closes the popup, creates a new window
81 // and opens a popup in the new window. Both popups should succeed in opening. 125 // and opens a popup in the new window. Both popups should succeed in opening.
82 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, TestOpenPopup) { 126 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, TestOpenPopup) {
83 if (!ShouldRunPopupTest()) 127 if (!ShouldRunPopupTest())
84 return; 128 return;
85 129
86 BrowserActionTestUtil browserActionBar(browser()); 130 BrowserActionTestUtil browserActionBar(browser());
87 // Setup extension message listener to wait for javascript to finish running. 131 // Setup extension message listener to wait for javascript to finish running.
88 ExtensionTestMessageListener listener("ready", true); 132 ExtensionTestMessageListener listener("ready", true);
89 { 133 {
90 OpenExtensionPopupViaAPI(); 134 OpenPopupViaAPI();
91 EXPECT_TRUE(browserActionBar.HasPopup()); 135 EXPECT_TRUE(browserActionBar.HasPopup());
92 browserActionBar.HidePopup(); 136 browserActionBar.HidePopup();
93 } 137 }
94 138
95 EXPECT_TRUE(listener.WaitUntilSatisfied()); 139 EXPECT_TRUE(listener.WaitUntilSatisfied());
96 Browser* new_browser = NULL; 140 Browser* new_browser = NULL;
97 { 141 {
98 content::WindowedNotificationObserver frame_observer( 142 content::WindowedNotificationObserver frame_observer(
99 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 143 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
100 content::NotificationService::AllSources()); 144 content::NotificationService::AllSources());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 "browser_action/popup"))); 242 "browser_action/popup")));
199 const Extension* extension = GetSingleLoadedExtension(); 243 const Extension* extension = GetSingleLoadedExtension();
200 ASSERT_TRUE(extension) << message_; 244 ASSERT_TRUE(extension) << message_;
201 245
202 ExtensionTestMessageListener listener("ready", true); 246 ExtensionTestMessageListener listener("ready", true);
203 // Load the test extension which will do nothing except notifyPass() to 247 // Load the test extension which will do nothing except notifyPass() to
204 // return control here. 248 // return control here.
205 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup", 249 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup",
206 "open_popup_fails.html")) << message_; 250 "open_popup_fails.html")) << message_;
207 EXPECT_TRUE(listener.WaitUntilSatisfied()); 251 EXPECT_TRUE(listener.WaitUntilSatisfied());
208 252 OpenPopupViaToolbar();
209 content::WindowedNotificationObserver frame_observer(
210 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
211 content::NotificationService::AllSources());
212 // Open popup in the first extension.
213 BrowserActionTestUtil(browser()).Press(0);
214 frame_observer.Wait();
215 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
216
217 ResultCatcher catcher; 253 ResultCatcher catcher;
218 // Return control to javascript to validate that opening a popup fails now. 254 // Return control to javascript to validate that opening a popup fails now.
219 listener.Reply("show another"); 255 listener.Reply("show another");
220 ASSERT_TRUE(catcher.GetNextResult()) << message_; 256 ASSERT_TRUE(catcher.GetNextResult()) << message_;
221 } 257 }
222 258
223 // Test that openPopup does not grant tab permissions like for browser action 259 // Test that openPopup does not grant tab permissions like for browser action
224 // clicks if the activeTab permission is set. 260 // clicks if the activeTab permission is set.
225 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, 261 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
226 TestOpenPopupDoesNotGrantTabPermissions) { 262 TestOpenPopupDoesNotGrantTabPermissions) {
227 if (!ShouldRunPopupTest()) 263 if (!ShouldRunPopupTest())
228 return; 264 return;
229 265
230 OpenExtensionPopupViaAPI(); 266 OpenPopupViaAPI();
231 ExtensionService* service = extensions::ExtensionSystem::Get( 267 ExtensionService* service = extensions::ExtensionSystem::Get(
232 browser()->profile())->extension_service(); 268 browser()->profile())->extension_service();
233 ASSERT_FALSE( 269 ASSERT_FALSE(
234 service->GetExtensionById(last_loaded_extension_id(), false) 270 service->GetExtensionById(last_loaded_extension_id(), false)
235 ->permissions_data() 271 ->permissions_data()
236 ->HasAPIPermissionForTab( 272 ->HasAPIPermissionForTab(
237 SessionTabHelper::IdForTab( 273 SessionTabHelper::IdForTab(
238 browser()->tab_strip_model()->GetActiveWebContents()), 274 browser()->tab_strip_model()->GetActiveWebContents()),
239 APIPermission::kTab)); 275 APIPermission::kTab));
240 } 276 }
241 277
242 // Test that the extension popup is closed when the browser window is clicked. 278 // Test that the extension popup is closed when the browser window is clicked.
243 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, BrowserClickClosesPopup1) { 279 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, BrowserClickClosesPopup1) {
244 if (!ShouldRunPopupTest()) 280 if (!ShouldRunPopupTest())
245 return; 281 return;
246 282 OpenPopupViaAPI();
247 // Open an extension popup via the chrome.browserAction.openPopup API. 283 ClosePopupViaClick();
248 content::WindowedNotificationObserver frame_observer(
249 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
250 content::NotificationService::AllSources());
251 ASSERT_TRUE(RunExtensionSubtest("browser_action/open_popup",
252 "open_popup_succeeds.html")) << message_;
253 frame_observer.Wait();
254 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
255
256 // Click on the omnibox to close the extension popup.
257 ui_test_utils::ClickOnView(browser(), VIEW_ID_OMNIBOX);
258 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
259 } 284 }
260 285
261 // Test that the extension popup is closed when the browser window is clicked. 286 // Test that the extension popup is closed when the browser window is clicked.
262 #if defined(OS_WIN) 287 #if defined(OS_WIN)
263 // Flaky on Windows: http://crbug.com/639130 288 // Flaky on Windows: http://crbug.com/639130
264 #define MAYBE_BrowserClickClosesPopup2 DISABLED_BrowserClickClosesPopup2 289 #define MAYBE_BrowserClickClosesPopup2 DISABLED_BrowserClickClosesPopup2
265 #else 290 #else
266 #define MAYBE_BrowserClickClosesPopup2 BrowserClickClosesPopup2 291 #define MAYBE_BrowserClickClosesPopup2 BrowserClickClosesPopup2
267 #endif 292 #endif
268 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, 293 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
269 MAYBE_BrowserClickClosesPopup2) { 294 MAYBE_BrowserClickClosesPopup2) {
270 if (!ShouldRunPopupTest()) 295 if (!ShouldRunPopupTest())
271 return; 296 return;
272 297
273 // Load a first extension that can open a popup. 298 // Load a first extension that can open a popup.
274 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 299 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
275 "browser_action/popup"))); 300 "browser_action/popup")));
276 const Extension* extension = GetSingleLoadedExtension(); 301 const Extension* extension = GetSingleLoadedExtension();
277 ASSERT_TRUE(extension) << message_; 302 ASSERT_TRUE(extension) << message_;
278 303 OpenPopupViaToolbar();
279 // Open an extension popup by clicking the browser action button. 304 ClosePopupViaClick();
280 content::WindowedNotificationObserver frame_observer(
281 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
282 content::NotificationService::AllSources());
283 BrowserActionTestUtil(browser()).Press(0);
284 frame_observer.Wait();
285 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
286
287 // Click on the omnibox to close the extension popup.
288 ui_test_utils::ClickOnView(browser(), VIEW_ID_OMNIBOX);
289 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
290 } 305 }
291 306
292 // Test that the extension popup is closed on browser tab switches. 307 // Test that the extension popup is closed on browser tab switches.
293 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, TabSwitchClosesPopup) { 308 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, TabSwitchClosesPopup) {
294 if (!ShouldRunPopupTest()) 309 if (!ShouldRunPopupTest())
295 return; 310 return;
296 311
297 // Add a second tab to the browser and open an extension popup. 312 // Add a second tab to the browser and open an extension popup.
298 chrome::NewTab(browser()); 313 chrome::NewTab(browser());
299 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 314 ASSERT_EQ(2, browser()->tab_strip_model()->count());
300 EXPECT_EQ(browser()->tab_strip_model()->GetWebContentsAt(1), 315 EXPECT_EQ(browser()->tab_strip_model()->GetWebContentsAt(1),
301 browser()->tab_strip_model()->GetActiveWebContents()); 316 browser()->tab_strip_model()->GetActiveWebContents());
302 OpenExtensionPopupViaAPI(); 317 OpenPopupViaAPI();
303 318
304 content::WindowedNotificationObserver observer( 319 content::WindowedNotificationObserver observer(
305 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 320 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
306 content::NotificationService::AllSources()); 321 content::NotificationService::AllSources());
307 // Change active tabs, the extension popup should close. 322 // Change active tabs, the extension popup should close.
308 browser()->tab_strip_model()->ActivateTabAt(0, true); 323 browser()->tab_strip_model()->ActivateTabAt(0, true);
309 observer.Wait(); 324 observer.Wait();
310 325
311 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup()); 326 EXPECT_FALSE(BrowserActionTestUtil(browser()).HasPopup());
312 } 327 }
313 328
314 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, 329 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
315 DeleteBrowserActionWithPopupOpen) { 330 DeleteBrowserActionWithPopupOpen) {
316 if (!ShouldRunPopupTest()) 331 if (!ShouldRunPopupTest())
317 return; 332 return;
318 333
319 // First, we open a popup. 334 // First, we open a popup.
320 OpenExtensionPopupViaAPI(); 335 OpenPopupViaAPI();
321 BrowserActionTestUtil browser_action_test_util(browser()); 336 BrowserActionTestUtil browser_action_test_util(browser());
322 EXPECT_TRUE(browser_action_test_util.HasPopup()); 337 EXPECT_TRUE(browser_action_test_util.HasPopup());
323 338
324 // Then, find the extension that created it. 339 // Then, find the extension that created it.
325 content::WebContents* active_web_contents = 340 content::WebContents* active_web_contents =
326 browser()->tab_strip_model()->GetActiveWebContents(); 341 browser()->tab_strip_model()->GetActiveWebContents();
327 ASSERT_TRUE(active_web_contents); 342 ASSERT_TRUE(active_web_contents);
328 GURL url = active_web_contents->GetLastCommittedURL(); 343 GURL url = active_web_contents->GetLastCommittedURL();
329 const Extension* extension = ExtensionRegistry::Get(browser()->profile())-> 344 const Extension* extension = ExtensionRegistry::Get(browser()->profile())->
330 enabled_extensions().GetExtensionOrAppByURL(url); 345 enabled_extensions().GetExtensionOrAppByURL(url);
331 ASSERT_TRUE(extension); 346 ASSERT_TRUE(extension);
332 347
333 // Finally, uninstall the extension, which causes the view to be deleted and 348 // Finally, uninstall the extension, which causes the view to be deleted and
334 // the popup to go away. This should not crash. 349 // the popup to go away. This should not crash.
335 UninstallExtension(extension->id()); 350 UninstallExtension(extension->id());
336 EXPECT_FALSE(browser_action_test_util.HasPopup()); 351 EXPECT_FALSE(browser_action_test_util.HasPopup());
337 } 352 }
338 353
339 #if defined(TOOLKIT_VIEWS) 354 // BrowserActionTestUtil::InspectPopup() is not implemented for a Cocoa browser.
355 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
356 #define MAYBE_CloseBrowserWithDevTools CloseBrowserWithDevTools
357 #else
358 #define MAYBE_CloseBrowserWithDevTools DISABLED_CloseBrowserWithDevTools
359 #endif
340 // Test closing the browser while inspecting an extension popup with dev tools. 360 // Test closing the browser while inspecting an extension popup with dev tools.
341 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, CloseBrowserWithDevTools) { 361 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
362 MAYBE_CloseBrowserWithDevTools) {
342 if (!ShouldRunPopupTest()) 363 if (!ShouldRunPopupTest())
343 return; 364 return;
344 365
345 // Load a first extension that can open a popup. 366 // Load a first extension that can open a popup.
346 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 367 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
347 "browser_action/popup"))); 368 "browser_action/popup")));
348 const Extension* extension = GetSingleLoadedExtension(); 369 const Extension* extension = GetSingleLoadedExtension();
349 ASSERT_TRUE(extension) << message_; 370 ASSERT_TRUE(extension) << message_;
350 371
351 // Open an extension popup by clicking the browser action button. 372 // Open an extension popup by clicking the browser action button.
352 content::WindowedNotificationObserver frame_observer( 373 content::WindowedNotificationObserver frame_observer(
353 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 374 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
354 content::NotificationService::AllSources()); 375 content::NotificationService::AllSources());
355 BrowserActionTestUtil(browser()).InspectPopup(0); 376 BrowserActionTestUtil(browser()).InspectPopup(0);
356 frame_observer.Wait(); 377 frame_observer.Wait();
357 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup()); 378 EXPECT_TRUE(BrowserActionTestUtil(browser()).HasPopup());
358 379
359 // Close the browser window, this should not cause a crash. 380 // Close the browser window, this should not cause a crash.
360 chrome::CloseWindow(browser()); 381 chrome::CloseWindow(browser());
361 } 382 }
362 #endif // TOOLKIT_VIEWS
363 383
364 #if defined(OS_WIN) 384 #if defined(OS_WIN)
365 // Test that forcibly closing the browser and popup HWND does not cause a crash. 385 // Test that forcibly closing the browser and popup HWND does not cause a crash.
366 // http://crbug.com/400646 386 // http://crbug.com/400646
367 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, 387 IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
368 DISABLED_DestroyHWNDDoesNotCrash) { 388 DISABLED_DestroyHWNDDoesNotCrash) {
369 if (!ShouldRunPopupTest()) 389 if (!ShouldRunPopupTest())
370 return; 390 return;
371 391
372 OpenExtensionPopupViaAPI(); 392 OpenPopupViaAPI();
373 BrowserActionTestUtil test_util(browser()); 393 BrowserActionTestUtil test_util(browser());
374 const gfx::NativeView view = test_util.GetPopupNativeView(); 394 const gfx::NativeView view = test_util.GetPopupNativeView();
375 EXPECT_NE(static_cast<gfx::NativeView>(NULL), view); 395 EXPECT_NE(static_cast<gfx::NativeView>(NULL), view);
376 const HWND hwnd = views::HWNDForNativeView(view); 396 const HWND hwnd = views::HWNDForNativeView(view);
377 EXPECT_EQ(hwnd, 397 EXPECT_EQ(hwnd,
378 views::HWNDForNativeView(browser()->window()->GetNativeWindow())); 398 views::HWNDForNativeView(browser()->window()->GetNativeWindow()));
379 EXPECT_EQ(TRUE, ::IsWindow(hwnd)); 399 EXPECT_EQ(TRUE, ::IsWindow(hwnd));
380 400
381 // Create a new browser window to prevent the message loop from terminating. 401 // Create a new browser window to prevent the message loop from terminating.
382 browser()->OpenURL(content::OpenURLParams(GURL("about:"), content::Referrer(), 402 browser()->OpenURL(content::OpenURLParams(GURL("about:"), content::Referrer(),
383 WindowOpenDisposition::NEW_WINDOW, 403 WindowOpenDisposition::NEW_WINDOW,
384 ui::PAGE_TRANSITION_TYPED, false)); 404 ui::PAGE_TRANSITION_TYPED, false));
385 405
386 // Forcibly closing the browser HWND should not cause a crash. 406 // Forcibly closing the browser HWND should not cause a crash.
387 EXPECT_EQ(TRUE, ::CloseWindow(hwnd)); 407 EXPECT_EQ(TRUE, ::CloseWindow(hwnd));
388 EXPECT_EQ(TRUE, ::DestroyWindow(hwnd)); 408 EXPECT_EQ(TRUE, ::DestroyWindow(hwnd));
389 EXPECT_EQ(FALSE, ::IsWindow(hwnd)); 409 EXPECT_EQ(FALSE, ::IsWindow(hwnd));
390 } 410 }
391 #endif // OS_WIN 411 #endif // OS_WIN
392 412
393 } // namespace 413 } // namespace
394 } // namespace extensions 414 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/browser_action_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698