| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 GURL base_url = test_server()->GetURL( | 74 GURL base_url = test_server()->GetURL( |
| 75 "files/extensions/api_test/app_process/"); | 75 "files/extensions/api_test/app_process/"); |
| 76 | 76 |
| 77 // The app under test acts on URLs whose host is "localhost", | 77 // The app under test acts on URLs whose host is "localhost", |
| 78 // so the URLs we navigate to must have host "localhost". | 78 // so the URLs we navigate to must have host "localhost". |
| 79 GURL::Replacements replace_host; | 79 GURL::Replacements replace_host; |
| 80 std::string host_str("localhost"); // must stay in scope with replace_host | 80 std::string host_str("localhost"); // must stay in scope with replace_host |
| 81 replace_host.SetHostStr(host_str); | 81 replace_host.SetHostStr(host_str); |
| 82 base_url = base_url.ReplaceComponents(replace_host); | 82 base_url = base_url.ReplaceComponents(replace_host); |
| 83 | 83 |
| 84 browser()->NewTab(); | 84 // Test both opening a URL in a new tab, and opening a tab and then navigating |
| 85 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 85 // it. Either way, app tabs should be considered extension processes, but |
| 86 // they have no elevated privileges and thus should not have WebUI bindings. |
| 87 ui_test_utils::NavigateToURLWithDisposition( |
| 88 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
| 89 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 90 EXPECT_TRUE(browser()->GetTabContentsAt(1)->render_view_host()->process()-> |
| 91 is_extension_process()); |
| 92 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); |
| 86 browser()->NewTab(); | 93 browser()->NewTab(); |
| 87 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | 94 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); |
| 95 EXPECT_TRUE(browser()->GetTabContentsAt(2)->render_view_host()->process()-> |
| 96 is_extension_process()); |
| 97 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); |
| 88 browser()->NewTab(); | 98 browser()->NewTab(); |
| 89 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); | 99 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); |
| 100 EXPECT_FALSE(browser()->GetTabContentsAt(3)->render_view_host()->process()-> |
| 101 is_extension_process()); |
| 102 EXPECT_FALSE(browser()->GetTabContentsAt(3)->web_ui()); |
| 90 | 103 |
| 91 // The extension should have opened 3 new tabs. Including the original blank | 104 // The extension should have opened 3 new tabs. Including the original blank |
| 92 // tab, we now have 4 tabs. Two should be part of the extension app, and | 105 // tab, we now have 4 tabs. Two should be part of the extension app, and |
| 93 // grouped in the same process. | 106 // grouped in the same process. |
| 94 ASSERT_EQ(4, browser()->tab_count()); | 107 ASSERT_EQ(4, browser()->tab_count()); |
| 95 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); | 108 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); |
| 96 | 109 |
| 97 EXPECT_EQ(host->process(), | 110 EXPECT_EQ(host->process(), |
| 98 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 111 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
| 99 EXPECT_NE(host->process(), | 112 EXPECT_NE(host->process(), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // 3 tabs, including the initial about:blank. The last 2 should be the same | 182 // 3 tabs, including the initial about:blank. The last 2 should be the same |
| 170 // process. | 183 // process. |
| 171 ASSERT_EQ(3, browser()->tab_count()); | 184 ASSERT_EQ(3, browser()->tab_count()); |
| 172 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", | 185 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", |
| 173 browser()->GetTabContentsAt(2)->controller(). | 186 browser()->GetTabContentsAt(2)->controller(). |
| 174 GetLastCommittedEntry()->url().path()); | 187 GetLastCommittedEntry()->url().path()); |
| 175 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); | 188 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); |
| 176 EXPECT_EQ(host->process(), | 189 EXPECT_EQ(host->process(), |
| 177 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 190 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
| 178 } | 191 } |
| OLD | NEW |