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

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

Issue 2407713002: Limit PDF helper extension to print preview only (Closed)
Patch Set: Use location.origin instead of location.ancestorOrigins. Created 4 years, 2 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/browser_api.js » ('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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 "</body></html>"; 457 "</body></html>";
458 TestGetSelectedTextReply(GURL(data_url), false); 458 TestGetSelectedTextReply(GURL(data_url), false);
459 } 459 }
460 460
461 // Ensure same-origin replies do work for getSelectedText. 461 // Ensure same-origin replies do work for getSelectedText.
462 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsureSameOriginRepliesAllowed) { 462 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsureSameOriginRepliesAllowed) {
463 TestGetSelectedTextReply(embedded_test_server()->GetURL("/pdf/test.pdf"), 463 TestGetSelectedTextReply(embedded_test_server()->GetURL("/pdf/test.pdf"),
464 true); 464 true);
465 } 465 }
466 466
467 // Ensure that the PDF component extension cannot be loaded directly.
468 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, BlockDirectAccess) {
469 content::WebContents* web_contents =
470 browser()->tab_strip_model()->GetActiveWebContents();
471
472 std::unique_ptr<content::ConsoleObserverDelegate> console_delegate(
473 new content::ConsoleObserverDelegate(
474 web_contents,
475 "*Streams are only available from a mime handler view guest.*"));
476 web_contents->SetDelegate(console_delegate.get());
477 GURL forbiddenUrl(
478 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?"
479 "https://example.com/notrequested.pdf");
480 ui_test_utils::NavigateToURL(browser(), forbiddenUrl);
481
482 console_delegate->Wait();
483 }
484
467 // This test ensures that PDF can be loaded from local file 485 // This test ensures that PDF can be loaded from local file
468 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsurePDFFromLocalFileLoads) { 486 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsurePDFFromLocalFileLoads) {
469 base::FilePath test_data_dir; 487 base::FilePath test_data_dir;
470 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); 488 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
471 test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf")); 489 test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf"));
472 base::FilePath test_data_file = test_data_dir.AppendASCII("test.pdf"); 490 base::FilePath test_data_file = test_data_dir.AppendASCII("test.pdf");
473 ASSERT_TRUE(PathExists(test_data_file)); 491 ASSERT_TRUE(PathExists(test_data_file));
474 GURL test_pdf_url("file://" + test_data_file.MaybeAsASCII()); 492 GURL test_pdf_url("file://" + test_data_file.MaybeAsASCII());
475 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); 493 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
476 ASSERT_TRUE(guest_contents); 494 ASSERT_TRUE(guest_contents);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 902
885 ASSERT_EQ(2U, chrome::GetTotalBrowserCount()); 903 ASSERT_EQ(2U, chrome::GetTotalBrowserCount());
886 904
887 content::WebContents* active_web_contents = 905 content::WebContents* active_web_contents =
888 chrome::FindLastActive()->tab_strip_model()->GetActiveWebContents(); 906 chrome::FindLastActive()->tab_strip_model()->GetActiveWebContents();
889 ASSERT_NE(web_contents, active_web_contents); 907 ASSERT_NE(web_contents, active_web_contents);
890 908
891 const GURL& url = active_web_contents->GetURL(); 909 const GURL& url = active_web_contents->GetURL();
892 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); 910 ASSERT_EQ(std::string("http://www.example.com/"), url.spec());
893 } 911 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/browser_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698