Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 2686943002: New WebContents created via ctrl-click should be in a new process. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowCreateVsSiteInstance) {
2141 const extensions::Extension* extension =
2142 LoadExtension(test_data_dir_.AppendASCII("../simple_with_file"));
2143 ASSERT_TRUE(extension);
2144
2145 GURL extension_url = extension->GetResourceURL("file.html");
2146 ui_test_utils::NavigateToURL(browser(), extension_url);
2147 content::WebContents* old_contents =
2148 browser()->tab_strip_model()->GetActiveWebContents();
2149
2150 content::WebContentsAddedObserver observer;
2151 ASSERT_TRUE(content::ExecuteScript(
2152 old_contents,
2153 "window.name = 'test-name';\n"
2154 "chrome.windows.create({url: '" + extension_url.spec() + "'})"));
2155 content::WebContents* new_contents = observer.GetWebContents();
2156
2157 EXPECT_EQ(old_contents->GetMainFrame()->GetSiteInstance(),
2158 new_contents->GetMainFrame()->GetSiteInstance());
2159
2160 std::string url_of_found_window;
2161 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
2162 old_contents,
2163 "w = window.open('', 'test-name');\n"
2164 "window.domAutomationController.send(w.location.href)",
2165 &url_of_found_window));
2166 EXPECT_EQ(extension_url.spec(), url_of_found_window);
2167 }
Łukasz Anforowicz 2017/02/09 16:53:01 1. I am not sure if this is the right location for
alexmos 2017/02/09 22:58:36 This seems like a reasonable place for it. Anothe
2168
2139 } // namespace extensions 2169 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698