Chromium Code Reviews| 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 <limits.h> | 5 #include <limits.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 33 #include "chrome/browser/ui/browser_commands.h" | 33 #include "chrome/browser/ui/browser_commands.h" |
| 34 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 36 #include "chrome/browser/ui/views/frame/browser_view.h" | 36 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 37 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 37 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
| 38 #include "chrome/test/base/ui_test_utils.h" | 38 #include "chrome/test/base/ui_test_utils.h" |
| 39 #include "components/prefs/pref_service.h" | 39 #include "components/prefs/pref_service.h" |
| 40 #include "content/public/browser/browser_context.h" | 40 #include "content/public/browser/browser_context.h" |
| 41 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/render_frame_host.h" | |
| 42 #include "content/public/browser/storage_partition.h" | 43 #include "content/public/browser/storage_partition.h" |
| 43 #include "content/public/common/page_zoom.h" | 44 #include "content/public/common/page_zoom.h" |
| 44 #include "content/public/common/url_constants.h" | 45 #include "content/public/common/url_constants.h" |
| 45 #include "content/public/test/browser_test_utils.h" | 46 #include "content/public/test/browser_test_utils.h" |
| 46 #include "extensions/browser/api_test_utils.h" | 47 #include "extensions/browser/api_test_utils.h" |
| 47 #include "extensions/browser/app_window/app_window.h" | 48 #include "extensions/browser/app_window/app_window.h" |
| 48 #include "extensions/browser/app_window/app_window_registry.h" | 49 #include "extensions/browser/app_window/app_window_registry.h" |
| 49 #include "extensions/common/manifest_constants.h" | 50 #include "extensions/common/manifest_constants.h" |
| 50 #include "extensions/common/test_util.h" | 51 #include "extensions/common/test_util.h" |
| 51 #include "extensions/test/extension_test_message_listener.h" | 52 #include "extensions/test/extension_test_message_listener.h" |
| (...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2109 EXPECT_TRUE( | 2110 EXPECT_TRUE( |
| 2110 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 2111 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
| 2111 | 2112 |
| 2112 // chrome.tabs.setZoomSettings(). | 2113 // chrome.tabs.setZoomSettings(). |
| 2113 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 2114 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
| 2114 EXPECT_TRUE( | 2115 EXPECT_TRUE( |
| 2115 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 2116 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
| 2116 } | 2117 } |
| 2117 | 2118 |
| 2118 // Regression test for crbug.com/660498. | 2119 // Regression test for crbug.com/660498. |
| 2119 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Foo) { | 2120 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TemporaryAddressSpoof) { |
| 2120 ASSERT_TRUE(StartEmbeddedTestServer()); | 2121 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 2121 content::WebContents* first_web_contents = | 2122 content::WebContents* first_web_contents = |
| 2122 browser()->tab_strip_model()->GetActiveWebContents(); | 2123 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2123 ASSERT_TRUE(first_web_contents); | 2124 ASSERT_TRUE(first_web_contents); |
| 2124 chrome::NewTab(browser()); | 2125 chrome::NewTab(browser()); |
| 2125 content::WebContents* second_web_contents = | 2126 content::WebContents* second_web_contents = |
| 2126 browser()->tab_strip_model()->GetActiveWebContents(); | 2127 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2127 ASSERT_NE(first_web_contents, second_web_contents); | 2128 ASSERT_NE(first_web_contents, second_web_contents); |
| 2128 GURL url = embedded_test_server()->GetURL( | 2129 GURL url = embedded_test_server()->GetURL( |
| 2129 "/extensions/api_test/tabs/pdf_extension_test.html"); | 2130 "/extensions/api_test/tabs/pdf_extension_test.html"); |
| 2130 content::TestNavigationManager navigation_manager( | 2131 content::TestNavigationManager navigation_manager( |
| 2131 second_web_contents, GURL("http://www.facebook.com:83")); | 2132 second_web_contents, GURL("http://www.facebook.com:83")); |
| 2132 ui_test_utils::NavigateToURLWithDisposition( | 2133 ui_test_utils::NavigateToURLWithDisposition( |
| 2133 browser(), url, WindowOpenDisposition::CURRENT_TAB, | 2134 browser(), url, WindowOpenDisposition::CURRENT_TAB, |
| 2134 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2135 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 2135 EXPECT_TRUE(navigation_manager.WaitForRequestStart()); | 2136 EXPECT_TRUE(navigation_manager.WaitForRequestStart()); |
| 2136 | 2137 |
| 2137 browser()->tab_strip_model()->ActivateTabAt(0, true); | 2138 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 2138 EXPECT_EQ(first_web_contents, | 2139 EXPECT_EQ(first_web_contents, |
| 2139 browser()->tab_strip_model()->GetActiveWebContents()); | 2140 browser()->tab_strip_model()->GetActiveWebContents()); |
| 2140 browser()->tab_strip_model()->ActivateTabAt(1, true); | 2141 browser()->tab_strip_model()->ActivateTabAt(1, true); |
| 2141 EXPECT_EQ(second_web_contents, | 2142 EXPECT_EQ(second_web_contents, |
| 2142 browser()->tab_strip_model()->GetActiveWebContents()); | 2143 browser()->tab_strip_model()->GetActiveWebContents()); |
| 2143 | 2144 |
| 2144 EXPECT_EQ(url, second_web_contents->GetVisibleURL()); | 2145 EXPECT_EQ(url, second_web_contents->GetVisibleURL()); |
| 2145 } | 2146 } |
| 2146 | 2147 |
| 2148 // Window created by chrome.windows.create should be in the same SiteInstance | |
| 2149 // and BrowsingInstance as the opener - this is a regression test for | |
| 2150 // hangouts-vs-isolate-extensions-trouble (see also https://crbug.com/597750). | |
| 2151 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowsCreateVsSiteInstance) { | |
| 2152 const extensions::Extension* extension = | |
| 2153 LoadExtension(test_data_dir_.AppendASCII("../simple_with_file")); | |
| 2154 ASSERT_TRUE(extension); | |
| 2155 | |
| 2156 // Navigate a tab to an extension page. | |
| 2157 GURL extension_url = extension->GetResourceURL("file.html"); | |
| 2158 ui_test_utils::NavigateToURL(browser(), extension_url); | |
| 2159 content::WebContents* old_contents = | |
| 2160 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 2161 | |
| 2162 // Execute chrome.windows.create and store the new tab in |new_contents|. | |
| 2163 content::WebContents* new_contents; | |
|
Devlin
2017/04/20 21:06:10
nit: initialize (to nullptr)
Łukasz Anforowicz
2017/04/20 21:56:05
Done.
| |
| 2164 { | |
| 2165 content::WebContentsAddedObserver observer; | |
| 2166 ASSERT_TRUE(content::ExecuteScript(old_contents, | |
| 2167 "window.name = 'test-name';\n" | |
| 2168 "chrome.windows.create({url: '" + | |
| 2169 extension_url.spec() + "'})")); | |
| 2170 new_contents = observer.GetWebContents(); | |
| 2171 } | |
| 2172 | |
| 2173 // Verify that the old and new tab are in the same process and SiteInstance. | |
| 2174 // Note: both test assertions are important - one observed failure mode was | |
| 2175 // having the same process, but different SiteInstance. | |
| 2176 EXPECT_EQ(old_contents->GetMainFrame()->GetProcess(), | |
| 2177 new_contents->GetMainFrame()->GetProcess()); | |
| 2178 EXPECT_EQ(old_contents->GetMainFrame()->GetSiteInstance(), | |
| 2179 new_contents->GetMainFrame()->GetSiteInstance()); | |
| 2180 | |
| 2181 // Verify that the |new_contents| doesn't have a |window.opener| set. | |
| 2182 bool window_opener_cast_to_bool; | |
|
Devlin
2017/04/20 21:06:10
nit: initialize
Łukasz Anforowicz
2017/04/20 21:56:05
Done.
| |
| 2183 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 2184 new_contents, "window.domAutomationController.send(!!window.opener)", | |
| 2185 &window_opener_cast_to_bool)); | |
| 2186 EXPECT_FALSE(window_opener_cast_to_bool); | |
| 2187 } | |
| 2188 | |
| 2147 } // namespace extensions | 2189 } // namespace extensions |
| OLD | NEW |