OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 return ASCIIToUTF16(kSecondPageTitle); | 2257 return ASCIIToUTF16(kSecondPageTitle); |
2258 } | 2258 } |
2259 | 2259 |
2260 // Loads our test page and simulates a single click using the supplied button | 2260 // Loads our test page and simulates a single click using the supplied button |
2261 // and modifiers. The click will cause either a navigation or the creation of | 2261 // and modifiers. The click will cause either a navigation or the creation of |
2262 // a new window or foreground or background tab. We verify that the expected | 2262 // a new window or foreground or background tab. We verify that the expected |
2263 // disposition occurs. | 2263 // disposition occurs. |
2264 void RunTest(Browser* browser, | 2264 void RunTest(Browser* browser, |
2265 const GURL& url, | 2265 const GURL& url, |
2266 int modifiers, | 2266 int modifiers, |
2267 WebKit::WebMouseEvent::Button button, | 2267 blink::WebMouseEvent::Button button, |
2268 WindowOpenDisposition disposition) { | 2268 WindowOpenDisposition disposition) { |
2269 ui_test_utils::NavigateToURL(browser, url); | 2269 ui_test_utils::NavigateToURL(browser, url); |
2270 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), | 2270 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), |
2271 browser->host_desktop_type())); | 2271 browser->host_desktop_type())); |
2272 EXPECT_EQ(1, browser->tab_strip_model()->count()); | 2272 EXPECT_EQ(1, browser->tab_strip_model()->count()); |
2273 content::WebContents* web_contents = | 2273 content::WebContents* web_contents = |
2274 browser->tab_strip_model()->GetActiveWebContents(); | 2274 browser->tab_strip_model()->GetActiveWebContents(); |
2275 EXPECT_EQ(url, web_contents->GetURL()); | 2275 EXPECT_EQ(url, web_contents->GetURL()); |
2276 | 2276 |
2277 if (disposition == CURRENT_TAB) { | 2277 if (disposition == CURRENT_TAB) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 } | 2313 } |
2314 | 2314 |
2315 private: | 2315 private: |
2316 DISALLOW_COPY_AND_ASSIGN(ClickModifierTest); | 2316 DISALLOW_COPY_AND_ASSIGN(ClickModifierTest); |
2317 }; | 2317 }; |
2318 | 2318 |
2319 // Tests for clicking on elements with handlers that run window.open. | 2319 // Tests for clicking on elements with handlers that run window.open. |
2320 | 2320 |
2321 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenBasicClickTest) { | 2321 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenBasicClickTest) { |
2322 int modifiers = 0; | 2322 int modifiers = 0; |
2323 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2323 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2324 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2324 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2325 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); | 2325 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); |
2326 } | 2326 } |
2327 | 2327 |
2328 // TODO(ericu): Alt-click behavior on window.open is platform-dependent and not | 2328 // TODO(ericu): Alt-click behavior on window.open is platform-dependent and not |
2329 // well defined. Should we add tests so we know if it changes? | 2329 // well defined. Should we add tests so we know if it changes? |
2330 | 2330 |
2331 // Shift-clicks open in a new window. | 2331 // Shift-clicks open in a new window. |
2332 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftClickTest) { | 2332 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftClickTest) { |
2333 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2333 int modifiers = blink::WebInputEvent::ShiftKey; |
2334 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2334 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2335 WindowOpenDisposition disposition = NEW_WINDOW; | 2335 WindowOpenDisposition disposition = NEW_WINDOW; |
2336 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); | 2336 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); |
2337 } | 2337 } |
2338 | 2338 |
2339 // Control-clicks open in a background tab. | 2339 // Control-clicks open in a background tab. |
2340 // On OSX meta [the command key] takes the place of control. | 2340 // On OSX meta [the command key] takes the place of control. |
2341 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlClickTest) { | 2341 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlClickTest) { |
2342 #if defined(OS_MACOSX) | 2342 #if defined(OS_MACOSX) |
2343 int modifiers = WebKit::WebInputEvent::MetaKey; | 2343 int modifiers = blink::WebInputEvent::MetaKey; |
2344 #else | 2344 #else |
2345 int modifiers = WebKit::WebInputEvent::ControlKey; | 2345 int modifiers = blink::WebInputEvent::ControlKey; |
2346 #endif | 2346 #endif |
2347 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2347 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2348 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 2348 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
2349 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); | 2349 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); |
2350 } | 2350 } |
2351 | 2351 |
2352 // Control-shift-clicks open in a foreground tab. | 2352 // Control-shift-clicks open in a foreground tab. |
2353 // On OSX meta [the command key] takes the place of control. | 2353 // On OSX meta [the command key] takes the place of control. |
2354 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) { | 2354 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenControlShiftClickTest) { |
2355 #if defined(OS_MACOSX) | 2355 #if defined(OS_MACOSX) |
2356 int modifiers = WebKit::WebInputEvent::MetaKey; | 2356 int modifiers = blink::WebInputEvent::MetaKey; |
2357 #else | 2357 #else |
2358 int modifiers = WebKit::WebInputEvent::ControlKey; | 2358 int modifiers = blink::WebInputEvent::ControlKey; |
2359 #endif | 2359 #endif |
2360 modifiers |= WebKit::WebInputEvent::ShiftKey; | 2360 modifiers |= blink::WebInputEvent::ShiftKey; |
2361 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2361 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2362 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2362 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2363 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); | 2363 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); |
2364 } | 2364 } |
2365 | 2365 |
2366 // Middle-clicks open in a background tab. | 2366 // Middle-clicks open in a background tab. |
2367 // TODO(linux_aura) http://crbug.com/163931 | 2367 // TODO(linux_aura) http://crbug.com/163931 |
2368 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 2368 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
2369 #define MAYBE_WindowOpenMiddleClickTest DISABLED_WindowOpenMiddleClickTest | 2369 #define MAYBE_WindowOpenMiddleClickTest DISABLED_WindowOpenMiddleClickTest |
2370 #else | 2370 #else |
2371 #define MAYBE_WindowOpenMiddleClickTest WindowOpenMiddleClickTest | 2371 #define MAYBE_WindowOpenMiddleClickTest WindowOpenMiddleClickTest |
2372 #endif | 2372 #endif |
2373 IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_WindowOpenMiddleClickTest) { | 2373 IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_WindowOpenMiddleClickTest) { |
2374 int modifiers = 0; | 2374 int modifiers = 0; |
2375 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2375 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; |
2376 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 2376 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
2377 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); | 2377 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); |
2378 } | 2378 } |
2379 | 2379 |
2380 // Shift-middle-clicks open in a foreground tab. | 2380 // Shift-middle-clicks open in a foreground tab. |
2381 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftMiddleClickTest) { | 2381 IN_PROC_BROWSER_TEST_F(ClickModifierTest, WindowOpenShiftMiddleClickTest) { |
2382 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2382 int modifiers = blink::WebInputEvent::ShiftKey; |
2383 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2383 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; |
2384 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2384 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2385 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); | 2385 RunTest(browser(), GetWindowOpenURL(), modifiers, button, disposition); |
2386 } | 2386 } |
2387 | 2387 |
2388 // Tests for clicking on normal links. | 2388 // Tests for clicking on normal links. |
2389 | 2389 |
2390 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) { | 2390 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefBasicClickTest) { |
2391 int modifiers = 0; | 2391 int modifiers = 0; |
2392 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2392 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2393 WindowOpenDisposition disposition = CURRENT_TAB; | 2393 WindowOpenDisposition disposition = CURRENT_TAB; |
2394 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2394 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2395 } | 2395 } |
2396 | 2396 |
2397 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well | 2397 // TODO(ericu): Alt-click behavior on links is platform-dependent and not well |
2398 // defined. Should we add tests so we know if it changes? | 2398 // defined. Should we add tests so we know if it changes? |
2399 | 2399 |
2400 // Shift-clicks open in a new window. | 2400 // Shift-clicks open in a new window. |
2401 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) { | 2401 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftClickTest) { |
2402 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2402 int modifiers = blink::WebInputEvent::ShiftKey; |
2403 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2403 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2404 WindowOpenDisposition disposition = NEW_WINDOW; | 2404 WindowOpenDisposition disposition = NEW_WINDOW; |
2405 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2405 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2406 } | 2406 } |
2407 | 2407 |
2408 // Control-clicks open in a background tab. | 2408 // Control-clicks open in a background tab. |
2409 // On OSX meta [the command key] takes the place of control. | 2409 // On OSX meta [the command key] takes the place of control. |
2410 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) { | 2410 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlClickTest) { |
2411 #if defined(OS_MACOSX) | 2411 #if defined(OS_MACOSX) |
2412 int modifiers = WebKit::WebInputEvent::MetaKey; | 2412 int modifiers = blink::WebInputEvent::MetaKey; |
2413 #else | 2413 #else |
2414 int modifiers = WebKit::WebInputEvent::ControlKey; | 2414 int modifiers = blink::WebInputEvent::ControlKey; |
2415 #endif | 2415 #endif |
2416 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2416 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2417 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 2417 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
2418 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2418 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2419 } | 2419 } |
2420 | 2420 |
2421 // Control-shift-clicks open in a foreground tab. | 2421 // Control-shift-clicks open in a foreground tab. |
2422 // On OSX meta [the command key] takes the place of control. | 2422 // On OSX meta [the command key] takes the place of control. |
2423 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlShiftClickTest) { | 2423 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefControlShiftClickTest) { |
2424 #if defined(OS_MACOSX) | 2424 #if defined(OS_MACOSX) |
2425 int modifiers = WebKit::WebInputEvent::MetaKey; | 2425 int modifiers = blink::WebInputEvent::MetaKey; |
2426 #else | 2426 #else |
2427 int modifiers = WebKit::WebInputEvent::ControlKey; | 2427 int modifiers = blink::WebInputEvent::ControlKey; |
2428 #endif | 2428 #endif |
2429 modifiers |= WebKit::WebInputEvent::ShiftKey; | 2429 modifiers |= blink::WebInputEvent::ShiftKey; |
2430 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonLeft; | 2430 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonLeft; |
2431 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2431 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2432 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2432 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2433 } | 2433 } |
2434 | 2434 |
2435 // Middle-clicks open in a background tab. | 2435 // Middle-clicks open in a background tab. |
2436 // TODO(linux_aura) http://crbug.com/163931 | 2436 // TODO(linux_aura) http://crbug.com/163931 |
2437 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 2437 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
2438 #define MAYBE_HrefMiddleClickTest DISABLED_HrefMiddleClickTest | 2438 #define MAYBE_HrefMiddleClickTest DISABLED_HrefMiddleClickTest |
2439 #else | 2439 #else |
2440 #define MAYBE_HrefMiddleClickTest HrefMiddleClickTest | 2440 #define MAYBE_HrefMiddleClickTest HrefMiddleClickTest |
2441 #endif | 2441 #endif |
2442 IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_HrefMiddleClickTest) { | 2442 IN_PROC_BROWSER_TEST_F(ClickModifierTest, MAYBE_HrefMiddleClickTest) { |
2443 int modifiers = 0; | 2443 int modifiers = 0; |
2444 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2444 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; |
2445 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; | 2445 WindowOpenDisposition disposition = NEW_BACKGROUND_TAB; |
2446 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2446 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2447 } | 2447 } |
2448 | 2448 |
2449 // Shift-middle-clicks open in a foreground tab. | 2449 // Shift-middle-clicks open in a foreground tab. |
2450 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 2450 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
2451 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2451 int modifiers = blink::WebInputEvent::ShiftKey; |
2452 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2452 blink::WebMouseEvent::Button button = blink::WebMouseEvent::ButtonMiddle; |
2453 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2453 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
2454 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2454 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
2455 } | 2455 } |
2456 | 2456 |
2457 // TODO(sail): enable this for MAC when | 2457 // TODO(sail): enable this for MAC when |
2458 // BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar | 2458 // BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar |
2459 // is fixed. | 2459 // is fixed. |
2460 #if defined(OS_MACOSX) | 2460 #if defined(OS_MACOSX) |
2461 #define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView | 2461 #define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView |
2462 #else | 2462 #else |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2550 exp_commit_size.Enlarge(wcv_resize_insets.width(), | 2550 exp_commit_size.Enlarge(wcv_resize_insets.width(), |
2551 wcv_resize_insets.height() + height_inset); | 2551 wcv_resize_insets.height() + height_inset); |
2552 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2552 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
2553 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2553 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
2554 // Sizes of RenderWidgetHostView and WebContentsView before and after | 2554 // Sizes of RenderWidgetHostView and WebContentsView before and after |
2555 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. | 2555 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. |
2556 EXPECT_EQ(rwhv_commit_size2, | 2556 EXPECT_EQ(rwhv_commit_size2, |
2557 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2557 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
2558 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); | 2558 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); |
2559 } | 2559 } |
OLD | NEW |