| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser_list.h" | 6 #include "chrome/browser/browser_list.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 104 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
| 105 EXPECT_NE(host->process(), | 105 EXPECT_NE(host->process(), |
| 106 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 106 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
| 107 | 107 |
| 108 // Now let's do the same using window.open. The same should happen. | 108 // Now let's do the same using window.open. The same should happen. |
| 109 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 109 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); |
| 110 WindowOpenHelper(browser(), host, | 110 WindowOpenHelper(browser(), host, |
| 111 base_url.Resolve("path1/empty.html"), true); | 111 base_url.Resolve("path1/empty.html"), true); |
| 112 WindowOpenHelper(browser(), host, | 112 WindowOpenHelper(browser(), host, |
| 113 base_url.Resolve("path2/empty.html"), true); | 113 base_url.Resolve("path2/empty.html"), true); |
| 114 // TODO(creis): This should open in a new process (i.e., false for the last |
| 115 // argument), but we temporarily keep pages with a valid window.opener in the |
| 116 // same process until we're able to restore window.opener if the page later |
| 117 // returns to an in-app URL. See crbug.com/65953. |
| 114 WindowOpenHelper(browser(), host, | 118 WindowOpenHelper(browser(), host, |
| 115 base_url.Resolve("path3/empty.html"), false); | 119 base_url.Resolve("path3/empty.html"), true); |
| 116 | 120 |
| 117 // Now let's have these pages navigate, into or out of the extension web | 121 // Now let's have these pages navigate, into or out of the extension web |
| 118 // extent. They should switch processes. | 122 // extent. They should switch processes. |
| 119 const GURL& app_url(base_url.Resolve("path1/empty.html")); | 123 const GURL& app_url(base_url.Resolve("path1/empty.html")); |
| 120 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); | 124 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); |
| 121 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); | 125 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); |
| 122 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); | 126 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); |
| 123 EXPECT_NE(host->process(), | 127 // TODO(creis): This should swap out of the app's process (i.e., EXPECT_NE), |
| 128 // but we temporarily avoid swapping away from an app in case it needs to |
| 129 // communicate with window.opener later. See crbug.com/65953. |
| 130 EXPECT_EQ(host->process(), |
| 124 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 131 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
| 125 EXPECT_EQ(host->process(), | 132 EXPECT_EQ(host->process(), |
| 126 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 133 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
| 134 |
| 135 // If one of the popup tabs navigates back to the app, window.opener should |
| 136 // be valid. |
| 137 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); |
| 138 EXPECT_EQ(host->process(), |
| 139 browser()->GetTabContentsAt(6)->render_view_host()->process()); |
| 140 bool windowOpenerValid = false; |
| 141 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 142 browser()->GetTabContentsAt(6)->render_view_host(), L"", |
| 143 L"window.domAutomationController.send(window.opener != null)", |
| 144 &windowOpenerValid)); |
| 145 ASSERT_TRUE(windowOpenerValid); |
| 127 } | 146 } |
| OLD | NEW |