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

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

Issue 2127383002: Open hyperlinks in PDF in a new tab when middle mouse clicking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open hyperlinks in PDF in a new tab when middle mouse clicking. 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/pdf.js » ('j') | pdf/pdfium/pdfium_engine.cc » ('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 3e11df7829e3d3e63da939418497da44bdc69f4c..69af59fcaf12f430d5ae5278aed68f99548f6cd0 100644
--- a/chrome/browser/pdf/pdf_extension_test.cc
+++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -39,6 +39,7 @@
#include "content/public/browser/download_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -48,6 +49,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "extensions/test/result_catcher.h"
+#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
@@ -585,3 +587,60 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibility) {
<< "Expected:\n" << expected_ax_tree
<< "\n\nActual:\n" << ax_tree_dump;
}
+
+IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkMiddleClick) {
+ host_resolver()->AddRule("example.com", "127.0.0.1");
+ GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf"));
+ ui_test_utils::NavigateToURL(browser(), test_pdf_url);
+
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(web_contents));
+
+ bool success;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ web_contents,
+ "var pos_x, pos_y;"
+ "window.addEventListener('message', function(event) {"
+ " if (event.data.type != 'getLinkPositionReply')"
+ " window.domAutomationController.send(false);"
+ " if (!event.data.linkExists)"
+ " window.domAutomationController.send(false);"
+ " pos_x = Math.floor(event.data.x);"
+ " pos_y = Math.floor(event.data.y);"
+ " window.domAutomationController.send(true);"
+ "});"
+ "document.getElementsByTagName('embed')[0].postMessage("
+ " {type: 'getLinkPosition'});",
+ &success));
+
+ ASSERT_TRUE(success);
+
+ int x;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
+ web_contents,
+ "window.domAutomationController.send(pos_x);",
+ &x));
+
+ int y;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
+ web_contents,
+ "window.domAutomationController.send(pos_y);",
+ &y));
+
+ gfx::Point point(x, y);
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_TAB_ADDED,
+ content::NotificationService::AllSources());
+ content::SimulateMouseClickAt(web_contents, 0,
+ blink::WebMouseEvent::ButtonMiddle, point);
+ observer.Wait();
+
+ int tab_count = browser()->tab_strip_model()->count();
+ ASSERT_EQ(2, tab_count);
+
+ const GURL& url =
+ browser()->tab_strip_model()->GetActiveWebContents()->GetURL();
+ ASSERT_EQ(std::string("https://www.example.com/"), url.spec());
Lei Zhang 2016/07/08 21:12:29 If the link is www.example.com, but the host resol
jaepark 2016/07/08 22:15:03 Fixed.
+}
+
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | pdf/pdfium/pdfium_engine.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698