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 "chrome/browser/browser.h" | 5 #include "chrome/browser/browser.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/profile.h" | 9 #include "chrome/browser/profile.h" |
10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 &result); | 50 &result); |
51 ASSERT_TRUE(result); | 51 ASSERT_TRUE(result); |
52 | 52 |
53 if (contents->controller().GetLastCommittedEntry() || | 53 if (contents->controller().GetLastCommittedEntry() || |
54 contents->controller().GetLastCommittedEntry()->url() != url) | 54 contents->controller().GetLastCommittedEntry()->url() != url) |
55 ui_test_utils::WaitForNavigation(&contents->controller()); | 55 ui_test_utils::WaitForNavigation(&contents->controller()); |
56 EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url()); | 56 EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url()); |
57 } | 57 } |
58 | 58 |
59 // This test is flaky, see bug 42497. | 59 // This test is flaky, see bug 42497. |
60 IN_PROC_BROWSER_TEST_F(AppApiTest, FLAKY_AppProcess) { | 60 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { |
61 host_resolver()->AddRule("*", "127.0.0.1"); | 61 host_resolver()->AddRule("*", "127.0.0.1"); |
62 StartHTTPServer(); | 62 StartHTTPServer(); |
63 | 63 |
64 ASSERT_TRUE(RunExtensionTest("app_process")) << message_; | 64 ASSERT_TRUE(RunExtensionTest("app_process")) << message_; |
65 | 65 |
66 Extension* extension = GetSingleLoadedExtension(); | 66 Extension* extension = GetSingleLoadedExtension(); |
67 ExtensionHost* host = browser()->profile()->GetExtensionProcessManager()-> | 67 ExtensionHost* host = browser()->profile()->GetExtensionProcessManager()-> |
68 GetBackgroundHostForExtension(extension); | 68 GetBackgroundHostForExtension(extension); |
69 ASSERT_TRUE(host); | 69 ASSERT_TRUE(host); |
70 | 70 |
71 // The extension should have opened 3 new tabs. Including the original blank | 71 // The extension should have opened 3 new tabs. Including the original blank |
72 // tab, we now have 4 tabs. Two should be part of the extension app, and | 72 // tab, we now have 4 tabs. Two should be part of the extension app, and |
73 // grouped in the extension process. | 73 // grouped in the extension process. |
74 ASSERT_EQ(4, browser()->tab_count()); | 74 ASSERT_EQ(4, browser()->tab_count()); |
75 EXPECT_EQ(host->render_process_host(), | 75 EXPECT_EQ(host->render_process_host(), |
76 browser()->GetTabContentsAt(1)->render_view_host()->process()); | 76 browser()->GetTabContentsAt(1)->render_view_host()->process()); |
77 EXPECT_EQ(host->render_process_host(), | 77 EXPECT_EQ(host->render_process_host(), |
78 browser()->GetTabContentsAt(2)->render_view_host()->process()); | 78 browser()->GetTabContentsAt(2)->render_view_host()->process()); |
79 EXPECT_NE(host->render_process_host(), | 79 EXPECT_NE(host->render_process_host(), |
80 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 80 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
81 | 81 |
82 // Now let's do the same using window.open. The same should happen. | 82 // Now let's do the same using window.open. The same should happen. |
| 83 GURL base_url("http://localhost:1337/files/extensions/api_test/app_process/"); |
83 WindowOpenHelper(browser(), host->render_view_host(), | 84 WindowOpenHelper(browser(), host->render_view_host(), |
84 browser()->GetTabContentsAt(1)->GetURL()); | 85 base_url.Resolve("path1/empty.html")); |
85 WindowOpenHelper(browser(), host->render_view_host(), | 86 WindowOpenHelper(browser(), host->render_view_host(), |
86 browser()->GetTabContentsAt(2)->GetURL()); | 87 base_url.Resolve("path2/empty.html")); |
87 WindowOpenHelper(browser(), host->render_view_host(), | 88 WindowOpenHelper(browser(), host->render_view_host(), |
88 browser()->GetTabContentsAt(3)->GetURL()); | 89 base_url.Resolve("path3/empty.html")); |
89 | 90 |
90 ASSERT_EQ(7, browser()->tab_count()); | 91 ASSERT_EQ(7, browser()->tab_count()); |
91 EXPECT_EQ(host->render_process_host(), | 92 EXPECT_EQ(host->render_process_host(), |
92 browser()->GetTabContentsAt(4)->render_view_host()->process()); | 93 browser()->GetTabContentsAt(4)->render_view_host()->process()); |
93 EXPECT_EQ(host->render_process_host(), | 94 EXPECT_EQ(host->render_process_host(), |
94 browser()->GetTabContentsAt(5)->render_view_host()->process()); | 95 browser()->GetTabContentsAt(5)->render_view_host()->process()); |
95 EXPECT_NE(host->render_process_host(), | 96 EXPECT_NE(host->render_process_host(), |
96 browser()->GetTabContentsAt(6)->render_view_host()->process()); | 97 browser()->GetTabContentsAt(6)->render_view_host()->process()); |
97 | 98 |
98 // Now let's have these pages navigate, into or out of the extension web | 99 // Now let's have these pages navigate, into or out of the extension web |
99 // extent. They should switch processes. | 100 // extent. They should switch processes. |
100 const GURL& app_url(browser()->GetTabContentsAt(1)->GetURL()); | 101 const GURL& app_url(base_url.Resolve("path1/empty.html")); |
101 const GURL& non_app_url(browser()->GetTabContentsAt(3)->GetURL()); | 102 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); |
102 NavigateTabHelper(browser()->GetTabContentsAt(1), non_app_url); | 103 NavigateTabHelper(browser()->GetTabContentsAt(1), non_app_url); |
103 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); | 104 NavigateTabHelper(browser()->GetTabContentsAt(3), app_url); |
104 EXPECT_NE(host->render_process_host(), | 105 EXPECT_NE(host->render_process_host(), |
105 browser()->GetTabContentsAt(1)->render_view_host()->process()); | 106 browser()->GetTabContentsAt(1)->render_view_host()->process()); |
106 EXPECT_EQ(host->render_process_host(), | 107 EXPECT_EQ(host->render_process_host(), |
107 browser()->GetTabContentsAt(3)->render_view_host()->process()); | 108 browser()->GetTabContentsAt(3)->render_view_host()->process()); |
108 } | 109 } |
OLD | NEW |