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

Unified Diff: chrome/browser/pdf/pdf_extension_test.cc

Issue 2166193002: Handle ctrl + shift + left click on links in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle ctrl + shift + left click on links in PDF. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/navigator.js » ('j') | chrome/browser/resources/pdf/navigator.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/pdf/pdf_extension_test.cc
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc
index 3a67f71b247de15eeafb35654945dcc1375265ac..8d66a96c95bd03cf39d33997184a4ab8e684b0f2 100644
--- a/chrome/browser/pdf/pdf_extension_test.cc
+++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -780,3 +780,75 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkMiddleClick) {
const GURL& url = new_web_contents->GetURL();
ASSERT_EQ(std::string("http://www.example.com/"), url.spec());
}
+
+IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkCtrlShiftLeftClick) {
+ host_resolver()->AddRule("www.example.com", "127.0.0.1");
+ GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf"));
+ content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
+ ASSERT_TRUE(guest_contents);
+
+ // The link position of the test-link.pdf in page coordinates is (110, 110).
+ // Convert the link position from page coordinates to screen coordinates.
+ gfx::Point link_position(110, 110);
+ ConvertPageCoordToScreenCoord(guest_contents, &link_position);
+
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+#if defined(OS_MACOSX)
+ int modifiers =
+ blink::WebInputEvent::MetaKey | blink::WebInputEvent::ShiftKey;
Lei Zhang 2016/07/23 00:39:38 You can add a helper function to return the right
jaepark 2016/07/23 03:52:30 Done. I made a const variable for the default modi
+#else
+ int modifiers =
+ blink::WebInputEvent::ControlKey | blink::WebInputEvent::ShiftKey;
+#endif
+
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_TAB_ADDED,
+ content::NotificationService::AllSources());
+ content::SimulateMouseClickAt(web_contents, modifiers,
+ blink::WebMouseEvent::ButtonLeft, link_position);
+ observer.Wait();
+
+ int tab_count = browser()->tab_strip_model()->count();
+ ASSERT_EQ(2, tab_count);
+
+ content::WebContents* active_web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_NE(web_contents, active_web_contents);
+
+ const GURL& url = active_web_contents->GetURL();
+ ASSERT_EQ(std::string("http://www.example.com/"), url.spec());
+}
+
+IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftMiddleClick) {
+ host_resolver()->AddRule("www.example.com", "127.0.0.1");
+ GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf"));
+ content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
+ ASSERT_TRUE(guest_contents);
+
+ // The link position of the test-link.pdf in page coordinates is (110, 110).
+ // Convert the link position from page coordinates to screen coordinates.
+ gfx::Point link_position(110, 110);
+ ConvertPageCoordToScreenCoord(guest_contents, &link_position);
+
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_TAB_ADDED,
+ content::NotificationService::AllSources());
+ content::SimulateMouseClickAt(web_contents, blink::WebInputEvent::ShiftKey,
+ blink::WebMouseEvent::ButtonMiddle, link_position);
+ observer.Wait();
+
+ int tab_count = browser()->tab_strip_model()->count();
+ ASSERT_EQ(2, tab_count);
+
+ content::WebContents* active_web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_NE(web_contents, active_web_contents);
+
+ const GURL& url = active_web_contents->GetURL();
+ ASSERT_EQ(std::string("http://www.example.com/"), url.spec());
+}
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/navigator.js » ('j') | chrome/browser/resources/pdf/navigator.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698