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

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: 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/browser/resources/pdf/pdf.js » ('j') | chrome/browser/resources/pdf/pdf.js » ('J')
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"
51 #include "net/test/embedded_test_server/embedded_test_server.h" 52 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 " paragraph\n" 579 " paragraph\n"
579 " staticText '3'\n" 580 " staticText '3'\n"
580 " inlineTextBox '3'\n"; 581 " inlineTextBox '3'\n";
581 582
582 // Using ASSERT_TRUE deliberately instead of ASSERT_EQ or ASSERT_STREQ 583 // Using ASSERT_TRUE deliberately instead of ASSERT_EQ or ASSERT_STREQ
583 // in order to print a more readable message if the strings differ. 584 // in order to print a more readable message if the strings differ.
584 ASSERT_TRUE(expected_ax_tree == ax_tree_dump) 585 ASSERT_TRUE(expected_ax_tree == ax_tree_dump)
585 << "Expected:\n" << expected_ax_tree 586 << "Expected:\n" << expected_ax_tree
586 << "\n\nActual:\n" << ax_tree_dump; 587 << "\n\nActual:\n" << ax_tree_dump;
587 } 588 }
589
590 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkMiddleClick) {
591 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf"));
592 ui_test_utils::NavigateToURL(browser(), test_pdf_url);
593
594 content::WebContents* web_contents =
595 browser()->tab_strip_model()->GetActiveWebContents();
596 ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(web_contents));
597
598 int x;
599 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
600 web_contents,
601 "window.addEventListener('message', function(event) {"
602 " if (event.data.type == 'getLinkPositionReply')"
603 " window.domAutomationController.send(Math.floor(event.data.x));"
604 " window.removeEventListener(event.type, arguments.callee);"
605 "});"
606 "document.getElementsByTagName('embed')[0].postMessage("
607 " {type: 'getLinkPosition'});",
608 &x));
609
610 int y;
611 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
612 web_contents,
613 "window.addEventListener('message', function(event) {"
614 " if (event.data.type == 'getLinkPositionReply')"
615 " window.domAutomationController.send(Math.floor(event.data.y));"
616 " window.removeEventListener(event.type, arguments.callee);"
617 "});"
618 "document.getElementsByTagName('embed')[0].postMessage("
619 " {type: 'getLinkPosition'});",
Lei Zhang 2016/07/08 18:02:35 It feels like a bit more work to have to post 2 ge
jaepark 2016/07/08 20:58:16 Done.
620 &y));
621
622 gfx::Point point(x, y);
623 content::WindowedNotificationObserver observer(
624 chrome::NOTIFICATION_TAB_ADDED,
625 content::NotificationService::AllSources());
626 content::SimulateMouseClickAt(web_contents, 0,
627 blink::WebMouseEvent::ButtonMiddle, point);
628 observer.Wait();
629
630 int tab_count = browser()->tab_strip_model()->count();
631 ASSERT_EQ(2, tab_count);
632
633 const GURL& url =
634 browser()->tab_strip_model()->GetActiveWebContents()->GetURL();
635 ASSERT_EQ(std::string("https://www.google.com/"), url.spec());
Lei Zhang 2016/07/08 18:02:35 Can we do example.com and add: host_resolver()->A
jaepark 2016/07/08 20:58:16 Done.
636 }
637
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf.js » ('j') | chrome/browser/resources/pdf/pdf.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698