| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 " inlineTextBox '2'\n" | 638 " inlineTextBox '2'\n" |
| 639 " region 'Page 3'\n" | 639 " region 'Page 3'\n" |
| 640 " paragraph\n" | 640 " paragraph\n" |
| 641 " staticText '2 Second Section\\r\\n'\n" | 641 " staticText '2 Second Section\\r\\n'\n" |
| 642 " inlineTextBox '2 '\n" | 642 " inlineTextBox '2 '\n" |
| 643 " inlineTextBox 'Second Section\\r\\n'\n" | 643 " inlineTextBox 'Second Section\\r\\n'\n" |
| 644 " paragraph\n" | 644 " paragraph\n" |
| 645 " staticText '3'\n" | 645 " staticText '3'\n" |
| 646 " inlineTextBox '3'\n"; | 646 " inlineTextBox '3'\n"; |
| 647 | 647 |
| 648 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibility) { | 648 // https://crbug.com/701427 |
| 649 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_PdfAccessibility) { |
| 649 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); | 650 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); |
| 650 | 651 |
| 651 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-bookmarks.pdf")); | 652 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-bookmarks.pdf")); |
| 652 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 653 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
| 653 ASSERT_TRUE(guest_contents); | 654 ASSERT_TRUE(guest_contents); |
| 654 | 655 |
| 655 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, | 656 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, |
| 656 "1 First Section\r\n"); | 657 "1 First Section\r\n"); |
| 657 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); | 658 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); |
| 658 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); | 659 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); |
| 659 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); | 660 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); |
| 660 } | 661 } |
| 661 | 662 |
| 662 #if defined(GOOGLE_CHROME_BUILD) | 663 #if defined(GOOGLE_CHROME_BUILD) |
| 663 // Test a particular PDF encountered in the wild that triggered a crash | 664 // Test a particular PDF encountered in the wild that triggered a crash |
| 664 // when accessibility is enabled. (http://crbug.com/648981) | 665 // when accessibility is enabled. (http://crbug.com/648981) |
| 665 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityCharCountCrash) { | 666 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityCharCountCrash) { |
| 666 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); | 667 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); |
| 667 GURL test_pdf_url(embedded_test_server()->GetURL( | 668 GURL test_pdf_url(embedded_test_server()->GetURL( |
| 668 "/pdf_private/accessibility_crash_1.pdf")); | 669 "/pdf_private/accessibility_crash_1.pdf")); |
| 669 | 670 |
| 670 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 671 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
| 671 ASSERT_TRUE(guest_contents); | 672 ASSERT_TRUE(guest_contents); |
| 672 | 673 |
| 673 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, "Page 1"); | 674 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, "Page 1"); |
| 674 } | 675 } |
| 675 #endif | 676 #endif |
| 676 | 677 |
| 677 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityEnableLater) { | 678 // https://crbug.com/701427 |
| 679 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_PdfAccessibilityEnableLater) { |
| 678 // In this test, load the PDF file first, with accessibility off. | 680 // In this test, load the PDF file first, with accessibility off. |
| 679 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-bookmarks.pdf")); | 681 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-bookmarks.pdf")); |
| 680 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 682 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
| 681 ASSERT_TRUE(guest_contents); | 683 ASSERT_TRUE(guest_contents); |
| 682 | 684 |
| 683 // Now enable accessibility globally, and assert that the PDF accessibility | 685 // Now enable accessibility globally, and assert that the PDF accessibility |
| 684 // tree loads. | 686 // tree loads. |
| 685 EnableAccessibilityForWebContents(guest_contents); | 687 EnableAccessibilityForWebContents(guest_contents); |
| 686 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, | 688 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, |
| 687 "1 First Section\r\n"); | 689 "1 First Section\r\n"); |
| 688 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); | 690 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); |
| 689 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); | 691 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); |
| 690 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); | 692 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); |
| 691 } | 693 } |
| 692 | 694 |
| 693 bool RetrieveGuestContents( | 695 bool RetrieveGuestContents( |
| 694 content::WebContents** out_guest_contents, | 696 content::WebContents** out_guest_contents, |
| 695 content::WebContents* in_guest_contents) { | 697 content::WebContents* in_guest_contents) { |
| 696 *out_guest_contents = in_guest_contents; | 698 *out_guest_contents = in_guest_contents; |
| 697 return true; | 699 return true; |
| 698 } | 700 } |
| 699 | 701 |
| 700 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityInIframe) { | 702 // https://crbug.com/701427 |
| 703 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_PdfAccessibilityInIframe) { |
| 701 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); | 704 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); |
| 702 GURL test_iframe_url(embedded_test_server()->GetURL("/pdf/test-iframe.html")); | 705 GURL test_iframe_url(embedded_test_server()->GetURL("/pdf/test-iframe.html")); |
| 703 ui_test_utils::NavigateToURL(browser(), test_iframe_url); | 706 ui_test_utils::NavigateToURL(browser(), test_iframe_url); |
| 704 content::WebContents* contents = | 707 content::WebContents* contents = |
| 705 browser()->tab_strip_model()->GetActiveWebContents(); | 708 browser()->tab_strip_model()->GetActiveWebContents(); |
| 706 WaitForAccessibilityTreeToContainNodeWithName(contents, | 709 WaitForAccessibilityTreeToContainNodeWithName(contents, |
| 707 "1 First Section\r\n"); | 710 "1 First Section\r\n"); |
| 708 | 711 |
| 709 content::WebContents* guest_contents = nullptr; | 712 content::WebContents* guest_contents = nullptr; |
| 710 content::BrowserPluginGuestManager* guest_manager = | 713 content::BrowserPluginGuestManager* guest_manager = |
| 711 contents->GetBrowserContext()->GetGuestManager(); | 714 contents->GetBrowserContext()->GetGuestManager(); |
| 712 guest_manager->ForEachGuest(contents, | 715 guest_manager->ForEachGuest(contents, |
| 713 base::Bind(&RetrieveGuestContents, | 716 base::Bind(&RetrieveGuestContents, |
| 714 &guest_contents)); | 717 &guest_contents)); |
| 715 ASSERT_TRUE(guest_contents); | 718 ASSERT_TRUE(guest_contents); |
| 716 | 719 |
| 717 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); | 720 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); |
| 718 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); | 721 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); |
| 719 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); | 722 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); |
| 720 } | 723 } |
| 721 | 724 |
| 722 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityInOOPIF) { | 725 // https://crbug.com/701427 |
| 726 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_PdfAccessibilityInOOPIF) { |
| 723 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); | 727 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); |
| 724 GURL test_iframe_url(embedded_test_server()->GetURL( | 728 GURL test_iframe_url(embedded_test_server()->GetURL( |
| 725 "/pdf/test-cross-site-iframe.html")); | 729 "/pdf/test-cross-site-iframe.html")); |
| 726 ui_test_utils::NavigateToURL(browser(), test_iframe_url); | 730 ui_test_utils::NavigateToURL(browser(), test_iframe_url); |
| 727 content::WebContents* contents = | 731 content::WebContents* contents = |
| 728 browser()->tab_strip_model()->GetActiveWebContents(); | 732 browser()->tab_strip_model()->GetActiveWebContents(); |
| 729 WaitForAccessibilityTreeToContainNodeWithName(contents, | 733 WaitForAccessibilityTreeToContainNodeWithName(contents, |
| 730 "1 First Section\r\n"); | 734 "1 First Section\r\n"); |
| 731 | 735 |
| 732 content::WebContents* guest_contents = nullptr; | 736 content::WebContents* guest_contents = nullptr; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 ASSERT_EQ(web_contents, active_web_contents); | 1024 ASSERT_EQ(web_contents, active_web_contents); |
| 1021 | 1025 |
| 1022 content::WebContents* new_web_contents = | 1026 content::WebContents* new_web_contents = |
| 1023 browser()->tab_strip_model()->GetWebContentsAt(1); | 1027 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 1024 ASSERT_TRUE(new_web_contents); | 1028 ASSERT_TRUE(new_web_contents); |
| 1025 ASSERT_NE(web_contents, new_web_contents); | 1029 ASSERT_NE(web_contents, new_web_contents); |
| 1026 | 1030 |
| 1027 const GURL& url = new_web_contents->GetURL(); | 1031 const GURL& url = new_web_contents->GetURL(); |
| 1028 ASSERT_EQ(GURL("http://www.example.com"), url); | 1032 ASSERT_EQ(GURL("http://www.example.com"), url); |
| 1029 } | 1033 } |
| OLD | NEW |