| OLD | NEW | 
|---|
| 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 <queue> | 5 #include <queue> | 
| 6 | 6 | 
| 7 #include "base/location.h" | 7 #include "base/location.h" | 
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" | 
| 9 #include "base/process/process.h" | 9 #include "base/process/process.h" | 
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 31 #include "components/content_settings/core/browser/host_content_settings_map.h" | 31 #include "components/content_settings/core/browser/host_content_settings_map.h" | 
| 32 #include "components/guest_view/browser/guest_view_manager.h" | 32 #include "components/guest_view/browser/guest_view_manager.h" | 
| 33 #include "components/guest_view/browser/guest_view_manager_delegate.h" | 33 #include "components/guest_view/browser/guest_view_manager_delegate.h" | 
| 34 #include "components/guest_view/browser/guest_view_manager_factory.h" | 34 #include "components/guest_view/browser/guest_view_manager_factory.h" | 
| 35 #include "components/guest_view/browser/test_guest_view_manager.h" | 35 #include "components/guest_view/browser/test_guest_view_manager.h" | 
| 36 #include "content/public/browser/gpu_data_manager.h" | 36 #include "content/public/browser/gpu_data_manager.h" | 
| 37 #include "content/public/browser/interstitial_page.h" | 37 #include "content/public/browser/interstitial_page.h" | 
| 38 #include "content/public/browser/interstitial_page_delegate.h" | 38 #include "content/public/browser/interstitial_page_delegate.h" | 
| 39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" | 
| 40 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" | 
|  | 41 #include "content/public/browser/render_widget_host_view.h" | 
| 41 #include "content/public/browser/web_contents_delegate.h" | 42 #include "content/public/browser/web_contents_delegate.h" | 
| 42 #include "content/public/common/child_process_host.h" | 43 #include "content/public/common/child_process_host.h" | 
| 43 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" | 
| 44 #include "content/public/test/browser_test_utils.h" | 45 #include "content/public/test/browser_test_utils.h" | 
| 45 #include "content/public/test/fake_speech_recognition_manager.h" | 46 #include "content/public/test/fake_speech_recognition_manager.h" | 
| 46 #include "content/public/test/test_renderer_host.h" | 47 #include "content/public/test/test_renderer_host.h" | 
| 47 #include "extensions/browser/api/declarative/rules_registry.h" | 48 #include "extensions/browser/api/declarative/rules_registry.h" | 
| 48 #include "extensions/browser/api/declarative/rules_registry_service.h" | 49 #include "extensions/browser/api/declarative/rules_registry_service.h" | 
| 49 #include "extensions/browser/api/declarative/test_rules_registry.h" | 50 #include "extensions/browser/api/declarative/test_rules_registry.h" | 
| 50 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 51 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 
| 51 #include "extensions/browser/api/extensions_api_client.h" | 52 #include "extensions/browser/api/extensions_api_client.h" | 
| 52 #include "extensions/browser/app_window/native_app_window.h" | 53 #include "extensions/browser/app_window/native_app_window.h" | 
| 53 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 54 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 
| 54 #include "extensions/common/extension.h" | 55 #include "extensions/common/extension.h" | 
| 55 #include "extensions/common/extensions_client.h" | 56 #include "extensions/common/extensions_client.h" | 
| 56 #include "extensions/test/extension_test_message_listener.h" | 57 #include "extensions/test/extension_test_message_listener.h" | 
| 57 #include "media/base/media_switches.h" | 58 #include "media/base/media_switches.h" | 
| 58 #include "net/test/embedded_test_server/embedded_test_server.h" | 59 #include "net/test/embedded_test_server/embedded_test_server.h" | 
| 59 #include "net/test/embedded_test_server/http_request.h" | 60 #include "net/test/embedded_test_server/http_request.h" | 
| 60 #include "net/test/embedded_test_server/http_response.h" | 61 #include "net/test/embedded_test_server/http_response.h" | 
| 61 #include "ui/aura/window.h" | 62 #include "ui/aura/window.h" | 
| 62 #include "ui/base/l10n/l10n_util.h" | 63 #include "ui/base/l10n/l10n_util.h" | 
| 63 #include "ui/compositor/compositor.h" | 64 #include "ui/compositor/compositor.h" | 
| 64 #include "ui/compositor/compositor_observer.h" | 65 #include "ui/compositor/compositor_observer.h" | 
| 65 #include "ui/events/event_switches.h" | 66 #include "ui/events/event_switches.h" | 
|  | 67 #include "ui/events/gesture_detection/gesture_configuration.h" | 
| 66 #include "ui/gfx/switches.h" | 68 #include "ui/gfx/switches.h" | 
| 67 #include "ui/gl/gl_switches.h" | 69 #include "ui/gl/gl_switches.h" | 
| 68 #include "ui/views/view.h" | 70 #include "ui/views/view.h" | 
| 69 #include "ui/views/widget/widget.h" | 71 #include "ui/views/widget/widget.h" | 
| 70 | 72 | 
| 71 #if defined(ENABLE_PLUGINS) | 73 #if defined(ENABLE_PLUGINS) | 
| 72 #include "content/public/browser/plugin_service.h" | 74 #include "content/public/browser/plugin_service.h" | 
| 73 #include "content/public/common/webplugininfo.h" | 75 #include "content/public/common/webplugininfo.h" | 
| 74 #include "content/public/test/ppapi_test_utils.h" | 76 #include "content/public/test/ppapi_test_utils.h" | 
| 75 #endif | 77 #endif | 
| (...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2516              "web_view/shim", NEEDS_TEST_SERVER); | 2518              "web_view/shim", NEEDS_TEST_SERVER); | 
| 2517 } | 2519 } | 
| 2518 | 2520 | 
| 2519 // Tests that a WebView accessible resource can actually be loaded from a | 2521 // Tests that a WebView accessible resource can actually be loaded from a | 
| 2520 // webpage in a WebView. | 2522 // webpage in a WebView. | 
| 2521 IN_PROC_BROWSER_TEST_F(WebViewTest, LoadWebviewAccessibleResource) { | 2523 IN_PROC_BROWSER_TEST_F(WebViewTest, LoadWebviewAccessibleResource) { | 
| 2522   TestHelper("testLoadWebviewAccessibleResource", | 2524   TestHelper("testLoadWebviewAccessibleResource", | 
| 2523              "web_view/load_webview_accessible_resource", NEEDS_TEST_SERVER); | 2525              "web_view/load_webview_accessible_resource", NEEDS_TEST_SERVER); | 
| 2524 } | 2526 } | 
| 2525 | 2527 | 
|  | 2528 class WebViewTouchTest : public WebViewTest { | 
|  | 2529  protected: | 
|  | 2530   void SetUpCommandLine(base::CommandLine* command_line) override { | 
|  | 2531     command_line->AppendSwitchASCII(switches::kTouchEvents, | 
|  | 2532                                     switches::kTouchEventsEnabled); | 
|  | 2533 | 
|  | 2534     WebViewTest::SetUpCommandLine(command_line); | 
|  | 2535   } | 
|  | 2536 }; | 
|  | 2537 | 
|  | 2538 namespace { | 
|  | 2539 | 
|  | 2540 class ScrollWaiter { | 
|  | 2541  public: | 
|  | 2542   explicit ScrollWaiter(content::RenderWidgetHostView* host_view) | 
|  | 2543       : host_view_(host_view) {} | 
|  | 2544   ~ScrollWaiter() {} | 
|  | 2545 | 
|  | 2546   void WaitForScrollChange(gfx::Vector2dF target_offset) { | 
|  | 2547     while (target_offset != host_view_->GetLastScrollOffset()) | 
|  | 2548       base::MessageLoop::current()->RunUntilIdle(); | 
|  | 2549   } | 
|  | 2550 | 
|  | 2551  private: | 
|  | 2552   content::RenderWidgetHostView* host_view_; | 
|  | 2553 }; | 
|  | 2554 | 
|  | 2555 }  // namespace | 
|  | 2556 | 
|  | 2557 // Tests that scrolls bubble from guest to embedder. | 
|  | 2558 IN_PROC_BROWSER_TEST_F(WebViewTest, TestGuestWheelScrollsBubble) { | 
|  | 2559   LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); | 
|  | 2560 | 
|  | 2561   content::WebContents* embedder_contents = GetEmbedderWebContents(); | 
|  | 2562 | 
|  | 2563   std::vector<content::WebContents*> guest_web_contents_list; | 
|  | 2564   GetGuestViewManager()->WaitForNumGuestsCreated(1u); | 
|  | 2565   GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); | 
|  | 2566   ASSERT_EQ(1u, guest_web_contents_list.size()); | 
|  | 2567 | 
|  | 2568   content::WebContents* guest_contents = guest_web_contents_list[0]; | 
|  | 2569 | 
|  | 2570   gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); | 
|  | 2571   gfx::Rect guest_rect = guest_contents->GetContainerBounds(); | 
|  | 2572 | 
|  | 2573   guest_rect.set_x(guest_rect.x() - embedder_rect.x()); | 
|  | 2574   guest_rect.set_y(guest_rect.y() - embedder_rect.y()); | 
|  | 2575   embedder_rect.set_x(0); | 
|  | 2576   embedder_rect.set_y(0); | 
|  | 2577 | 
|  | 2578   // Send scroll gesture to embedder & verify. | 
|  | 2579   content::RenderWidgetHostView* embedder_host_view = | 
|  | 2580       embedder_contents->GetRenderWidgetHostView(); | 
|  | 2581   EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); | 
|  | 2582 | 
|  | 2583   // Make sure wheel events don't get filtered. | 
|  | 2584   float scroll_magnitude = 15.f; | 
|  | 2585 | 
|  | 2586   { | 
|  | 2587     // Scroll the embedder from a position in the embedder that is not over | 
|  | 2588     // the guest. | 
|  | 2589     gfx::Point embedder_scroll_location( | 
|  | 2590         embedder_rect.x() + embedder_rect.width() / 2, | 
|  | 2591         (embedder_rect.y() + guest_rect.y()) / 2); | 
|  | 2592 | 
|  | 2593     gfx::Vector2dF expected_offset(0.f, scroll_magnitude); | 
|  | 2594 | 
|  | 2595     ScrollWaiter waiter(embedder_host_view); | 
|  | 2596 | 
|  | 2597     content::SimulateMouseEvent(embedder_contents, | 
|  | 2598                                 blink::WebInputEvent::MouseMove, | 
|  | 2599                                 embedder_scroll_location); | 
|  | 2600     content::SimulateMouseWheelEvent(embedder_contents, | 
|  | 2601                                      embedder_scroll_location, | 
|  | 2602                                      gfx::Vector2d(0, -scroll_magnitude)); | 
|  | 2603     waiter.WaitForScrollChange(expected_offset); | 
|  | 2604   } | 
|  | 2605 | 
|  | 2606   content::RenderWidgetHostView* guest_host_view = | 
|  | 2607       guest_contents->GetRenderWidgetHostView(); | 
|  | 2608   EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset()); | 
|  | 2609 | 
|  | 2610   // Send scroll gesture to guest and verify embedder scrolls. | 
|  | 2611   // Perform a scroll gesture of the same magnitude, but in the opposite | 
|  | 2612   // direction and centered over the GuestView this time. | 
|  | 2613   guest_rect = guest_contents->GetContainerBounds(); | 
|  | 2614   embedder_rect = embedder_contents->GetContainerBounds(); | 
|  | 2615   guest_rect.set_x(guest_rect.x() - embedder_rect.x()); | 
|  | 2616   guest_rect.set_y(guest_rect.y() - embedder_rect.y()); | 
|  | 2617   { | 
|  | 2618     gfx::Point guest_scroll_location(guest_rect.x() + guest_rect.width() / 2, | 
|  | 2619                                      guest_rect.y()); | 
|  | 2620     ScrollWaiter waiter(embedder_host_view); | 
|  | 2621 | 
|  | 2622     content::SimulateMouseEvent(embedder_contents, | 
|  | 2623                                 blink::WebInputEvent::MouseMove, | 
|  | 2624                                 guest_scroll_location); | 
|  | 2625     content::SimulateMouseWheelEvent(embedder_contents, guest_scroll_location, | 
|  | 2626                                      gfx::Vector2d(0, scroll_magnitude)); | 
|  | 2627 | 
|  | 2628     waiter.WaitForScrollChange(gfx::Vector2dF()); | 
|  | 2629   } | 
|  | 2630 } | 
|  | 2631 | 
|  | 2632 IN_PROC_BROWSER_TEST_F(WebViewTouchTest, TestGuestGestureScrollsBubble) { | 
|  | 2633   // Just in case we're running ChromeOS tests, we need to make sure the | 
|  | 2634   // debounce interval is set to zero so our back-to-back gesture-scrolls don't | 
|  | 2635   // get munged together. Since the first scroll will be put on the fast | 
|  | 2636   // (compositor) path, while the second one should always be slow-path so it | 
|  | 2637   // gets to BrowserPlugin, having them merged is definitely an error. | 
|  | 2638   ui::GestureConfiguration* gesture_config = | 
|  | 2639       ui::GestureConfiguration::GetInstance(); | 
|  | 2640   gesture_config->set_scroll_debounce_interval_in_ms(0); | 
|  | 2641 | 
|  | 2642   LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); | 
|  | 2643 | 
|  | 2644   content::WebContents* embedder_contents = GetEmbedderWebContents(); | 
|  | 2645 | 
|  | 2646   std::vector<content::WebContents*> guest_web_contents_list; | 
|  | 2647   GetGuestViewManager()->WaitForNumGuestsCreated(1u); | 
|  | 2648   GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); | 
|  | 2649   ASSERT_EQ(1u, guest_web_contents_list.size()); | 
|  | 2650 | 
|  | 2651   content::WebContents* guest_contents = guest_web_contents_list[0]; | 
|  | 2652 | 
|  | 2653   gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); | 
|  | 2654   gfx::Rect guest_rect = guest_contents->GetContainerBounds(); | 
|  | 2655 | 
|  | 2656   guest_rect.set_x(guest_rect.x() - embedder_rect.x()); | 
|  | 2657   guest_rect.set_y(guest_rect.y() - embedder_rect.y()); | 
|  | 2658   embedder_rect.set_x(0); | 
|  | 2659   embedder_rect.set_y(0); | 
|  | 2660 | 
|  | 2661   // Send scroll gesture to embedder & verify. | 
|  | 2662   content::RenderWidgetHostView* embedder_host_view = | 
|  | 2663       embedder_contents->GetRenderWidgetHostView(); | 
|  | 2664   EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); | 
|  | 2665 | 
|  | 2666   float gesture_distance = 15.f; | 
|  | 2667   { | 
|  | 2668     // Scroll the embedder from a position in the embedder that is not over | 
|  | 2669     // the guest. | 
|  | 2670     gfx::Point embedder_scroll_location( | 
|  | 2671         embedder_rect.x() + embedder_rect.width() / 2, | 
|  | 2672         (embedder_rect.y() + guest_rect.y()) / 2); | 
|  | 2673 | 
|  | 2674     gfx::Vector2dF expected_offset(0.f, gesture_distance); | 
|  | 2675 | 
|  | 2676     content::SimulateGestureScrollSequence( | 
|  | 2677         embedder_contents, embedder_scroll_location, | 
|  | 2678         gfx::Vector2dF(0, -gesture_distance)); | 
|  | 2679 | 
|  | 2680     ScrollWaiter waiter(embedder_host_view); | 
|  | 2681 | 
|  | 2682     waiter.WaitForScrollChange(expected_offset); | 
|  | 2683   } | 
|  | 2684 | 
|  | 2685   content::RenderWidgetHostView* guest_host_view = | 
|  | 2686       guest_contents->GetRenderWidgetHostView(); | 
|  | 2687   EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset()); | 
|  | 2688 | 
|  | 2689   // Send scroll gesture to guest and verify embedder scrolls. | 
|  | 2690   // Perform a scroll gesture of the same magnitude, but in the opposite | 
|  | 2691   // direction and centered over the GuestView this time. | 
|  | 2692   guest_rect = guest_contents->GetContainerBounds(); | 
|  | 2693   embedder_rect = embedder_contents->GetContainerBounds(); | 
|  | 2694   guest_rect.set_x(guest_rect.x() - embedder_rect.x()); | 
|  | 2695   guest_rect.set_y(guest_rect.y() - embedder_rect.y()); | 
|  | 2696   { | 
|  | 2697     gfx::Point guest_scroll_location(guest_rect.x() + guest_rect.width() / 2, | 
|  | 2698                                      guest_rect.y()); | 
|  | 2699 | 
|  | 2700     ScrollWaiter waiter(embedder_host_view); | 
|  | 2701 | 
|  | 2702     content::SimulateGestureScrollSequence(embedder_contents, | 
|  | 2703                                            guest_scroll_location, | 
|  | 2704                                            gfx::Vector2dF(0, gesture_distance)); | 
|  | 2705 | 
|  | 2706     waiter.WaitForScrollChange(gfx::Vector2dF()); | 
|  | 2707   } | 
|  | 2708 } | 
|  | 2709 | 
| 2526 #if defined(USE_AURA) | 2710 #if defined(USE_AURA) | 
| 2527 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation | 2711 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation | 
| 2528 // bots, then re-enable this test class as well. | 2712 // bots, then re-enable this test class as well. | 
| 2529 // https://crbug.com/503751 | 2713 // https://crbug.com/503751 | 
| 2530 class WebViewFocusTest : public WebViewTest { | 2714 class WebViewFocusTest : public WebViewTest { | 
| 2531  public: | 2715  public: | 
| 2532   ~WebViewFocusTest() override {} | 2716   ~WebViewFocusTest() override {} | 
| 2533 | 2717 | 
| 2534   void SetUpCommandLine(base::CommandLine* command_line) override { | 2718   void SetUpCommandLine(base::CommandLine* command_line) override { | 
| 2535     WebViewTest::SetUpCommandLine(command_line); | 2719     WebViewTest::SetUpCommandLine(command_line); | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2742   const task_management::Task* task = task_manager.tasks().back(); | 2926   const task_management::Task* task = task_manager.tasks().back(); | 
| 2743   EXPECT_EQ(task_management::Task::GUEST, task->GetType()); | 2927   EXPECT_EQ(task_management::Task::GUEST, task->GetType()); | 
| 2744   const base::string16 title = task->title(); | 2928   const base::string16 title = task->title(); | 
| 2745   const base::string16 expected_prefix = GetExpectedPrefix(guest_contents); | 2929   const base::string16 expected_prefix = GetExpectedPrefix(guest_contents); | 
| 2746   EXPECT_TRUE(base::StartsWith(title, | 2930   EXPECT_TRUE(base::StartsWith(title, | 
| 2747                                expected_prefix, | 2931                                expected_prefix, | 
| 2748                                base::CompareCase::INSENSITIVE_ASCII)); | 2932                                base::CompareCase::INSENSITIVE_ASCII)); | 
| 2749 } | 2933 } | 
| 2750 | 2934 | 
| 2751 #endif  // defined(ENABLE_TASK_MANAGER) | 2935 #endif  // defined(ENABLE_TASK_MANAGER) | 
| OLD | NEW | 
|---|