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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 728 |
729 // Verify that the browser action turned the background color red. | 729 // Verify that the browser action turned the background color red. |
730 const std::string script = | 730 const std::string script = |
731 "window.domAutomationController.send(document.body.style." | 731 "window.domAutomationController.send(document.body.style." |
732 "backgroundColor);"; | 732 "backgroundColor);"; |
733 std::string result; | 733 std::string result; |
734 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); | 734 EXPECT_TRUE(content::ExecuteScriptAndExtractString(tab, script, &result)); |
735 EXPECT_EQ(result, "red"); | 735 EXPECT_EQ(result, "red"); |
736 } | 736 } |
737 | 737 |
738 // Test that a browser action popup with a web iframe works correctly. This | 738 // Test that a browser action popup with a web iframe works correctly. The |
739 // primarily targets --isolate-extensions and --site-per-process modes, where | 739 // iframe is expected to run in a separate process. |
740 // the iframe runs in a separate process. See https://crbug.com/546267. | 740 // See https://crbug.com/546267. |
741 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) { | 741 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) { |
742 ASSERT_TRUE(embedded_test_server()->Start()); | 742 ASSERT_TRUE(embedded_test_server()->Start()); |
743 | 743 |
744 ASSERT_TRUE(LoadExtension( | 744 ASSERT_TRUE(LoadExtension( |
745 test_data_dir_.AppendASCII("browser_action/popup_with_iframe"))); | 745 test_data_dir_.AppendASCII("browser_action/popup_with_iframe"))); |
746 BrowserActionTestUtil* actions_bar = GetBrowserActionsBar(); | 746 BrowserActionTestUtil* actions_bar = GetBrowserActionsBar(); |
747 const Extension* extension = GetSingleLoadedExtension(); | 747 const Extension* extension = GetSingleLoadedExtension(); |
748 ASSERT_TRUE(extension) << message_; | 748 ASSERT_TRUE(extension) << message_; |
749 | 749 |
750 // Simulate a click on the browser action to open the popup. | 750 // Simulate a click on the browser action to open the popup. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 } | 946 } |
947 | 947 |
948 const Extension* popup_extension_; | 948 const Extension* popup_extension_; |
949 const Extension* other_extension_; | 949 const Extension* other_extension_; |
950 }; | 950 }; |
951 | 951 |
952 // Tests that an extension pop-up cannot be navigated to a web page. | 952 // Tests that an extension pop-up cannot be navigated to a web page. |
953 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, Webpage) { | 953 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, Webpage) { |
954 GURL web_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); | 954 GURL web_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
955 | 955 |
956 // With and without --isolate-extension the GET request will be blocked in | 956 // The GET request will be blocked in ExtensionViewHost::OpenURLFromTab |
957 // ExtensionViewHost::OpenURLFromTab (which silently drops navigations with | 957 // (which silently drops navigations with CURRENT_TAB disposition). |
958 // CURRENT_TAB disposition). | |
959 TestPopupNavigationViaGet(web_url, EXPECTING_NAVIGATION_FAILURE); | 958 TestPopupNavigationViaGet(web_url, EXPECTING_NAVIGATION_FAILURE); |
960 | 959 |
961 // POST requests don't go through ExtensionViewHost::OpenURLFromTab. | 960 // POST requests don't go through ExtensionViewHost::OpenURLFromTab. |
962 // | 961 TestPopupNavigationViaPost(web_url, EXPECTING_NAVIGATION_FAILURE); |
963 // Without --isolate-extensions, there is no process transfer to isolate | |
964 // extensions into separate processes and therefore | |
965 // 1) navigating a popup extension to a webpage will succeed (because | |
966 // ExtensionViewHost::ShouldTransferNavigation won't get called when there | |
967 // is no transfer), | |
968 // 2) the webpage will stay in the same renderer process. | |
969 // This behavior is okay without --isolate-extensions (where webpages and | |
970 // extensions can coexist in the same process in other scenarios) - therefore | |
971 // no test verification is needed in this case. | |
972 // | |
973 // With --isolate-extensions the navigation should be blocked by | |
974 // ExtensionViewHost::ShouldTransferNavigation. Test verification is | |
975 // important in --isolate-extensions mode, because this mode is all about | |
976 // isolating extensions and webpages into separate processes and therefore we | |
977 // need to ensure the behavior described above doesn't occur (i.e. that | |
978 // instead the webpage navigation in an extension popup fails). | |
979 if (extensions::IsIsolateExtensionsEnabled()) | |
980 TestPopupNavigationViaPost(web_url, EXPECTING_NAVIGATION_FAILURE); | |
981 } | 962 } |
982 | 963 |
983 // Tests that an extension pop-up can be navigated to another page | 964 // Tests that an extension pop-up can be navigated to another page |
984 // in the same extension. | 965 // in the same extension. |
985 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, | 966 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, |
986 PageInSameExtension) { | 967 PageInSameExtension) { |
987 GURL other_page_in_same_extension = | 968 GURL other_page_in_same_extension = |
988 popup_extension().GetResourceURL("other_page.html"); | 969 popup_extension().GetResourceURL("other_page.html"); |
989 TestPopupNavigationViaGet(other_page_in_same_extension, | 970 TestPopupNavigationViaGet(other_page_in_same_extension, |
990 EXPECTING_NAVIGATION_SUCCESS); | 971 EXPECTING_NAVIGATION_SUCCESS); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 // The test verification below is applicable only to scenarios where the | 1027 // The test verification below is applicable only to scenarios where the |
1047 // download shelf is supported - on ChromeOS, instead of the download shelf, | 1028 // download shelf is supported - on ChromeOS, instead of the download shelf, |
1048 // there is a download notification in the right-bottom corner of the screen. | 1029 // there is a download notification in the right-bottom corner of the screen. |
1049 #if !defined(OS_CHROMEOS) | 1030 #if !defined(OS_CHROMEOS) |
1050 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 1031 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
1051 #endif | 1032 #endif |
1052 } | 1033 } |
1053 | 1034 |
1054 } // namespace | 1035 } // namespace |
1055 } // namespace extensions | 1036 } // namespace extensions |
OLD | NEW |