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

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

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update new sync tests Created 8 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 5 #include "base/bind.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/automation/automation_util.h" 10 #include "chrome/browser/automation/automation_util.h"
11 #include "chrome/browser/debugger/devtools_window.h" 11 #include "chrome/browser/debugger/devtools_window.h"
12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
13 #include "chrome/browser/extensions/app_restore_service_factory.h" 13 #include "chrome/browser/extensions/app_restore_service_factory.h"
14 #include "chrome/browser/extensions/app_restore_service.h" 14 #include "chrome/browser/extensions/app_restore_service.h"
15 #include "chrome/browser/extensions/extension_browsertest.h" 15 #include "chrome/browser/extensions/extension_browsertest.h"
16 #include "chrome/browser/extensions/extension_prefs.h" 16 #include "chrome/browser/extensions/extension_prefs.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/extension_test_message_listener.h" 19 #include "chrome/browser/extensions/extension_test_message_listener.h"
20 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 20 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
21 #include "chrome/browser/extensions/platform_app_launcher.h" 21 #include "chrome/browser/extensions/platform_app_launcher.h"
22 #include "chrome/browser/extensions/shell_window_registry.h" 22 #include "chrome/browser/extensions/shell_window_registry.h"
23 #include "chrome/browser/lifetime/application_lifetime.h"
23 #include "chrome/browser/tab_contents/render_view_context_menu.h" 24 #include "chrome/browser/tab_contents/render_view_context_menu.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_tabstrip.h" 26 #include "chrome/browser/ui/browser_tabstrip.h"
27 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/constrained_window_tab_helper.h" 28 #include "chrome/browser/ui/constrained_window_tab_helper.h"
27 #include "chrome/browser/ui/extensions/application_launch.h" 29 #include "chrome/browser/ui/extensions/application_launch.h"
28 #include "chrome/browser/ui/extensions/shell_window.h" 30 #include "chrome/browser/ui/extensions/shell_window.h"
29 #include "chrome/browser/ui/tab_contents/tab_contents.h" 31 #include "chrome/browser/ui/tab_contents/tab_contents.h"
30 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
32 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
33 #include "content/public/browser/devtools_agent_host_registry.h" 35 #include "content/public/browser/devtools_agent_host_registry.h"
34 #include "content/public/browser/render_process_host.h" 36 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/web_intents_dispatcher.h" 37 #include "content/public/browser/web_intents_dispatcher.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 size_t observations_; 140 size_t observations_;
139 std::vector<content::WebContents*> observed_tabs_; 141 std::vector<content::WebContents*> observed_tabs_;
140 142
141 DISALLOW_COPY_AND_ASSIGN(TabsAddedNotificationObserver); 143 DISALLOW_COPY_AND_ASSIGN(TabsAddedNotificationObserver);
142 }; 144 };
143 145
144 const char kTestFilePath[] = "platform_apps/launch_files/test.txt"; 146 const char kTestFilePath[] = "platform_apps/launch_files/test.txt";
145 147
146 } // namespace 148 } // namespace
147 149
150 // TODO(benwells): Break up this file into some sensible smaller files.
151
148 // Tests that CreateShellWindow doesn't crash if you close it straight away. 152 // Tests that CreateShellWindow doesn't crash if you close it straight away.
149 // LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for 153 // LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for
150 // ash, so we test that it works here. 154 // ash, so we test that it works here.
151 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) { 155 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) {
152 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); 156 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
153 ShellWindow* window = CreateShellWindow(extension); 157 ShellWindow* window = CreateShellWindow(extension);
154 CloseShellWindow(window); 158 CloseShellWindow(window);
159 CloseShellWindowsAndWaitForAppToExit();
155 } 160 }
156 161
157 // Tests that platform apps can be launched in incognito mode without crashing. 162 // Tests that platform apps can be launched in incognito mode without crashing.
158 // Times out on ChromeOS: http://crbug.com/159392 163 // Times out on ChromeOS: http://crbug.com/159392
159 #if defined(OS_CHROMEOS) 164 #if defined(OS_CHROMEOS)
160 #define MAYBE_LaunchAppIncognito DISABLED_LaunchAppIncognito 165 #define MAYBE_LaunchAppIncognito DISABLED_LaunchAppIncognito
161 #else 166 #else
162 #define MAYBE_LaunchAppIncognito LaunchAppIncognito 167 #define MAYBE_LaunchAppIncognito LaunchAppIncognito
163 #endif 168 #endif
164 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_LaunchAppIncognito) { 169 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_LaunchAppIncognito) {
165 Browser* browser_incognito = ui_test_utils::OpenURLOffTheRecord( 170 Browser* browser_incognito = ui_test_utils::OpenURLOffTheRecord(
166 browser()->profile(), GURL("about:blank")); 171 browser()->profile(), GURL("about:blank"));
167 172
168 ExtensionTestMessageListener launched_listener("Launched", false); 173 ExtensionTestMessageListener launched_listener("Launched", false);
169 174
170 const Extension* extension = LoadExtensionIncognito( 175 const Extension* extension = LoadExtensionIncognito(
171 test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal")); 176 test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal"));
172 EXPECT_TRUE(extension); 177 EXPECT_TRUE(extension);
173 178
174 application_launch::OpenApplication(application_launch::LaunchParams( 179 application_launch::OpenApplication(application_launch::LaunchParams(
175 browser_incognito->profile(), extension, extension_misc::LAUNCH_NONE, 180 browser_incognito->profile(), extension, extension_misc::LAUNCH_NONE,
176 NEW_WINDOW)); 181 NEW_WINDOW));
177 182
178 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 183 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
184 CloseShellWindowsAndWaitForAppToExit();
185 }
186
187 // Tests that the browser process is kept alive by the platform app's background
188 // page.
189 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppEventPageKeepsBrowserAlive) {
190 LoadAndLaunchPlatformApp("minimal");
191 browser()->window()->Close();
192 ASSERT_TRUE(browser::WillKeepAlive());
193 CloseShellWindowsAndWaitForAppToExit();
179 } 194 }
180 195
181 // Tests that platform apps received the "launch" event when launched. 196 // Tests that platform apps received the "launch" event when launched.
182 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) { 197 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) {
183 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_; 198 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_;
184 } 199 }
185 200
186 // Tests that platform apps can reply to "launch" events that contain a Web 201 // Tests that platform apps can reply to "launch" events that contain a Web
187 // Intent. This test does not test the mechanics of invoking a Web Intent 202 // Intent. This test does not test the mechanics of invoking a Web Intent
188 // from a source page, and short-circuits to LaunchPlatformAppWithWebIntent. 203 // from a source page, and short-circuits to LaunchPlatformAppWithWebIntent.
(...skipping 14 matching lines...) Expand all
203 WebContents* web_contents = chrome::GetActiveWebContents(browser()); 218 WebContents* web_contents = chrome::GetActiveWebContents(browser());
204 ASSERT_TRUE(web_contents); 219 ASSERT_TRUE(web_contents);
205 220
206 extensions::LaunchPlatformAppWithWebIntent( 221 extensions::LaunchPlatformAppWithWebIntent(
207 browser()->profile(), 222 browser()->profile(),
208 extension, 223 extension,
209 handler.intents_dispatcher(), 224 handler.intents_dispatcher(),
210 web_contents); 225 web_contents);
211 226
212 ASSERT_TRUE(handler.WaitUntilReply()); 227 ASSERT_TRUE(handler.WaitUntilReply());
228 CloseShellWindowsAndWaitForAppToExit();
213 } 229 }
214 230
215 // Tests that platform apps cannot use certain disabled window properties, but 231 // Tests that platform apps cannot use certain disabled window properties, but
216 // can override them and then use them. 232 // can override them and then use them.
217 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) { 233 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) {
218 ASSERT_TRUE(RunPlatformAppTest("platform_apps/disabled_window_properties")) 234 ASSERT_TRUE(RunPlatformAppTest("platform_apps/disabled_window_properties"))
219 << message_; 235 << message_;
220 } 236 }
221 237
222 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) { 238 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
223 ExtensionTestMessageListener launched_listener("Launched", false);
224 LoadAndLaunchPlatformApp("minimal"); 239 LoadAndLaunchPlatformApp("minimal");
225 240
226 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
227
228 // The empty app doesn't add any context menu items, so its menu should 241 // The empty app doesn't add any context menu items, so its menu should
229 // only include the developer tools. 242 // only include the developer tools.
230 WebContents* web_contents = GetFirstShellWindowWebContents(); 243 WebContents* web_contents = GetFirstShellWindowWebContents();
231 ASSERT_TRUE(web_contents); 244 ASSERT_TRUE(web_contents);
232 WebKit::WebContextMenuData data; 245 WebKit::WebContextMenuData data;
233 content::ContextMenuParams params(data); 246 content::ContextMenuParams params(data);
234 scoped_ptr<PlatformAppContextMenu> menu; 247 scoped_ptr<PlatformAppContextMenu> menu;
235 menu.reset(new PlatformAppContextMenu(web_contents, params)); 248 menu.reset(new PlatformAppContextMenu(web_contents, params));
236 menu->Init(); 249 menu->Init();
237 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 250 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
238 ASSERT_TRUE( 251 ASSERT_TRUE(
239 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 252 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
240 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 253 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
241 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 254 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
242 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 255 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
256 CloseShellWindowsAndWaitForAppToExit();
243 } 257 }
244 258
245 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { 259 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
246 ExtensionTestMessageListener launched_listener("Launched", false);
247 LoadAndLaunchPlatformApp("context_menu"); 260 LoadAndLaunchPlatformApp("context_menu");
248 261
249 // Wait for the extension to tell us it's initialized its context menus and
250 // launched a window.
251 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
252
253 // The context_menu app has two context menu items. These, along with a 262 // The context_menu app has two context menu items. These, along with a
254 // separator and the developer tools, is all that should be in the menu. 263 // separator and the developer tools, is all that should be in the menu.
255 WebContents* web_contents = GetFirstShellWindowWebContents(); 264 WebContents* web_contents = GetFirstShellWindowWebContents();
256 ASSERT_TRUE(web_contents); 265 ASSERT_TRUE(web_contents);
257 WebKit::WebContextMenuData data; 266 WebKit::WebContextMenuData data;
258 content::ContextMenuParams params(data); 267 content::ContextMenuParams params(data);
259 scoped_ptr<PlatformAppContextMenu> menu; 268 scoped_ptr<PlatformAppContextMenu> menu;
260 menu.reset(new PlatformAppContextMenu(web_contents, params)); 269 menu.reset(new PlatformAppContextMenu(web_contents, params));
261 menu->Init(); 270 menu->Init();
262 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 271 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
263 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); 272 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
264 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 273 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
265 ASSERT_TRUE( 274 ASSERT_TRUE(
266 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 275 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
267 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 276 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
268 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 277 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
269 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 278 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
270 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 279 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
280 CloseShellWindowsAndWaitForAppToExit();
271 } 281 }
272 282
273 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) { 283 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) {
274 ExtensionTestMessageListener launched_listener("Launched", false);
275 InstallAndLaunchPlatformApp("context_menu"); 284 InstallAndLaunchPlatformApp("context_menu");
276 285
277 // Wait for the extension to tell us it's initialized its context menus and
278 // launched a window.
279 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
280
281 // The context_menu app has two context menu items. For an installed app 286 // The context_menu app has two context menu items. For an installed app
282 // these are all that should be in the menu. 287 // these are all that should be in the menu.
283 WebContents* web_contents = GetFirstShellWindowWebContents(); 288 WebContents* web_contents = GetFirstShellWindowWebContents();
284 ASSERT_TRUE(web_contents); 289 ASSERT_TRUE(web_contents);
285 WebKit::WebContextMenuData data; 290 WebKit::WebContextMenuData data;
286 content::ContextMenuParams params(data); 291 content::ContextMenuParams params(data);
287 scoped_ptr<PlatformAppContextMenu> menu; 292 scoped_ptr<PlatformAppContextMenu> menu;
288 menu.reset(new PlatformAppContextMenu(web_contents, params)); 293 menu.reset(new PlatformAppContextMenu(web_contents, params));
289 menu->Init(); 294 menu->Init();
290 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 295 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
291 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1)); 296 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
292 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 297 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
293 ASSERT_FALSE( 298 ASSERT_FALSE(
294 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 299 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
295 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 300 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
296 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 301 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
297 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 302 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
298 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 303 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
304 CloseShellWindowsAndWaitForAppToExit();
299 } 305 }
300 306
301 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) { 307 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
302 ExtensionTestMessageListener launched_listener("Launched", false);
303 LoadAndLaunchPlatformApp("context_menu"); 308 LoadAndLaunchPlatformApp("context_menu");
304 309
305 // Wait for the extension to tell us it's initialized its context menus and
306 // launched a window.
307 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
308
309 // The context_menu app has one context menu item. This, along with a 310 // The context_menu app has one context menu item. This, along with a
310 // separator and the developer tools, is all that should be in the menu. 311 // separator and the developer tools, is all that should be in the menu.
311 WebContents* web_contents = GetFirstShellWindowWebContents(); 312 WebContents* web_contents = GetFirstShellWindowWebContents();
312 ASSERT_TRUE(web_contents); 313 ASSERT_TRUE(web_contents);
313 WebKit::WebContextMenuData data; 314 WebKit::WebContextMenuData data;
314 content::ContextMenuParams params(data); 315 content::ContextMenuParams params(data);
315 params.is_editable = true; 316 params.is_editable = true;
316 scoped_ptr<PlatformAppContextMenu> menu; 317 scoped_ptr<PlatformAppContextMenu> menu;
317 menu.reset(new PlatformAppContextMenu(web_contents, params)); 318 menu.reset(new PlatformAppContextMenu(web_contents, params));
318 menu->Init(); 319 menu->Init();
319 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 320 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
320 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 321 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
321 ASSERT_TRUE( 322 ASSERT_TRUE(
322 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 323 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
323 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 324 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
324 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 325 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
325 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); 326 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
326 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 327 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
327 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 328 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
329 CloseShellWindowsAndWaitForAppToExit();
328 } 330 }
329 331
330 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) { 332 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) {
331 ExtensionTestMessageListener launched_listener("Launched", false);
332 LoadAndLaunchPlatformApp("context_menu"); 333 LoadAndLaunchPlatformApp("context_menu");
333 334
334 // Wait for the extension to tell us it's initialized its context menus and
335 // launched a window.
336 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
337
338 // The context_menu app has one context menu item. This, along with a 335 // The context_menu app has one context menu item. This, along with a
339 // separator and the developer tools, is all that should be in the menu. 336 // separator and the developer tools, is all that should be in the menu.
340 WebContents* web_contents = GetFirstShellWindowWebContents(); 337 WebContents* web_contents = GetFirstShellWindowWebContents();
341 ASSERT_TRUE(web_contents); 338 ASSERT_TRUE(web_contents);
342 WebKit::WebContextMenuData data; 339 WebKit::WebContextMenuData data;
343 content::ContextMenuParams params(data); 340 content::ContextMenuParams params(data);
344 params.selection_text = ASCIIToUTF16("Hello World"); 341 params.selection_text = ASCIIToUTF16("Hello World");
345 scoped_ptr<PlatformAppContextMenu> menu; 342 scoped_ptr<PlatformAppContextMenu> menu;
346 menu.reset(new PlatformAppContextMenu(web_contents, params)); 343 menu.reset(new PlatformAppContextMenu(web_contents, params));
347 menu->Init(); 344 menu->Init();
348 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 345 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
349 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT)); 346 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
350 ASSERT_TRUE( 347 ASSERT_TRUE(
351 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE)); 348 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
352 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP)); 349 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
353 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO)); 350 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
354 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY)); 351 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
355 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK)); 352 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
356 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE)); 353 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
354 CloseShellWindowsAndWaitForAppToExit();
357 } 355 }
358 356
359 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) { 357 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
360 ExtensionTestMessageListener launched_listener("Launched", false);
361 LoadAndLaunchPlatformApp("context_menu_click"); 358 LoadAndLaunchPlatformApp("context_menu_click");
362 359
363 // Wait for the extension to tell us it's initialized its context menus and
364 // launched a window.
365 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
366
367 // Test that the menu item shows up 360 // Test that the menu item shows up
368 WebContents* web_contents = GetFirstShellWindowWebContents(); 361 WebContents* web_contents = GetFirstShellWindowWebContents();
369 ASSERT_TRUE(web_contents); 362 ASSERT_TRUE(web_contents);
370 WebKit::WebContextMenuData data; 363 WebKit::WebContextMenuData data;
371 content::ContextMenuParams params(data); 364 content::ContextMenuParams params(data);
372 params.page_url = GURL("http://foo.bar"); 365 params.page_url = GURL("http://foo.bar");
373 scoped_ptr<PlatformAppContextMenu> menu; 366 scoped_ptr<PlatformAppContextMenu> menu;
374 menu.reset(new PlatformAppContextMenu(web_contents, params)); 367 menu.reset(new PlatformAppContextMenu(web_contents, params));
375 menu->Init(); 368 menu->Init();
376 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST)); 369 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
377 370
378 // Execute the menu item 371 // Execute the menu item
379 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1", 372 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1",
380 false); 373 false);
381 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST); 374 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST);
382 375
383 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied()); 376 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied());
377 CloseShellWindowsAndWaitForAppToExit();
384 } 378 }
385 379
386 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) { 380 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
387 TabsAddedNotificationObserver observer(2); 381 TabsAddedNotificationObserver observer(2);
388 382
389 ASSERT_TRUE(StartTestServer()); 383 ASSERT_TRUE(StartTestServer());
390 ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_; 384 ASSERT_TRUE(RunPlatformAppTestReturnImmediately("platform_apps/navigation"))
385 << message_;
391 386
392 observer.Wait(); 387 observer.Wait();
393 ASSERT_EQ(2U, observer.tabs().size()); 388 ASSERT_EQ(2U, observer.tabs().size());
394 EXPECT_EQ(std::string(chrome::kExtensionInvalidRequestURL), 389 EXPECT_EQ(std::string(chrome::kExtensionInvalidRequestURL),
395 observer.tabs()[0]->GetURL().spec()); 390 observer.tabs()[0]->GetURL().spec());
396 EXPECT_EQ("http://chromium.org/", 391 EXPECT_EQ("http://chromium.org/",
397 observer.tabs()[1]->GetURL().spec()); 392 observer.tabs()[1]->GetURL().spec());
393 browser()->window()->Close();
394 CloseShellWindowsAndWaitForAppToExit();
398 } 395 }
399 396
400 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) { 397 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) {
401 ASSERT_TRUE(StartTestServer()); 398 ASSERT_TRUE(StartTestServer());
402 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_; 399 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_;
403 } 400 }
404 401
405 // Tests that localStorage and WebSQL are disabled for platform apps. 402 // Tests that localStorage and WebSQL are disabled for platform apps.
406 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) { 403 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) {
407 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_; 404 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Initially there should be just the one browser window visible to the 454 // Initially there should be just the one browser window visible to the
458 // extensions API. 455 // extensions API.
459 const Extension* extension = LoadExtension( 456 const Extension* extension = LoadExtension(
460 test_data_dir_.AppendASCII("common/background_page")); 457 test_data_dir_.AppendASCII("common/background_page"));
461 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension)); 458 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
462 459
463 // And no shell windows. 460 // And no shell windows.
464 ASSERT_EQ(0U, GetShellWindowCount()); 461 ASSERT_EQ(0U, GetShellWindowCount());
465 462
466 // Launch a platform app that shows a window. 463 // Launch a platform app that shows a window.
467 ExtensionTestMessageListener launched_listener("Launched", false);
468 LoadAndLaunchPlatformApp("minimal"); 464 LoadAndLaunchPlatformApp("minimal");
469 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
470 ASSERT_EQ(1U, GetShellWindowCount()); 465 ASSERT_EQ(1U, GetShellWindowCount());
471 ShellWindowRegistry::ShellWindowSet shell_windows = 466 ShellWindowRegistry::ShellWindowSet shell_windows =
472 ShellWindowRegistry::Get(browser()->profile())->shell_windows(); 467 ShellWindowRegistry::Get(browser()->profile())->shell_windows();
473 int shell_window_id = (*shell_windows.begin())->session_id().id(); 468 int shell_window_id = (*shell_windows.begin())->session_id().id();
474 469
475 // But it's not visible to the extensions API, it still thinks there's just 470 // But it's not visible to the extensions API, it still thinks there's just
476 // one browser window. 471 // one browser window.
477 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension)); 472 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
478 // It can't look it up by ID either 473 // It can't look it up by ID either
479 ASSERT_FALSE(RunGetWindowFunctionForExtension(shell_window_id, extension)); 474 ASSERT_FALSE(RunGetWindowFunctionForExtension(shell_window_id, extension));
480 475
481 // The app can also only see one window (its own). 476 // The app can also only see one window (its own).
482 // TODO(jeremya): add an extension function to get a shell window by ID, and 477 // TODO(jeremya): add an extension function to get a shell window by ID, and
483 // to get a list of all the shell windows, so we can test this. 478 // to get a list of all the shell windows, so we can test this.
484 479
485 // Launch another platform app that also shows a window. 480 // Launch another platform app that also shows a window.
486 ExtensionTestMessageListener launched_listener2("Launched", false);
487 LoadAndLaunchPlatformApp("context_menu"); 481 LoadAndLaunchPlatformApp("context_menu");
488 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
489 482
490 // There are two total shell windows, but each app can only see its own. 483 // There are two total shell windows, but each app can only see its own.
491 ASSERT_EQ(2U, GetShellWindowCount()); 484 ASSERT_EQ(2U, GetShellWindowCount());
492 // TODO(jeremya): as above, this requires more extension functions. 485 // TODO(jeremya): as above, this requires more extension functions.
486 CloseShellWindowsAndWaitForAppToExit();
493 } 487 }
494 488
495 // ChromeOS does not support passing arguments on the command line, so the tests 489 // ChromeOS does not support passing arguments on the command line, so the tests
496 // that rely on this functionality are disabled. 490 // that rely on this functionality are disabled.
497 #if !defined(OS_CHROMEOS) 491 #if !defined(OS_CHROMEOS)
498 // Tests that command line parameters get passed through to platform apps 492 // Tests that command line parameters get passed through to platform apps
499 // via launchData correctly when launching with a file. 493 // via launchData correctly when launching with a file.
500 // TODO(benwells/jeremya): tests need a way to specify a handler ID. 494 // TODO(benwells/jeremya): tests need a way to specify a handler ID.
501 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) { 495 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) {
502 SetCommandLineArg(kTestFilePath); 496 SetCommandLineArg(kTestFilePath);
(...skipping 24 matching lines...) Expand all
527 extension_misc::LAUNCH_NONE, 521 extension_misc::LAUNCH_NONE,
528 NEW_WINDOW); 522 NEW_WINDOW);
529 params.command_line = CommandLine::ForCurrentProcess(); 523 params.command_line = CommandLine::ForCurrentProcess();
530 params.current_directory = test_data_dir_; 524 params.current_directory = test_data_dir_;
531 application_launch::OpenApplication(params); 525 application_launch::OpenApplication(params);
532 526
533 if (!catcher.GetNextResult()) { 527 if (!catcher.GetNextResult()) {
534 message_ = catcher.message(); 528 message_ = catcher.message();
535 ASSERT_TRUE(0); 529 ASSERT_TRUE(0);
536 } 530 }
531 CloseShellWindowsAndWaitForAppToExit();
537 } 532 }
538 533
539 // Tests that no launch data is sent through if the file is of the wrong MIME 534 // Tests that no launch data is sent through if the file is of the wrong MIME
540 // type. 535 // type.
541 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) { 536 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) {
542 SetCommandLineArg(kTestFilePath); 537 SetCommandLineArg(kTestFilePath);
543 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type")) 538 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type"))
544 << message_; 539 << message_;
545 } 540 }
546 541
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 #endif // defined(OS_CHROMEOS) 588 #endif // defined(OS_CHROMEOS)
594 589
595 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { 590 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) {
596 ASSERT_TRUE(StartTestServer()); 591 ASSERT_TRUE(StartTestServer());
597 content::WindowedNotificationObserver observer( 592 content::WindowedNotificationObserver observer(
598 chrome::NOTIFICATION_TAB_ADDED, 593 chrome::NOTIFICATION_TAB_ADDED,
599 content::Source<content::WebContentsDelegate>(browser())); 594 content::Source<content::WebContentsDelegate>(browser()));
600 LoadAndLaunchPlatformApp("open_link"); 595 LoadAndLaunchPlatformApp("open_link");
601 observer.Wait(); 596 observer.Wait();
602 ASSERT_EQ(2, browser()->tab_count()); 597 ASSERT_EQ(2, browser()->tab_count());
598 browser()->window()->Close();
599 CloseShellWindowsAndWaitForAppToExit();
603 } 600 }
604 601
605 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { 602 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
606 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; 603 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
607 } 604 }
608 605
609 // Test that windows created with an id will remember and restore their 606 // Test that windows created with an id will remember and restore their
610 // geometry when opening new windows. 607 // geometry when opening new windows.
611 // Originally disabled due to flakiness (see http://crbug.com/155459) 608 // Originally disabled due to flakiness (see http://crbug.com/155459)
612 // but now because a regression breaks the test (http://crbug.com/160343). 609 // but now because a regression breaks the test (http://crbug.com/160343).
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // Wait for javascript to verify that the second window got the updated 666 // Wait for javascript to verify that the second window got the updated
670 // coordinates, ignoring the default coordinates passed to the create method. 667 // coordinates, ignoring the default coordinates passed to the create method.
671 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); 668 ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
672 669
673 // Tell javascript to open a third window. 670 // Tell javascript to open a third window.
674 page3_listener.Reply("continue"); 671 page3_listener.Reply("continue");
675 672
676 // Wait for javascript to verify that the third window got the restored size 673 // Wait for javascript to verify that the third window got the restored size
677 // and explicitly specified coordinates. 674 // and explicitly specified coordinates.
678 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); 675 ASSERT_TRUE(done3_listener.WaitUntilSatisfied());
676 CloseShellWindowsAndWaitForAppToExit();
679 } 677 }
680 678
681 // Tests that a running app is recorded in the preferences as such. 679 // Tests that a running app is recorded in the preferences as such.
682 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { 680 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
683 content::WindowedNotificationObserver extension_suspended( 681 content::WindowedNotificationObserver extension_suspended(
684 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 682 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
685 content::NotificationService::AllSources()); 683 content::NotificationService::AllSources());
686 684
687 const Extension* extension = LoadExtension( 685 const Extension* extension = LoadExtension(
688 test_data_dir_.AppendASCII("platform_apps/restart_test")); 686 test_data_dir_.AppendASCII("platform_apps/restart_test"));
(...skipping 11 matching lines...) Expand all
700 // App isn't running because it got suspended. 698 // App isn't running because it got suspended.
701 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); 699 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id()));
702 700
703 // Pretend that the app is supposed to be running. 701 // Pretend that the app is supposed to be running.
704 extension_prefs->SetExtensionRunning(extension->id(), true); 702 extension_prefs->SetExtensionRunning(extension->id(), true);
705 703
706 ExtensionTestMessageListener restart_listener("onRestarted", false); 704 ExtensionTestMessageListener restart_listener("onRestarted", false);
707 AppRestoreServiceFactory::GetForProfile(browser()->profile())-> 705 AppRestoreServiceFactory::GetForProfile(browser()->profile())->
708 HandleStartup(true); 706 HandleStartup(true);
709 restart_listener.WaitUntilSatisfied(); 707 restart_listener.WaitUntilSatisfied();
708 CloseShellWindowsAndWaitForAppToExit();
710 } 709 }
711 710
712 namespace { 711 namespace {
713 712
714 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { 713 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest {
715 protected: 714 protected:
716 enum TestFlags { 715 enum TestFlags {
717 RELAUNCH = 0x1, 716 RELAUNCH = 0x1,
718 HAS_ID = 0x2, 717 HAS_ID = 0x2,
719 }; 718 };
720 // Runs a test inside a harness that opens DevTools on a shell window. 719 // Runs a test inside a harness that opens DevTools on a shell window.
721 void RunTestWithDevTools(const char* name, int test_flags); 720 void RunTestWithDevTools(const char* name, int test_flags);
722 }; 721 };
723 722
724 void PlatformAppDevToolsBrowserTest::RunTestWithDevTools( 723 void PlatformAppDevToolsBrowserTest::RunTestWithDevTools(
725 const char* name, int test_flags) { 724 const char* name, int test_flags) {
726 using content::DevToolsAgentHostRegistry; 725 using content::DevToolsAgentHostRegistry;
727 ExtensionTestMessageListener launched_listener("Launched", false);
728 const Extension* extension = LoadAndLaunchPlatformApp(name); 726 const Extension* extension = LoadAndLaunchPlatformApp(name);
729 ASSERT_TRUE(extension); 727 ASSERT_TRUE(extension);
730 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
731 ShellWindow* window = GetFirstShellWindow(); 728 ShellWindow* window = GetFirstShellWindow();
732 ASSERT_TRUE(window); 729 ASSERT_TRUE(window);
733 ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0); 730 ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0);
734 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost(); 731 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost();
735 ASSERT_TRUE(rvh); 732 ASSERT_TRUE(rvh);
736 733
737 // Ensure no DevTools open for the ShellWindow, then open one. 734 // Ensure no DevTools open for the ShellWindow, then open one.
738 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); 735 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
739 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh); 736 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh);
740 content::WindowedNotificationObserver loaded_observer( 737 content::WindowedNotificationObserver loaded_observer(
(...skipping 17 matching lines...) Expand all
758 NEW_WINDOW)); 755 NEW_WINDOW));
759 app_loaded_observer.Wait(); 756 app_loaded_observer.Wait();
760 window = GetFirstShellWindow(); 757 window = GetFirstShellWindow();
761 ASSERT_TRUE(window); 758 ASSERT_TRUE(window);
762 759
763 // DevTools should have reopened with the relaunch. 760 // DevTools should have reopened with the relaunch.
764 rvh = window->web_contents()->GetRenderViewHost(); 761 rvh = window->web_contents()->GetRenderViewHost();
765 ASSERT_TRUE(rvh); 762 ASSERT_TRUE(rvh);
766 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); 763 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
767 } 764 }
765 CloseShellWindowsAndWaitForAppToExit();
768 } 766 }
769 767
770 } // namespace 768 } // namespace
771 769
772 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithID) { 770 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithID) {
773 RunTestWithDevTools("minimal_id", RELAUNCH | HAS_ID); 771 RunTestWithDevTools("minimal_id", RELAUNCH | HAS_ID);
774 } 772 }
775 773
776 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithURL) { 774 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithURL) {
777 RunTestWithDevTools("minimal", RELAUNCH); 775 RunTestWithDevTools("minimal", RELAUNCH);
(...skipping 21 matching lines...) Expand all
799 // Verify that the shell window has a constrained window attached. 797 // Verify that the shell window has a constrained window attached.
800 ConstrainedWindowTabHelper* constrained_window_tab_helper = 798 ConstrainedWindowTabHelper* constrained_window_tab_helper =
801 ConstrainedWindowTabHelper::FromWebContents(web_contents); 799 ConstrainedWindowTabHelper::FromWebContents(web_contents);
802 EXPECT_EQ(1u, constrained_window_tab_helper->constrained_window_count()); 800 EXPECT_EQ(1u, constrained_window_tab_helper->constrained_window_count());
803 801
804 // Close the constrained window and wait for the reply to the permission 802 // Close the constrained window and wait for the reply to the permission
805 // request. 803 // request.
806 ExtensionTestMessageListener listener("PermissionRequestDone", false); 804 ExtensionTestMessageListener listener("PermissionRequestDone", false);
807 constrained_window_tab_helper->CloseConstrainedWindows(); 805 constrained_window_tab_helper->CloseConstrainedWindows();
808 ASSERT_TRUE(listener.WaitUntilSatisfied()); 806 ASSERT_TRUE(listener.WaitUntilSatisfied());
807
808 CloseShellWindowsAndWaitForAppToExit();
809 } 809 }
810 810
811 // Tests that an app calling chrome.runtime.reload will reload the app and 811 // Tests that an app calling chrome.runtime.reload will reload the app and
812 // relaunch it if it was running. 812 // relaunch it if it was running.
813 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { 813 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
814 ExtensionTestMessageListener launched_listener("Launched", true); 814 ExtensionTestMessageListener launched_listener("Launched", true);
815 const Extension* extension = LoadAndLaunchPlatformApp("reload"); 815 const Extension* extension = LoadPlatformApp("reload");
816 ASSERT_TRUE(extension); 816 ASSERT_TRUE(extension);
817 application_launch::OpenApplication(application_launch::LaunchParams(
818 browser()->profile(), extension, extension_misc::LAUNCH_NONE,
819 NEW_WINDOW));
817 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 820 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
818 ASSERT_TRUE(GetFirstShellWindow()); 821 ASSERT_TRUE(GetFirstShellWindow());
819 822
820 // Now tell the app to reload itself 823 // Now tell the app to reload itself
821 ExtensionTestMessageListener launched_listener2("Launched", false); 824 ExtensionTestMessageListener launched_listener2("Launched", false);
822 launched_listener.Reply("reload"); 825 launched_listener.Reply("reload");
823 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); 826 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
824 ASSERT_TRUE(GetFirstShellWindow()); 827 ASSERT_TRUE(GetFirstShellWindow());
828 CloseShellWindowsAndWaitForAppToExit();
825 } 829 }
826 830
827 } // namespace extensions 831 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698