OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 98 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
99 EXPECT_NE(host->process(), | 99 EXPECT_NE(host->process(), |
100 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 100 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
101 | 101 |
102 // Now let's do the same using window.open. The same should happen. | 102 // Now let's do the same using window.open. The same should happen. |
103 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 103 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); |
104 WindowOpenHelper(browser(), host, | 104 WindowOpenHelper(browser(), host, |
105 base_url.Resolve("path1/empty.html"), true); | 105 base_url.Resolve("path1/empty.html"), true); |
106 WindowOpenHelper(browser(), host, | 106 WindowOpenHelper(browser(), host, |
107 base_url.Resolve("path2/empty.html"), true); | 107 base_url.Resolve("path2/empty.html"), true); |
108 // TODO(creis): This should open in a new process (i.e., false for the last | 108 // This should open in a new process (i.e., false for the last argument). |
109 // argument), but we temporarily avoid swapping processes away from an app | |
110 // until we're able to restore window.opener if the page later returns to an | |
111 // in-app URL. See crbug.com/65953. | |
112 WindowOpenHelper(browser(), host, | 109 WindowOpenHelper(browser(), host, |
113 base_url.Resolve("path3/empty.html"), true); | 110 base_url.Resolve("path3/empty.html"), false); |
114 | 111 |
115 // Now let's have these pages navigate, into or out of the extension web | 112 // Now let's have these pages navigate, into or out of the extension web |
116 // extent. They should switch processes. | 113 // extent. They should switch processes. |
117 const GURL& app_url(base_url.Resolve("path1/empty.html")); | 114 const GURL& app_url(base_url.Resolve("path1/empty.html")); |
118 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); | 115 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); |
119 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); | 116 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); |
120 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); | 117 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); |
121 // TODO(creis): This should swap out of the app's process (i.e., EXPECT_NE), | 118 EXPECT_NE(host->process(), |
122 // but we temporarily avoid swapping away from an app in case it needs to | |
123 // communicate with window.opener later. See crbug.com/65953. | |
124 EXPECT_EQ(host->process(), | |
125 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 119 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
126 EXPECT_EQ(host->process(), | 120 EXPECT_EQ(host->process(), |
127 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 121 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
128 | 122 |
129 // If one of the popup tabs navigates back to the app, window.opener should | 123 // If one of the popup tabs navigates back to the app, window.opener should |
130 // be valid. | 124 // be valid. |
131 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); | 125 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); |
132 EXPECT_EQ(host->process(), | 126 EXPECT_EQ(host->process(), |
133 browser()->GetTabContentsAt(6)->render_view_host()->process()); | 127 browser()->GetTabContentsAt(6)->render_view_host()->process()); |
134 bool windowOpenerValid = false; | 128 bool windowOpenerValid = false; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // 3 tabs, including the initial about:blank. The last 2 should be the same | 169 // 3 tabs, including the initial about:blank. The last 2 should be the same |
176 // process. | 170 // process. |
177 ASSERT_EQ(3, browser()->tab_count()); | 171 ASSERT_EQ(3, browser()->tab_count()); |
178 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", | 172 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", |
179 browser()->GetTabContentsAt(2)->controller(). | 173 browser()->GetTabContentsAt(2)->controller(). |
180 GetLastCommittedEntry()->url().path()); | 174 GetLastCommittedEntry()->url().path()); |
181 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); | 175 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); |
182 EXPECT_EQ(host->process(), | 176 EXPECT_EQ(host->process(), |
183 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 177 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
184 } | 178 } |
OLD | NEW |