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

Side by Side Diff: chrome/browser/pdf/pdf_extension_test.cc

Issue 2648013002: Fix crash in PDF accessibility when PDF engine reports -1 as char count. (Closed)
Patch Set: Add test Created 3 years, 11 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 | pdf/out_of_process_instance.cc » ('j') | no next file with comments »
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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); 652 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
653 ASSERT_TRUE(guest_contents); 653 ASSERT_TRUE(guest_contents);
654 654
655 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, 655 WaitForAccessibilityTreeToContainNodeWithName(guest_contents,
656 "1 First Section\r\n"); 656 "1 First Section\r\n");
657 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents); 657 ui::AXTreeUpdate ax_tree = GetAccessibilityTreeSnapshot(guest_contents);
658 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree); 658 std::string ax_tree_dump = DumpPdfAccessibilityTree(ax_tree);
659 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump); 659 ASSERT_MULTILINE_STREQ(kExpectedPDFAXTree, ax_tree_dump);
660 } 660 }
661 661
662 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityCharCountCrash) {
raymes 2017/01/24 23:05:47 nit: please add a comment with a link to the bug
dmazzoni 2017/01/25 20:30:36 Done.
663 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility();
664
665 GURL test_pdf_url(embedded_test_server()->GetURL(
666 "data:application/pdf;base64,JVBERi0xLjYNCiXi48/TDQo2IDAgb2JqDQo8PA0KL0"
667 "xpbmVhcml6ZWQgMQ0KL0wgMTg2Ng0KL0ggWyA2NTUgMTI3IF0NCi9PIDgNCi9FIDEyMjkN"
668 "Ci9OIDENCi9UIDE2MjANCj4+DQplbmRvYmoNCiAgICAgICAgICAgICAgICAgICAgICAgIC"
669 "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICANCnhyZWYNCjYgNg0K"
670 "MDAwMDAwMDAxNyAwMDAwMCBuDQowMDAwMDAwNTg2IDAwMDAwIG4NCjAwMDAwMDA3ODIgMD"
671 "AwMDAgbg0KMDAwMDAwMDk2MyAwMDAwMCBuDQowMDAwMDAxMDQzIDAwMDAwIG4NCjAwMDAw"
672 "MDA2NTUgMDAwMDAgbg0KdHJhaWxlcg0KPDwNCi9TaXplIDEyDQovUHJldiAxNjEwDQovSW"
673 "5mbyA1IDAgUg0KL1Jvb3QgNyAwIFINCi9JRCBbPDZlZjdhODFiZGQ2NDYwMGFmNDQ5NmQ0"
674 "MzMyMjA3ZmViPjw2ZWY3YTgxYmRkNjQ2MDBhZjQ0OTZkNDMzMjIwN2ZlYj5dDQo+Pg0Kc3"
675 "RhcnR4cmVmDQowDQolJUVPRg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg"
676 "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC"
677 "AgICAgICAgICAgICAgICAgICAgICAgICAgICANCjcgMCBvYmoNCjw8DQovVHlwZSAvQ2F0"
678 "YWxvZw0KL1BhZ2VzIDEgMCBSDQovTmFtZXMgMiAwIFINCj4+DQplbmRvYmoNCjExIDAgb2"
679 "JqDQo8PA0KL1MgMzYNCi9GaWx0ZXIgL0Zs"));
680 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
681 ASSERT_TRUE(guest_contents);
682
683 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, "Page 1");
684 }
685
662 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityEnableLater) { 686 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfAccessibilityEnableLater) {
663 // In this test, load the PDF file first, with accessibility off. 687 // In this test, load the PDF file first, with accessibility off.
664 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-bookmarks.pdf")); 688 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-bookmarks.pdf"));
665 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); 689 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
666 ASSERT_TRUE(guest_contents); 690 ASSERT_TRUE(guest_contents);
667 691
668 // Now enable accessibility globally, and assert that the PDF accessibility 692 // Now enable accessibility globally, and assert that the PDF accessibility
669 // tree loads. 693 // tree loads.
670 EnableAccessibilityForWebContents(guest_contents); 694 EnableAccessibilityForWebContents(guest_contents);
671 WaitForAccessibilityTreeToContainNodeWithName(guest_contents, 695 WaitForAccessibilityTreeToContainNodeWithName(guest_contents,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 ASSERT_EQ(web_contents, active_web_contents); 1014 ASSERT_EQ(web_contents, active_web_contents);
991 1015
992 content::WebContents* new_web_contents = 1016 content::WebContents* new_web_contents =
993 browser()->tab_strip_model()->GetWebContentsAt(1); 1017 browser()->tab_strip_model()->GetWebContentsAt(1);
994 ASSERT_TRUE(new_web_contents); 1018 ASSERT_TRUE(new_web_contents);
995 ASSERT_NE(web_contents, new_web_contents); 1019 ASSERT_NE(web_contents, new_web_contents);
996 1020
997 const GURL& url = new_web_contents->GetURL(); 1021 const GURL& url = new_web_contents->GetURL();
998 ASSERT_EQ(GURL("http://www.example.com"), url); 1022 ASSERT_EQ(GURL("http://www.example.com"), url);
999 } 1023 }
OLDNEW
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698