Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Side by Side Diff: chrome/browser/extensions/app_process_apitest.cc

Issue 8393026: Fix flakiness in NewTab() calls of AppApiTest browser_test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 L"window.addEventListener('unload', function() {" 71 L"window.addEventListener('unload', function() {"
72 L" window.domAutomationController.send(true);" 72 L" window.domAutomationController.send(true);"
73 L"}, false);" 73 L"}, false);"
74 L"window.location = '" + UTF8ToWide(url.spec()) + L"';", 74 L"window.location = '" + UTF8ToWide(url.spec()) + L"';",
75 &result)); 75 &result));
76 ASSERT_TRUE(result); 76 ASSERT_TRUE(result);
77 observer.Wait(); 77 observer.Wait();
78 EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url()); 78 EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url());
79 } 79 }
80 80
81 #if defined(OS_WIN) 81 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) {
82 // AppProcess sometimes hangs on Windows
83 // http://crbug.com/88316
84 #define MAYBE_AppProcess DISABLED_AppProcess
85 #else
86 #define MAYBE_AppProcess AppProcess
87 #endif
88
89 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcess) {
90 CommandLine::ForCurrentProcess()->AppendSwitch( 82 CommandLine::ForCurrentProcess()->AppendSwitch(
91 switches::kDisablePopupBlocking); 83 switches::kDisablePopupBlocking);
92 84
93 ExtensionProcessManager* extension_process_manager = 85 ExtensionProcessManager* extension_process_manager =
94 browser()->profile()->GetExtensionProcessManager(); 86 browser()->profile()->GetExtensionProcessManager();
95 87
96 host_resolver()->AddRule("*", "127.0.0.1"); 88 host_resolver()->AddRule("*", "127.0.0.1");
97 ASSERT_TRUE(test_server()->Start()); 89 ASSERT_TRUE(test_server()->Start());
98 90
99 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); 91 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process")));
100 92
101 // Open two tabs in the app, one outside it. 93 // Open two tabs in the app, one outside it.
102 GURL base_url = GetTestBaseURL("app_process"); 94 GURL base_url = GetTestBaseURL("app_process");
103 95
104 // Test both opening a URL in a new tab, and opening a tab and then navigating 96 // Test both opening a URL in a new tab, and opening a tab and then navigating
105 // it. Either way, app tabs should be considered extension processes, but 97 // it. Either way, app tabs should be considered extension processes, but
106 // they have no elevated privileges and thus should not have WebUI bindings. 98 // they have no elevated privileges and thus should not have WebUI bindings.
107 ui_test_utils::NavigateToURLWithDisposition( 99 ui_test_utils::NavigateToURLWithDisposition(
108 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, 100 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
109 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 101 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
110 EXPECT_TRUE(extension_process_manager->IsExtensionProcess( 102 EXPECT_TRUE(extension_process_manager->IsExtensionProcess(
111 browser()->GetTabContentsAt(1)->render_view_host()->process()->id())); 103 browser()->GetTabContentsAt(1)->render_view_host()->process()->id()));
112 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); 104 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui());
113 browser()->NewTab(); 105
114 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); 106 ui_test_utils::NavigateToURLWithDisposition(
107 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB,
108 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
115 EXPECT_TRUE(extension_process_manager->IsExtensionProcess( 109 EXPECT_TRUE(extension_process_manager->IsExtensionProcess(
116 browser()->GetTabContentsAt(2)->render_view_host()->process()->id())); 110 browser()->GetTabContentsAt(2)->render_view_host()->process()->id()));
117 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); 111 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui());
112
113 ui_test_utils::WindowedNotificationObserver tab_added_observer(
114 content::NOTIFICATION_TAB_ADDED,
115 content::NotificationService::AllSources());
118 browser()->NewTab(); 116 browser()->NewTab();
117 tab_added_observer.Wait();
119 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); 118 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html"));
120 EXPECT_FALSE(extension_process_manager->IsExtensionProcess( 119 EXPECT_FALSE(extension_process_manager->IsExtensionProcess(
121 browser()->GetTabContentsAt(3)->render_view_host()->process()->id())); 120 browser()->GetTabContentsAt(3)->render_view_host()->process()->id()));
122 EXPECT_FALSE(browser()->GetTabContentsAt(3)->web_ui()); 121 EXPECT_FALSE(browser()->GetTabContentsAt(3)->web_ui());
123 122
124 // We should have opened 3 new extension tabs. Including the original blank 123 // We should have opened 3 new extension tabs. Including the original blank
125 // tab, we now have 4 tabs. Because the app_process app has the background 124 // tab, we now have 4 tabs. Because the app_process app has the background
126 // permission, all of its instances are in the same process. Thus two tabs 125 // permission, all of its instances are in the same process. Thus two tabs
127 // should be part of the extension app and grouped in the same process. 126 // should be part of the extension app and grouped in the same process.
128 ASSERT_EQ(4, browser()->tab_count()); 127 ASSERT_EQ(4, browser()->tab_count());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_EQ(host->process(), 165 EXPECT_EQ(host->process(),
167 browser()->GetTabContentsAt(6)->render_view_host()->process()); 166 browser()->GetTabContentsAt(6)->render_view_host()->process());
168 bool windowOpenerValid = false; 167 bool windowOpenerValid = false;
169 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 168 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
170 browser()->GetTabContentsAt(6)->render_view_host(), L"", 169 browser()->GetTabContentsAt(6)->render_view_host(), L"",
171 L"window.domAutomationController.send(window.opener != null)", 170 L"window.domAutomationController.send(window.opener != null)",
172 &windowOpenerValid)); 171 &windowOpenerValid));
173 ASSERT_TRUE(windowOpenerValid); 172 ASSERT_TRUE(windowOpenerValid);
174 } 173 }
175 174
176
177 #if defined(OS_WIN)
178 // Seems to timeout sometimes on Windows: http://crbug.com/89766
179 #define MAYBE_AppProcessInstances FLAKY_AppProcessInstances
180 #else
181 #define MAYBE_AppProcessInstances AppProcessInstances
182 #endif
183
184 // Test that hosted apps without the background permission use a process per app 175 // Test that hosted apps without the background permission use a process per app
185 // instance model, such that separate instances are in separate processes. 176 // instance model, such that separate instances are in separate processes.
186 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcessInstances) { 177 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) {
187 CommandLine::ForCurrentProcess()->AppendSwitch( 178 CommandLine::ForCurrentProcess()->AppendSwitch(
188 switches::kDisablePopupBlocking); 179 switches::kDisablePopupBlocking);
189 180
190 ExtensionProcessManager* extension_process_manager = 181 ExtensionProcessManager* extension_process_manager =
191 browser()->profile()->GetExtensionProcessManager(); 182 browser()->profile()->GetExtensionProcessManager();
192 183
193 host_resolver()->AddRule("*", "127.0.0.1"); 184 host_resolver()->AddRule("*", "127.0.0.1");
194 ASSERT_TRUE(test_server()->Start()); 185 ASSERT_TRUE(test_server()->Start());
195 186
196 ASSERT_TRUE(LoadExtension( 187 ASSERT_TRUE(LoadExtension(
197 test_data_dir_.AppendASCII("app_process_instances"))); 188 test_data_dir_.AppendASCII("app_process_instances")));
198 189
199 // Open two tabs in the app, one outside it. 190 // Open two tabs in the app, one outside it.
200 GURL base_url = GetTestBaseURL("app_process_instances"); 191 GURL base_url = GetTestBaseURL("app_process_instances");
201 192
202 // Test both opening a URL in a new tab, and opening a tab and then navigating 193 // Test both opening a URL in a new tab, and opening a tab and then navigating
203 // it. Either way, app tabs should be considered extension processes, but 194 // it. Either way, app tabs should be considered extension processes, but
204 // they have no elevated privileges and thus should not have WebUI bindings. 195 // they have no elevated privileges and thus should not have WebUI bindings.
205 ui_test_utils::NavigateToURLWithDisposition( 196 ui_test_utils::NavigateToURLWithDisposition(
206 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, 197 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
207 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 198 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
208 EXPECT_TRUE(extension_process_manager->IsExtensionProcess( 199 EXPECT_TRUE(extension_process_manager->IsExtensionProcess(
209 browser()->GetTabContentsAt(1)->render_view_host()->process()->id())); 200 browser()->GetTabContentsAt(1)->render_view_host()->process()->id()));
210 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); 201 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui());
202
203 ui_test_utils::WindowedNotificationObserver tab_added_observer(
204 content::NOTIFICATION_TAB_ADDED,
205 content::NotificationService::AllSources());
211 browser()->NewTab(); 206 browser()->NewTab();
207 tab_added_observer.Wait();
212 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); 208 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html"));
213 EXPECT_TRUE(extension_process_manager->IsExtensionProcess( 209 EXPECT_TRUE(extension_process_manager->IsExtensionProcess(
214 browser()->GetTabContentsAt(2)->render_view_host()->process()->id())); 210 browser()->GetTabContentsAt(2)->render_view_host()->process()->id()));
215 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); 211 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui());
216 212
217 // We should have opened 2 new extension tabs. Including the original blank 213 // We should have opened 2 new extension tabs. Including the original blank
218 // tab, we now have 3 tabs. The two app tabs should not be in the same 214 // tab, we now have 3 tabs. The two app tabs should not be in the same
219 // process, since they do not have the background permission. (Thus, we want 215 // process, since they do not have the background permission. (Thus, we want
220 // to separate them to improve responsiveness.) 216 // to separate them to improve responsiveness.)
221 ASSERT_EQ(3, browser()->tab_count()); 217 ASSERT_EQ(3, browser()->tab_count());
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 content::Source<NavigationController>( 490 content::Source<NavigationController>(
495 &browser()->GetSelectedTabContentsWrapper()->controller())); 491 &browser()->GetSelectedTabContentsWrapper()->controller()));
496 browser()->Reload(CURRENT_TAB); 492 browser()->Reload(CURRENT_TAB);
497 observer.Wait(); 493 observer.Wait();
498 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 494 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
499 contents->render_view_host(), L"", 495 contents->render_view_host(), L"",
500 L"window.domAutomationController.send(chrome.app.isInstalled)", 496 L"window.domAutomationController.send(chrome.app.isInstalled)",
501 &is_installed)); 497 &is_installed));
502 ASSERT_TRUE(is_installed); 498 ASSERT_TRUE(is_installed);
503 } 499 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698