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 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2101 EXPECT_TRUE( | 2102 EXPECT_TRUE( |
2102 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 2103 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
2103 | 2104 |
2104 // chrome.tabs.setZoomSettings(). | 2105 // chrome.tabs.setZoomSettings(). |
2105 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 2106 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
2106 EXPECT_TRUE( | 2107 EXPECT_TRUE( |
2107 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 2108 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
2108 } | 2109 } |
2109 | 2110 |
2110 // Regression test for crbug.com/660498. | 2111 // Regression test for crbug.com/660498. |
2111 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Foo) { | 2112 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TemporaryAddressSpoof) { |
2112 ASSERT_TRUE(StartEmbeddedTestServer()); | 2113 ASSERT_TRUE(StartEmbeddedTestServer()); |
2113 content::WebContents* first_web_contents = | 2114 content::WebContents* first_web_contents = |
2114 browser()->tab_strip_model()->GetActiveWebContents(); | 2115 browser()->tab_strip_model()->GetActiveWebContents(); |
2115 ASSERT_TRUE(first_web_contents); | 2116 ASSERT_TRUE(first_web_contents); |
2116 chrome::NewTab(browser()); | 2117 chrome::NewTab(browser()); |
2117 content::WebContents* second_web_contents = | 2118 content::WebContents* second_web_contents = |
2118 browser()->tab_strip_model()->GetActiveWebContents(); | 2119 browser()->tab_strip_model()->GetActiveWebContents(); |
2119 ASSERT_NE(first_web_contents, second_web_contents); | 2120 ASSERT_NE(first_web_contents, second_web_contents); |
2120 GURL url = embedded_test_server()->GetURL( | 2121 GURL url = embedded_test_server()->GetURL( |
2121 "/extensions/api_test/tabs/pdf_extension_test.html"); | 2122 "/extensions/api_test/tabs/pdf_extension_test.html"); |
2122 content::TestNavigationManager navigation_manager( | 2123 content::TestNavigationManager navigation_manager( |
2123 second_web_contents, GURL("http://www.facebook.com:83")); | 2124 second_web_contents, GURL("http://www.facebook.com:83")); |
2124 ui_test_utils::NavigateToURLWithDisposition( | 2125 ui_test_utils::NavigateToURLWithDisposition( |
2125 browser(), url, WindowOpenDisposition::CURRENT_TAB, | 2126 browser(), url, WindowOpenDisposition::CURRENT_TAB, |
2126 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2127 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
2127 EXPECT_TRUE(navigation_manager.WaitForRequestStart()); | 2128 EXPECT_TRUE(navigation_manager.WaitForRequestStart()); |
2128 | 2129 |
2129 browser()->tab_strip_model()->ActivateTabAt(0, true); | 2130 browser()->tab_strip_model()->ActivateTabAt(0, true); |
2130 EXPECT_EQ(first_web_contents, | 2131 EXPECT_EQ(first_web_contents, |
2131 browser()->tab_strip_model()->GetActiveWebContents()); | 2132 browser()->tab_strip_model()->GetActiveWebContents()); |
2132 browser()->tab_strip_model()->ActivateTabAt(1, true); | 2133 browser()->tab_strip_model()->ActivateTabAt(1, true); |
2133 EXPECT_EQ(second_web_contents, | 2134 EXPECT_EQ(second_web_contents, |
2134 browser()->tab_strip_model()->GetActiveWebContents()); | 2135 browser()->tab_strip_model()->GetActiveWebContents()); |
2135 | 2136 |
2136 EXPECT_EQ(url, second_web_contents->GetVisibleURL()); | 2137 EXPECT_EQ(url, second_web_contents->GetVisibleURL()); |
2137 } | 2138 } |
2138 | 2139 |
2140 // Window created by chrome.windows.create should be in the same site instance | |
alexmos
2017/02/09 22:58:36
nit: s/site instance/SiteInstance/
Łukasz Anforowicz
2017/02/10 00:38:18
Done.
| |
2141 // as the opener - regression test for hangouts-vs-isolate-extensions-trouble | |
2142 // (see also https://crbug.com/597750). | |
2143 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowCreateVsSiteInstance) { | |
2144 const extensions::Extension* extension = | |
2145 LoadExtension(test_data_dir_.AppendASCII("../simple_with_file")); | |
2146 ASSERT_TRUE(extension); | |
2147 | |
2148 GURL extension_url = extension->GetResourceURL("file.html"); | |
2149 ui_test_utils::NavigateToURL(browser(), extension_url); | |
2150 content::WebContents* old_contents = | |
2151 browser()->tab_strip_model()->GetActiveWebContents(); | |
2152 | |
2153 content::WebContentsAddedObserver observer; | |
2154 ASSERT_TRUE(content::ExecuteScript( | |
2155 old_contents, | |
2156 "window.name = 'test-name';\n" | |
2157 "chrome.windows.create({url: '" + extension_url.spec() + "'})")); | |
2158 content::WebContents* new_contents = observer.GetWebContents(); | |
2159 | |
2160 EXPECT_EQ(old_contents->GetMainFrame()->GetSiteInstance(), | |
2161 new_contents->GetMainFrame()->GetSiteInstance()); | |
2162 | |
2163 std::string url_of_found_window; | |
2164 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | |
2165 old_contents, | |
2166 "w = window.open('', 'test-name');\n" | |
2167 "window.domAutomationController.send(w.location.href)", | |
2168 &url_of_found_window)); | |
2169 EXPECT_EQ(extension_url.spec(), url_of_found_window); | |
alexmos
2017/02/09 22:58:36
I'm a bit confused here: is this testing that old_
Łukasz Anforowicz
2017/02/10 00:38:18
Doh... thanks for catching this. I meant to execu
| |
2170 } | |
2171 | |
2139 } // namespace extensions | 2172 } // namespace extensions |
OLD | NEW |