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 <list> | 5 #include <list> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chrome_browser_main.h" | 14 #include "chrome/browser/chrome_browser_main.h" |
15 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 15 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
16 #include "chrome/browser/chrome_content_browser_client.h" | 16 #include "chrome/browser/chrome_content_browser_client.h" |
17 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 17 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
18 #include "chrome/browser/extensions/extension_apitest.h" | 18 #include "chrome/browser/extensions/extension_apitest.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 22 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
23 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 23 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/browser/ui/browser_tabstrip.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
32 #include "content/public/browser/resource_controller.h" | 32 #include "content/public/browser/resource_controller.h" |
33 #include "content/public/browser/resource_dispatcher_host.h" | 33 #include "content/public/browser/resource_dispatcher_host.h" |
34 #include "content/public/browser/resource_throttle.h" | 34 #include "content/public/browser/resource_throttle.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, | 407 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, |
408 DISABLED_ServerRedirectSingleProcess) { | 408 DISABLED_ServerRedirectSingleProcess) { |
409 // Set max renderers to 1 to force running out of processes. | 409 // Set max renderers to 1 to force running out of processes. |
410 content::RenderProcessHost::SetMaxRendererProcessCount(1); | 410 content::RenderProcessHost::SetMaxRendererProcessCount(1); |
411 | 411 |
412 // Wait for the extension to set itself up and return control to us. | 412 // Wait for the extension to set itself up and return control to us. |
413 ASSERT_TRUE(RunExtensionSubtest( | 413 ASSERT_TRUE(RunExtensionSubtest( |
414 "webnavigation", "test_serverRedirectSingleProcess.html")) | 414 "webnavigation", "test_serverRedirectSingleProcess.html")) |
415 << message_; | 415 << message_; |
416 | 416 |
417 WebContents* tab = chrome::GetActiveWebContents(browser()); | 417 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
418 content::WaitForLoadStop(tab); | 418 content::WaitForLoadStop(tab); |
419 | 419 |
420 ResultCatcher catcher; | 420 ResultCatcher catcher; |
421 GURL url(base::StringPrintf( | 421 GURL url(base::StringPrintf( |
422 "http://www.a.com:%d/" | 422 "http://www.a.com:%d/" |
423 "files/extensions/api_test/webnavigation/serverRedirect/a.html", | 423 "files/extensions/api_test/webnavigation/serverRedirect/a.html", |
424 test_server()->host_port_pair().port())); | 424 test_server()->host_port_pair().port())); |
425 | 425 |
426 ui_test_utils::NavigateToURL(browser(), url); | 426 ui_test_utils::NavigateToURL(browser(), url); |
427 | 427 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) { | 475 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, FilteredTest) { |
476 ASSERT_TRUE( | 476 ASSERT_TRUE( |
477 RunExtensionSubtest("webnavigation", "test_filtered.html")) << message_; | 477 RunExtensionSubtest("webnavigation", "test_filtered.html")) << message_; |
478 } | 478 } |
479 | 479 |
480 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) { | 480 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) { |
481 // Wait for the extension to set itself up and return control to us. | 481 // Wait for the extension to set itself up and return control to us. |
482 ASSERT_TRUE( | 482 ASSERT_TRUE( |
483 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; | 483 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; |
484 | 484 |
485 WebContents* tab = chrome::GetActiveWebContents(browser()); | 485 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
486 content::WaitForLoadStop(tab); | 486 content::WaitForLoadStop(tab); |
487 | 487 |
488 ResultCatcher catcher; | 488 ResultCatcher catcher; |
489 | 489 |
490 ExtensionService* service = extensions::ExtensionSystem::Get( | 490 ExtensionService* service = extensions::ExtensionSystem::Get( |
491 browser()->profile())->extension_service(); | 491 browser()->profile())->extension_service(); |
492 const extensions::Extension* extension = | 492 const extensions::Extension* extension = |
493 service->GetExtensionById(last_loaded_extension_id_, false); | 493 service->GetExtensionById(last_loaded_extension_id_, false); |
494 GURL url = extension->GetResourceURL("userAction/a.html"); | 494 GURL url = extension->GetResourceURL("userAction/a.html"); |
495 | 495 |
(...skipping 13 matching lines...) Expand all Loading... |
509 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 509 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
510 | 510 |
511 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 511 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
512 } | 512 } |
513 | 513 |
514 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) { | 514 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) { |
515 // Wait for the extension to set itself up and return control to us. | 515 // Wait for the extension to set itself up and return control to us. |
516 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) | 516 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) |
517 << message_; | 517 << message_; |
518 | 518 |
519 WebContents* tab = chrome::GetActiveWebContents(browser()); | 519 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
520 content::WaitForLoadStop(tab); | 520 content::WaitForLoadStop(tab); |
521 | 521 |
522 ResultCatcher catcher; | 522 ResultCatcher catcher; |
523 | 523 |
524 ExtensionService* service = extensions::ExtensionSystem::Get( | 524 ExtensionService* service = extensions::ExtensionSystem::Get( |
525 browser()->profile())->extension_service(); | 525 browser()->profile())->extension_service(); |
526 const extensions::Extension* extension = | 526 const extensions::Extension* extension = |
527 service->GetExtensionById(last_loaded_extension_id_, false); | 527 service->GetExtensionById(last_loaded_extension_id_, false); |
528 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); | 528 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); |
529 | 529 |
(...skipping 11 matching lines...) Expand all Loading... |
541 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 541 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
542 | 542 |
543 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 543 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
544 } | 544 } |
545 | 545 |
546 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlank) { | 546 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, TargetBlank) { |
547 // Wait for the extension to set itself up and return control to us. | 547 // Wait for the extension to set itself up and return control to us. |
548 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_targetBlank.html")) | 548 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_targetBlank.html")) |
549 << message_; | 549 << message_; |
550 | 550 |
551 WebContents* tab = chrome::GetActiveWebContents(browser()); | 551 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
552 content::WaitForLoadStop(tab); | 552 content::WaitForLoadStop(tab); |
553 | 553 |
554 ResultCatcher catcher; | 554 ResultCatcher catcher; |
555 | 555 |
556 GURL url = test_server()->GetURL( | 556 GURL url = test_server()->GetURL( |
557 "files/extensions/api_test/webnavigation/targetBlank/a.html"); | 557 "files/extensions/api_test/webnavigation/targetBlank/a.html"); |
558 | 558 |
559 chrome::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK); | 559 chrome::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK); |
560 ui_test_utils::NavigateToURL(¶ms); | 560 ui_test_utils::NavigateToURL(¶ms); |
561 | 561 |
(...skipping 18 matching lines...) Expand all Loading... |
580 "webnavigation", "test_targetBlank.html", | 580 "webnavigation", "test_targetBlank.html", |
581 ExtensionApiTest::kFlagEnableIncognito)) << message_; | 581 ExtensionApiTest::kFlagEnableIncognito)) << message_; |
582 | 582 |
583 ResultCatcher catcher; | 583 ResultCatcher catcher; |
584 | 584 |
585 GURL url = test_server()->GetURL( | 585 GURL url = test_server()->GetURL( |
586 "files/extensions/api_test/webnavigation/targetBlank/a.html"); | 586 "files/extensions/api_test/webnavigation/targetBlank/a.html"); |
587 | 587 |
588 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 588 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
589 browser()->profile(), url); | 589 browser()->profile(), url); |
590 WebContents* tab = chrome::GetActiveWebContents(otr_browser); | 590 WebContents* tab = otr_browser->tab_strip_model()->GetActiveWebContents(); |
591 | 591 |
592 // There's a link with target=_blank on a.html. Click on it to open it in a | 592 // There's a link with target=_blank on a.html. Click on it to open it in a |
593 // new tab. | 593 // new tab. |
594 WebKit::WebMouseEvent mouse_event; | 594 WebKit::WebMouseEvent mouse_event; |
595 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 595 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
596 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 596 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
597 mouse_event.x = 7; | 597 mouse_event.x = 7; |
598 mouse_event.y = 7; | 598 mouse_event.y = 7; |
599 mouse_event.clickCount = 1; | 599 mouse_event.clickCount = 1; |
600 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 600 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 test_server()->GetURL("test6"), | 690 test_server()->GetURL("test6"), |
691 "updateHistory()", | 691 "updateHistory()", |
692 extension->GetResourceURL("crossProcess/empty.html")); | 692 extension->GetResourceURL("crossProcess/empty.html")); |
693 | 693 |
694 ASSERT_TRUE(RunPageTest( | 694 ASSERT_TRUE(RunPageTest( |
695 extension->GetResourceURL("test_crossProcessHistory.html").spec())) | 695 extension->GetResourceURL("test_crossProcessHistory.html").spec())) |
696 << message_; | 696 << message_; |
697 } | 697 } |
698 | 698 |
699 } // namespace extensions | 699 } // namespace extensions |
OLD | NEW |