| Index: chrome/browser/chrome_site_per_process_browsertest.cc
|
| diff --git a/chrome/browser/chrome_site_per_process_browsertest.cc b/chrome/browser/chrome_site_per_process_browsertest.cc
|
| index e385c9ef3c642142343c7b2e1b041f800d99cfc4..7872cee95848a34301de54e2391baf3d9d28ec56 100644
|
| --- a/chrome/browser/chrome_site_per_process_browsertest.cc
|
| +++ b/chrome/browser/chrome_site_per_process_browsertest.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| @@ -20,6 +21,8 @@
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| +#include "content/public/browser/render_widget_host.h"
|
| +#include "content/public/browser/render_widget_host_view.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| @@ -28,6 +31,7 @@
|
| #include "extensions/browser/api/extensions_api_client.h"
|
| #include "net/dns/mock_host_resolver.h"
|
| #include "net/test/embedded_test_server/embedded_test_server.h"
|
| +#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
| #include "ui/display/display_switches.h"
|
| #include "url/gurl.h"
|
|
|
| @@ -321,7 +325,7 @@ class ChromeSitePerProcessPDFTest : public ChromeSitePerProcessTest {
|
| };
|
|
|
| // TODO(ekaramad): This test is flaky on Windows 7. Enable it when the issue is
|
| -// fixed ((https://crbug.com/666379).
|
| +// fixed (https://crbug.com/666379).
|
| #if defined(OS_WIN)
|
| #define MAYBE_EmbeddedPDFInsideCrossOriginFrame \
|
| DISABLED_EmbeddedPDFInsideCrossOriginFrame
|
| @@ -362,3 +366,59 @@ IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessPDFTest,
|
| observer.Wait();
|
| EXPECT_EQ(0U, test_guest_view_manager()->GetNumGuestsActive());
|
| }
|
| +
|
| +// This test loads a PDF inside an OOPIF and then verifies that context menu
|
| +// shows up at the correct position.
|
| +IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessPDFTest,
|
| + ContextMenuPositionForEmbeddedPDFInCrossOriginFrame) {
|
| + // Navigate to a page with an <iframe>.
|
| + GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
|
| + ui_test_utils::NavigateToURL(browser(), main_url);
|
| +
|
| + // Initially, no guests are created.
|
| + EXPECT_EQ(0U, test_guest_view_manager()->num_guests_created());
|
| +
|
| + // Navigate subframe to a cross-site page with an embedded PDF.
|
| + content::WebContents* active_web_contents =
|
| + browser()->tab_strip_model()->GetActiveWebContents();
|
| + GURL frame_url =
|
| + embedded_test_server()->GetURL("b.com", "/page_with_embedded_pdf.html");
|
| +
|
| + // Ensure the page finishes loading without crashing.
|
| + EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url));
|
| +
|
| + // Wait until the guest for PDF is created.
|
| + EXPECT_TRUE(test_guest_view_manager()->WaitForSingleGuestCreated());
|
| +
|
| + // Change the position of the <iframe> inside the page.
|
| + EXPECT_TRUE(ExecuteScript(active_web_contents,
|
| + "document.querySelector('iframe').style ="
|
| + " 'margin-left: 100px; margin-top: 100px;';"));
|
| +
|
| + // Send a right click to the embedder frame and observe the context menu.
|
| + auto send_right_mouse_event = [](content::RenderWidgetHost* host, int x,
|
| + int y, blink::WebInputEvent::Type type) {
|
| + blink::WebMouseEvent event;
|
| + event.x = x;
|
| + event.y = y;
|
| + event.button = blink::WebMouseEvent::Button::Right;
|
| + event.type = type;
|
| + host->ForwardMouseEvent(event);
|
| + };
|
| +
|
| + content::RenderWidgetHostView* child_view =
|
| + ChildFrameAt(active_web_contents->GetMainFrame(), 0)->GetView();
|
| +
|
| + ContextMenuWaiter menu_waiter(content::NotificationService::AllSources());
|
| + send_right_mouse_event(child_view->GetRenderWidgetHost(), 10, 20,
|
| + blink::WebInputEvent::MouseDown);
|
| + send_right_mouse_event(child_view->GetRenderWidgetHost(), 10, 20,
|
| + blink::WebInputEvent::MouseUp);
|
| + menu_waiter.WaitForMenuOpenAndClose();
|
| +
|
| + gfx::Point point_in_root_window =
|
| + child_view->TransformPointToRootCoordSpace(gfx::Point(10, 20));
|
| +
|
| + EXPECT_EQ(point_in_root_window.x(), menu_waiter.params().x);
|
| + EXPECT_EQ(point_in_root_window.y(), menu_waiter.params().y);
|
| +}
|
|
|