Chromium Code Reviews| 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 | |
| 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 const GURL& url = | |
| 636 browser()->tab_strip_model()->GetActiveWebContents()->GetURL(); | |
|
Lei Zhang
2016/07/14 01:25:05
Ok, so if we are testing the current "incorrect" b
jaepark
2016/07/14 01:53:01
Done.
| |
| 637 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | |
| 638 } | |
| OLD | NEW |