OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 content::WebContents* web_contents = | |
Lei Zhang
2016/07/14 00:03:39
Move this down to line ~627, closer to where it's
jaepark
2016/07/14 00:59:40
Done.
| |
597 browser()->tab_strip_model()->GetActiveWebContents(); | |
598 | |
599 // The link position of the test-link.pdf in page coordinates is (110, 110). | |
600 // Convert the link position from page coordinates to screen coordinates. | |
601 ASSERT_TRUE(content::ExecuteScript(guest_contents, | |
602 "var visiblePage = viewer.viewport.getMostVisiblePage();" | |
603 "var visiblePageDimensions =" | |
604 " viewer.viewport.getPageScreenRect(visiblePage);" | |
605 "var viewportPosition = viewer.viewport.position;" | |
606 "var screenOffsetX = visiblePageDimensions.x - viewportPosition.x;" | |
607 "var screenOffsetY = visiblePageDimensions.y - viewportPosition.y;" | |
608 "var linkScreenPositionX = Math.floor(110 + screenOffsetX);" | |
609 "var linkScreenPositionY = Math.floor(110 + screenOffsetY);")); | |
610 | |
611 int x; | |
612 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | |
613 guest_contents, | |
614 "window.domAutomationController.send(linkScreenPositionX);", | |
615 &x)); | |
616 | |
617 int y; | |
618 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | |
619 guest_contents, | |
620 "window.domAutomationController.send(linkScreenPositionY);", | |
621 &y)); | |
622 | |
623 gfx::Point point(x, y); | |
624 content::WindowedNotificationObserver observer( | |
625 chrome::NOTIFICATION_TAB_ADDED, | |
626 content::NotificationService::AllSources()); | |
627 content::SimulateMouseClickAt(web_contents, 0, | |
628 blink::WebMouseEvent::ButtonMiddle, point); | |
629 observer.Wait(); | |
630 | |
631 int tab_count = browser()->tab_strip_model()->count(); | |
632 ASSERT_EQ(2, tab_count); | |
633 | |
634 const GURL& url = | |
635 browser()->tab_strip_model()->GetActiveWebContents()->GetURL(); | |
Lei Zhang
2016/07/14 00:03:39
Does GetActiveWebContents() still return the same
jaepark
2016/07/14 00:59:40
Yes it does.
Lei Zhang
2016/07/14 01:25:04
Sure. Can you add a comment to here to note the ex
| |
636 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | |
637 } | |
OLD | NEW |