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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, "*Refused to load the standalone extension.*")); | |
475 web_contents->SetDelegate(console_delegate.get()); | |
476 GURL forbiddenUrl( | |
477 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?" | |
478 "https://example.com/notrequested.pdf"); | |
479 ui_test_utils::NavigateToURL(browser(), forbiddenUrl); | |
480 | |
481 console_delegate->Wait(); | |
raymes
2016/10/12 02:08:52
It could be good to verify that the plugin element
robwu
2016/10/12 11:33:28
The actual plugin is created asynchronously. I add
raymes
2016/10/13 00:43:22
Ah right. Ok - yeah testing the absence of success
| |
482 } | |
483 | |
467 // This test ensures that PDF can be loaded from local file | 484 // This test ensures that PDF can be loaded from local file |
468 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsurePDFFromLocalFileLoads) { | 485 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, EnsurePDFFromLocalFileLoads) { |
469 base::FilePath test_data_dir; | 486 base::FilePath test_data_dir; |
470 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | 487 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); |
471 test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf")); | 488 test_data_dir = test_data_dir.Append(FILE_PATH_LITERAL("pdf")); |
472 base::FilePath test_data_file = test_data_dir.AppendASCII("test.pdf"); | 489 base::FilePath test_data_file = test_data_dir.AppendASCII("test.pdf"); |
473 ASSERT_TRUE(PathExists(test_data_file)); | 490 ASSERT_TRUE(PathExists(test_data_file)); |
474 GURL test_pdf_url("file://" + test_data_file.MaybeAsASCII()); | 491 GURL test_pdf_url("file://" + test_data_file.MaybeAsASCII()); |
475 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | 492 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
476 ASSERT_TRUE(guest_contents); | 493 ASSERT_TRUE(guest_contents); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 | 901 |
885 ASSERT_EQ(2U, chrome::GetTotalBrowserCount()); | 902 ASSERT_EQ(2U, chrome::GetTotalBrowserCount()); |
886 | 903 |
887 content::WebContents* active_web_contents = | 904 content::WebContents* active_web_contents = |
888 chrome::FindLastActive()->tab_strip_model()->GetActiveWebContents(); | 905 chrome::FindLastActive()->tab_strip_model()->GetActiveWebContents(); |
889 ASSERT_NE(web_contents, active_web_contents); | 906 ASSERT_NE(web_contents, active_web_contents); |
890 | 907 |
891 const GURL& url = active_web_contents->GetURL(); | 908 const GURL& url = active_web_contents->GetURL(); |
892 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | 909 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
893 } | 910 } |
OLD | NEW |