OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 // Verify that the browser action turned the background color red. | 724 // Verify that the browser action turned the background color red. |
725 const std::string script = | 725 const std::string script = |
726 "window.domAutomationController.send(document.body.style." | 726 "window.domAutomationController.send(document.body.style." |
727 "backgroundColor);"; | 727 "backgroundColor);"; |
728 std::string result; | 728 std::string result; |
729 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); | 729 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); |
730 EXPECT_EQ(result, "red"); | 730 EXPECT_EQ(result, "red"); |
731 } | 731 } |
732 | 732 |
733 // Test that a browser action popup with a web iframe works correctly. This | 733 // Test that a browser action popup with a web iframe works correctly. This |
734 // primarily targets --isolate-extensions and --site-per-process modes, where | 734 // primarily targets site isolation modes, such as --site-per-process, where |
735 // the iframe runs in a separate process. See https://crbug.com/546267. | 735 // the iframe runs in a separate process. See https://crbug.com/546267. |
ncarter (slow)
2017/05/01 20:15:19
"This primarily targets ..." -> "The iframe is exp
nasko
2017/05/01 21:25:37
Done.
| |
736 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) { | 736 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) { |
737 host_resolver()->AddRule("*", "127.0.0.1"); | 737 host_resolver()->AddRule("*", "127.0.0.1"); |
738 ASSERT_TRUE(embedded_test_server()->Start()); | 738 ASSERT_TRUE(embedded_test_server()->Start()); |
739 | 739 |
740 ASSERT_TRUE(LoadExtension( | 740 ASSERT_TRUE(LoadExtension( |
741 test_data_dir_.AppendASCII("browser_action/popup_with_iframe"))); | 741 test_data_dir_.AppendASCII("browser_action/popup_with_iframe"))); |
742 BrowserActionTestUtil* actions_bar = GetBrowserActionsBar(); | 742 BrowserActionTestUtil* actions_bar = GetBrowserActionsBar(); |
743 const Extension* extension = GetSingleLoadedExtension(); | 743 const Extension* extension = GetSingleLoadedExtension(); |
744 ASSERT_TRUE(extension) << message_; | 744 ASSERT_TRUE(extension) << message_; |
745 | 745 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 } | 943 } |
944 | 944 |
945 const Extension* popup_extension_; | 945 const Extension* popup_extension_; |
946 const Extension* other_extension_; | 946 const Extension* other_extension_; |
947 }; | 947 }; |
948 | 948 |
949 // Tests that an extension pop-up cannot be navigated to a web page. | 949 // Tests that an extension pop-up cannot be navigated to a web page. |
950 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, Webpage) { | 950 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, Webpage) { |
951 GURL web_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); | 951 GURL web_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
952 | 952 |
953 // With and without --isolate-extension the GET request will be blocked in | 953 // The GET request will be blocked in ExtensionViewHost::OpenURLFromTab |
954 // ExtensionViewHost::OpenURLFromTab (which silently drops navigations with | 954 // (which silently drops navigations with CURRENT_TAB disposition). |
955 // CURRENT_TAB disposition). | |
956 TestPopupNavigationViaGet(web_url, EXPECTING_NAVIGATION_FAILURE); | 955 TestPopupNavigationViaGet(web_url, EXPECTING_NAVIGATION_FAILURE); |
957 | 956 |
958 // POST requests don't go through ExtensionViewHost::OpenURLFromTab. | 957 // POST requests don't go through ExtensionViewHost::OpenURLFromTab. |
959 // | 958 TestPopupNavigationViaPost(web_url, EXPECTING_NAVIGATION_FAILURE); |
960 // Without --isolate-extensions, there is no process transfer to isolate | |
961 // extensions into separate processes and therefore | |
962 // 1) navigating a popup extension to a webpage will succeed (because | |
963 // ExtensionViewHost::ShouldTransferNavigation won't get called when there | |
964 // is no transfer), | |
965 // 2) the webpage will stay in the same renderer process. | |
966 // This behavior is okay without --isolate-extensions (where webpages and | |
967 // extensions can coexist in the same process in other scenarios) - therefore | |
968 // no test verification is needed in this case. | |
969 // | |
970 // With --isolate-extensions the navigation should be blocked by | |
971 // ExtensionViewHost::ShouldTransferNavigation. Test verification is | |
972 // important in --isolate-extensions mode, because this mode is all about | |
973 // isolating extensions and webpages into separate processes and therefore we | |
974 // need to ensure the behavior described above doesn't occur (i.e. that | |
975 // instead the webpage navigation in an extension popup fails). | |
976 if (extensions::IsIsolateExtensionsEnabled()) | |
977 TestPopupNavigationViaPost(web_url, EXPECTING_NAVIGATION_FAILURE); | |
978 } | 959 } |
979 | 960 |
980 // Tests that an extension pop-up can be navigated to another page | 961 // Tests that an extension pop-up can be navigated to another page |
981 // in the same extension. | 962 // in the same extension. |
982 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, | 963 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, |
983 PageInSameExtension) { | 964 PageInSameExtension) { |
984 GURL other_page_in_same_extension = | 965 GURL other_page_in_same_extension = |
985 popup_extension().GetResourceURL("other_page.html"); | 966 popup_extension().GetResourceURL("other_page.html"); |
986 TestPopupNavigationViaGet(other_page_in_same_extension, | 967 TestPopupNavigationViaGet(other_page_in_same_extension, |
987 EXPECTING_NAVIGATION_SUCCESS); | 968 EXPECTING_NAVIGATION_SUCCESS); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1043 // The test verification below is applicable only to scenarios where the | 1024 // The test verification below is applicable only to scenarios where the |
1044 // download shelf is supported - on ChromeOS, instead of the download shelf, | 1025 // download shelf is supported - on ChromeOS, instead of the download shelf, |
1045 // there is a download notification in the right-bottom corner of the screen. | 1026 // there is a download notification in the right-bottom corner of the screen. |
1046 #if !defined(OS_CHROMEOS) | 1027 #if !defined(OS_CHROMEOS) |
1047 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 1028 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
1048 #endif | 1029 #endif |
1049 } | 1030 } |
1050 | 1031 |
1051 } // namespace | 1032 } // namespace |
1052 } // namespace extensions | 1033 } // namespace extensions |
OLD | NEW |