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_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/process_map.h" | 9 #include "chrome/browser/extensions/process_map.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 145 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
146 | 146 |
147 // Now let's do the same using window.open. The same should happen. | 147 // Now let's do the same using window.open. The same should happen. |
148 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 148 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); |
149 WindowOpenHelper(browser(), host, | 149 WindowOpenHelper(browser(), host, |
150 base_url.Resolve("path1/empty.html"), true); | 150 base_url.Resolve("path1/empty.html"), true); |
151 LOG(INFO) << "WindowOpenHelper 1."; | 151 LOG(INFO) << "WindowOpenHelper 1."; |
152 WindowOpenHelper(browser(), host, | 152 WindowOpenHelper(browser(), host, |
153 base_url.Resolve("path2/empty.html"), true); | 153 base_url.Resolve("path2/empty.html"), true); |
154 LOG(INFO) << "WindowOpenHelper 2."; | 154 LOG(INFO) << "WindowOpenHelper 2."; |
155 // TODO(creis): This should open in a new process (i.e., false for the last | 155 // This should open in a new process (i.e., false for the last argument). |
156 // argument), but we temporarily avoid swapping processes away from an app | |
157 // until we're able to support cross-process postMessage calls. | |
158 // See crbug.com/59285. | |
159 WindowOpenHelper(browser(), host, | 156 WindowOpenHelper(browser(), host, |
160 base_url.Resolve("path3/empty.html"), true); | 157 base_url.Resolve("path3/empty.html"), false); |
161 LOG(INFO) << "WindowOpenHelper 3."; | 158 LOG(INFO) << "WindowOpenHelper 3."; |
162 | 159 |
163 // Now let's have these pages navigate, into or out of the extension web | 160 // Now let's have these pages navigate, into or out of the extension web |
164 // extent. They should switch processes. | 161 // extent. They should switch processes. |
165 const GURL& app_url(base_url.Resolve("path1/empty.html")); | 162 const GURL& app_url(base_url.Resolve("path1/empty.html")); |
166 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); | 163 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); |
167 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); | 164 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); |
168 LOG(INFO) << "NavigateTabHelper 1."; | 165 LOG(INFO) << "NavigateTabHelper 1."; |
169 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); | 166 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); |
170 LOG(INFO) << "NavigateTabHelper 2."; | 167 LOG(INFO) << "NavigateTabHelper 2."; |
171 // TODO(creis): This should swap out of the app's process (i.e., EXPECT_NE), | 168 EXPECT_NE(host->process(), |
172 // but we temporarily avoid swapping away from an app in case the window | |
173 // tries to send a postMessage to the app. See crbug.com/59285. | |
174 EXPECT_EQ(host->process(), | |
175 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 169 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
176 EXPECT_EQ(host->process(), | 170 EXPECT_EQ(host->process(), |
177 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 171 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
178 | 172 |
179 // If one of the popup tabs navigates back to the app, window.opener should | 173 // If one of the popup tabs navigates back to the app, window.opener should |
180 // be valid. | 174 // be valid. |
181 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); | 175 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); |
182 LOG(INFO) << "NavigateTabHelper 3."; | 176 LOG(INFO) << "NavigateTabHelper 3."; |
183 EXPECT_EQ(host->process(), | 177 EXPECT_EQ(host->process(), |
184 browser()->GetTabContentsAt(6)->render_view_host()->process()); | 178 browser()->GetTabContentsAt(6)->render_view_host()->process()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 ASSERT_TRUE(test_server()->Start()); | 341 ASSERT_TRUE(test_server()->Start()); |
348 | 342 |
349 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 343 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
350 | 344 |
351 // Open two tabs in the app. | 345 // Open two tabs in the app. |
352 GURL base_url = GetTestBaseURL("app_process"); | 346 GURL base_url = GetTestBaseURL("app_process"); |
353 | 347 |
354 browser()->NewTab(); | 348 browser()->NewTab(); |
355 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 349 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
356 browser()->NewTab(); | 350 browser()->NewTab(); |
357 // Wait until the second tab finishes its redirect train (3 hops). | 351 // Wait until the second tab finishes its redirect train (2 hops). |
358 // 1. We navigate to redirect.html | 352 // 1. We navigate to redirect.html |
359 // 2. Renderer navigates and finishes, counting as a load stop. | 353 // 2. Renderer navigates and finishes, counting as a load stop. |
360 // 3. Renderer issues the meta refresh to navigate to server-redirect. | 354 // 3. Renderer issues the meta refresh to navigate to server-redirect. |
361 // 4. Renderer is now in a "provisional load", waiting for navigation to | 355 // 4. Renderer is now in a "provisional load", waiting for navigation to |
362 // complete. | 356 // complete. |
363 // 5. Browser sees a redirect response from server-redirect to empty.html, and | 357 // 5. Browser sees a redirect response from server-redirect to empty.html, and |
364 // transfers that to a new navigation, using RequestTransferURL. | 358 // transfers that to a new navigation, using RequestTransferURL. |
365 // 6. We navigate to empty.html. | |
366 // 7. Renderer is still in a provisional load to server-redirect, so that is | |
367 // cancelled, and counts as a load stop | |
368 // 8. Renderer navigates to empty.html, and finishes loading, counting as the | 359 // 8. Renderer navigates to empty.html, and finishes loading, counting as the |
369 // third load stop | 360 // second load stop |
370 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 361 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
371 browser(), base_url.Resolve("path1/redirect.html"), 3); | 362 browser(), base_url.Resolve("path1/redirect.html"), 2); |
372 | 363 |
373 // 3 tabs, including the initial about:blank. The last 2 should be the same | 364 // 3 tabs, including the initial about:blank. The last 2 should be the same |
374 // process. | 365 // process. |
375 ASSERT_EQ(3, browser()->tab_count()); | 366 ASSERT_EQ(3, browser()->tab_count()); |
376 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", | 367 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", |
377 browser()->GetTabContentsAt(2)->controller(). | 368 browser()->GetTabContentsAt(2)->controller(). |
378 GetLastCommittedEntry()->url().path()); | 369 GetLastCommittedEntry()->url().path()); |
379 EXPECT_EQ(browser()->GetTabContentsAt(1)->render_view_host()->process(), | 370 EXPECT_EQ(browser()->GetTabContentsAt(1)->render_view_host()->process(), |
380 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 371 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
381 } | 372 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 645 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
655 controller())); | 646 controller())); |
656 browser()->Reload(CURRENT_TAB); | 647 browser()->Reload(CURRENT_TAB); |
657 observer.Wait(); | 648 observer.Wait(); |
658 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 649 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
659 contents->render_view_host(), L"", | 650 contents->render_view_host(), L"", |
660 L"window.domAutomationController.send(chrome.app.isInstalled)", | 651 L"window.domAutomationController.send(chrome.app.isInstalled)", |
661 &is_installed)); | 652 &is_installed)); |
662 ASSERT_TRUE(is_installed); | 653 ASSERT_TRUE(is_installed); |
663 } | 654 } |
OLD | NEW |