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 ui_test_utils::NavigateToURL(browser(), test_pdf_url); | |
595 | |
596 content::WebContents* web_contents = | |
597 browser()->tab_strip_model()->GetActiveWebContents(); | |
598 ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(web_contents)); | |
599 | |
600 bool success; | |
601 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
602 web_contents, | |
603 "var pos_x, pos_y;" | |
Dan Beam
2016/07/11 21:03:09
these should probably be posX and posY as they're
| |
604 "window.addEventListener('message', function(event) {" | |
605 " if (event.data.type != 'getLinkPositionReply')" | |
606 " window.domAutomationController.send(false);" | |
607 " if (!event.data.linkExists)" | |
608 " window.domAutomationController.send(false);" | |
609 " pos_x = Math.floor(event.data.x);" | |
610 " pos_y = Math.floor(event.data.y);" | |
611 " window.domAutomationController.send(true);" | |
612 "});" | |
613 "document.getElementsByTagName('embed')[0].postMessage(" | |
614 " {type: 'getLinkPosition'});", | |
615 &success)); | |
616 | |
617 ASSERT_TRUE(success); | |
618 | |
619 int x; | |
620 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | |
621 web_contents, | |
622 "window.domAutomationController.send(pos_x);", | |
623 &x)); | |
624 | |
625 int y; | |
626 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | |
627 web_contents, | |
628 "window.domAutomationController.send(pos_y);", | |
629 &y)); | |
630 | |
631 gfx::Point point(x, y); | |
632 content::WindowedNotificationObserver observer( | |
633 chrome::NOTIFICATION_TAB_ADDED, | |
634 content::NotificationService::AllSources()); | |
635 content::SimulateMouseClickAt(web_contents, 0, | |
636 blink::WebMouseEvent::ButtonMiddle, point); | |
637 observer.Wait(); | |
638 | |
639 int tab_count = browser()->tab_strip_model()->count(); | |
640 ASSERT_EQ(2, tab_count); | |
641 | |
642 const GURL& url = | |
643 browser()->tab_strip_model()->GetActiveWebContents()->GetURL(); | |
644 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | |
645 } | |
646 | |
OLD | NEW |