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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/pdf/test-link.pdf » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
33 #include "components/zoom/page_zoom.h" 33 #include "components/zoom/page_zoom.h"
34 #include "components/zoom/test/zoom_test_utils.h" 34 #include "components/zoom/test/zoom_test_utils.h"
35 #include "components/zoom/zoom_controller.h" 35 #include "components/zoom/zoom_controller.h"
36 #include "content/public/browser/browser_accessibility_state.h" 36 #include "content/public/browser/browser_accessibility_state.h"
37 #include "content/public/browser/browser_plugin_guest_manager.h" 37 #include "content/public/browser/browser_plugin_guest_manager.h"
38 #include "content/public/browser/download_item.h" 38 #include "content/public/browser/download_item.h"
39 #include "content/public/browser/download_manager.h" 39 #include "content/public/browser/download_manager.h"
40 #include "content/public/browser/notification_observer.h" 40 #include "content/public/browser/notification_observer.h"
41 #include "content/public/browser/notification_registrar.h" 41 #include "content/public/browser/notification_registrar.h"
42 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/plugin_service.h" 43 #include "content/public/browser/plugin_service.h"
43 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
44 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
45 #include "content/public/browser/render_widget_host.h" 46 #include "content/public/browser/render_widget_host.h"
46 #include "content/public/browser/web_contents.h" 47 #include "content/public/browser/web_contents.h"
47 #include "content/public/test/browser_test_utils.h" 48 #include "content/public/test/browser_test_utils.h"
48 #include "extensions/browser/extension_registry.h" 49 #include "extensions/browser/extension_registry.h"
49 #include "extensions/common/manifest_handlers/mime_types_handler.h" 50 #include "extensions/common/manifest_handlers/mime_types_handler.h"
50 #include "extensions/test/result_catcher.h" 51 #include "extensions/test/result_catcher.h"
52 #include "net/dns/mock_host_resolver.h"
51 #include "net/test/embedded_test_server/embedded_test_server.h" 53 #include "net/test/embedded_test_server/embedded_test_server.h"
52 #include "ui/base/resource/resource_bundle.h" 54 #include "ui/base/resource/resource_bundle.h"
53 #include "url/gurl.h" 55 #include "url/gurl.h"
54 56
55 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) 57 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
56 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 58 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
57 #endif 59 #endif
58 60
59 const int kNumberLoadTestParts = 10; 61 const int kNumberLoadTestParts = 10;
60 62
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 " paragraph\n" 580 " paragraph\n"
579 " staticText '3'\n" 581 " staticText '3'\n"
580 " inlineTextBox '3'\n"; 582 " inlineTextBox '3'\n";
581 583
582 // Using ASSERT_TRUE deliberately instead of ASSERT_EQ or ASSERT_STREQ 584 // Using ASSERT_TRUE deliberately instead of ASSERT_EQ or ASSERT_STREQ
583 // in order to print a more readable message if the strings differ. 585 // in order to print a more readable message if the strings differ.
584 ASSERT_TRUE(expected_ax_tree == ax_tree_dump) 586 ASSERT_TRUE(expected_ax_tree == ax_tree_dump)
585 << "Expected:\n" << expected_ax_tree 587 << "Expected:\n" << expected_ax_tree
586 << "\n\nActual:\n" << ax_tree_dump; 588 << "\n\nActual:\n" << ax_tree_dump;
587 } 589 }
590
591 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkMiddleClick) {
592 host_resolver()->AddRule("www.example.com", "127.0.0.1");
593 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf"));
594 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
595 ASSERT_TRUE(guest_contents);
596
597 // The link position of the test-link.pdf in page coordinates is (110, 110).
598 // Convert the link position from page coordinates to screen coordinates.
599 ASSERT_TRUE(content::ExecuteScript(guest_contents,
600 "var visiblePage = viewer.viewport.getMostVisiblePage();"
601 "var visiblePageDimensions ="
602 " viewer.viewport.getPageScreenRect(visiblePage);"
603 "var viewportPosition = viewer.viewport.position;"
604 "var screenOffsetX = visiblePageDimensions.x - viewportPosition.x;"
605 "var screenOffsetY = visiblePageDimensions.y - viewportPosition.y;"
606 "var linkScreenPositionX = Math.floor(110 + screenOffsetX);"
607 "var linkScreenPositionY = Math.floor(110 + screenOffsetY);"));
608
609 int x;
610 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
611 guest_contents,
612 "window.domAutomationController.send(linkScreenPositionX);",
613 &x));
614
615 int y;
616 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
617 guest_contents,
618 "window.domAutomationController.send(linkScreenPositionY);",
619 &y));
620
621 gfx::Point point(x, y);
622 content::WebContents* web_contents =
623 browser()->tab_strip_model()->GetActiveWebContents();
624
625 content::WindowedNotificationObserver observer(
626 chrome::NOTIFICATION_TAB_ADDED,
627 content::NotificationService::AllSources());
628 content::SimulateMouseClickAt(web_contents, 0,
629 blink::WebMouseEvent::ButtonMiddle, point);
630 observer.Wait();
631
632 int tab_count = browser()->tab_strip_model()->count();
633 ASSERT_EQ(2, tab_count);
634
635 // TODO(jaepark): Middle mouse clicking on a link should not change
636 // the focus of the tab. See http://crbug.com/628054.
637 content::WebContents* new_web_contents =
638 browser()->tab_strip_model()->GetActiveWebContents();
639 ASSERT_NE(web_contents, new_web_contents);
640
641 const GURL& url = new_web_contents->GetURL();
642 ASSERT_EQ(std::string("http://www.example.com/"), url.spec());
643 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/pdf/test-link.pdf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698