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

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: Updates for 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 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) { 494 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) {
501 SetCommandLineArg(kTestFilePath); 495 SetCommandLineArg(kTestFilePath);
502 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file")) 496 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file"))
(...skipping 23 matching lines...) Expand all
526 extension_misc::LAUNCH_NONE, 520 extension_misc::LAUNCH_NONE,
527 NEW_WINDOW); 521 NEW_WINDOW);
528 params.command_line = CommandLine::ForCurrentProcess(); 522 params.command_line = CommandLine::ForCurrentProcess();
529 params.current_directory = test_data_dir_; 523 params.current_directory = test_data_dir_;
530 application_launch::OpenApplication(params); 524 application_launch::OpenApplication(params);
531 525
532 if (!catcher.GetNextResult()) { 526 if (!catcher.GetNextResult()) {
533 message_ = catcher.message(); 527 message_ = catcher.message();
534 ASSERT_TRUE(0); 528 ASSERT_TRUE(0);
535 } 529 }
530 CloseShellWindowsAndWaitForAppToExit();
536 } 531 }
537 532
538 // Tests that no launch data is sent through if the file is of the wrong MIME 533 // Tests that no launch data is sent through if the file is of the wrong MIME
539 // type. 534 // type.
540 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) { 535 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) {
541 SetCommandLineArg(kTestFilePath); 536 SetCommandLineArg(kTestFilePath);
542 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type")) 537 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type"))
543 << message_; 538 << message_;
544 } 539 }
545 540
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 #endif // defined(OS_CHROMEOS) 587 #endif // defined(OS_CHROMEOS)
593 588
594 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { 589 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) {
595 ASSERT_TRUE(StartTestServer()); 590 ASSERT_TRUE(StartTestServer());
596 content::WindowedNotificationObserver observer( 591 content::WindowedNotificationObserver observer(
597 chrome::NOTIFICATION_TAB_ADDED, 592 chrome::NOTIFICATION_TAB_ADDED,
598 content::Source<content::WebContentsDelegate>(browser())); 593 content::Source<content::WebContentsDelegate>(browser()));
599 LoadAndLaunchPlatformApp("open_link"); 594 LoadAndLaunchPlatformApp("open_link");
600 observer.Wait(); 595 observer.Wait();
601 ASSERT_EQ(2, browser()->tab_count()); 596 ASSERT_EQ(2, browser()->tab_count());
597 browser()->window()->Close();
598 CloseShellWindowsAndWaitForAppToExit();
602 } 599 }
603 600
604 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) { 601 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
605 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_; 602 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
606 } 603 }
607 604
608 // Test that windows created with an id will remember and restore their 605 // Test that windows created with an id will remember and restore their
609 // geometry when opening new windows. 606 // geometry when opening new windows.
610 // Originally disabled due to flakiness (see http://crbug.com/155459) 607 // Originally disabled due to flakiness (see http://crbug.com/155459)
611 // but now because a regression breaks the test (http://crbug.com/160343). 608 // but now because a regression breaks the test (http://crbug.com/160343).
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 // Wait for javascript to verify that the second window got the updated 665 // Wait for javascript to verify that the second window got the updated
669 // coordinates, ignoring the default coordinates passed to the create method. 666 // coordinates, ignoring the default coordinates passed to the create method.
670 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); 667 ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
671 668
672 // Tell javascript to open a third window. 669 // Tell javascript to open a third window.
673 page3_listener.Reply("continue"); 670 page3_listener.Reply("continue");
674 671
675 // Wait for javascript to verify that the third window got the restored size 672 // Wait for javascript to verify that the third window got the restored size
676 // and explicitly specified coordinates. 673 // and explicitly specified coordinates.
677 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); 674 ASSERT_TRUE(done3_listener.WaitUntilSatisfied());
675 CloseShellWindowsAndWaitForAppToExit();
678 } 676 }
679 677
680 // Tests that a running app is recorded in the preferences as such. 678 // Tests that a running app is recorded in the preferences as such.
681 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { 679 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
682 content::WindowedNotificationObserver extension_suspended( 680 content::WindowedNotificationObserver extension_suspended(
683 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 681 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
684 content::NotificationService::AllSources()); 682 content::NotificationService::AllSources());
685 683
686 const Extension* extension = LoadExtension( 684 const Extension* extension = LoadExtension(
687 test_data_dir_.AppendASCII("platform_apps/restart_test")); 685 test_data_dir_.AppendASCII("platform_apps/restart_test"));
(...skipping 11 matching lines...) Expand all
699 // App isn't running because it got suspended. 697 // App isn't running because it got suspended.
700 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); 698 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id()));
701 699
702 // Pretend that the app is supposed to be running. 700 // Pretend that the app is supposed to be running.
703 extension_prefs->SetExtensionRunning(extension->id(), true); 701 extension_prefs->SetExtensionRunning(extension->id(), true);
704 702
705 ExtensionTestMessageListener restart_listener("onRestarted", false); 703 ExtensionTestMessageListener restart_listener("onRestarted", false);
706 AppRestoreServiceFactory::GetForProfile(browser()->profile())-> 704 AppRestoreServiceFactory::GetForProfile(browser()->profile())->
707 HandleStartup(true); 705 HandleStartup(true);
708 restart_listener.WaitUntilSatisfied(); 706 restart_listener.WaitUntilSatisfied();
707 CloseShellWindowsAndWaitForAppToExit();
709 } 708 }
710 709
711 namespace { 710 namespace {
712 711
713 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { 712 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest {
714 protected: 713 protected:
715 enum TestFlags { 714 enum TestFlags {
716 RELAUNCH = 0x1, 715 RELAUNCH = 0x1,
717 HAS_ID = 0x2, 716 HAS_ID = 0x2,
718 }; 717 };
719 // Runs a test inside a harness that opens DevTools on a shell window. 718 // Runs a test inside a harness that opens DevTools on a shell window.
720 void RunTestWithDevTools(const char* name, int test_flags); 719 void RunTestWithDevTools(const char* name, int test_flags);
721 }; 720 };
722 721
723 void PlatformAppDevToolsBrowserTest::RunTestWithDevTools( 722 void PlatformAppDevToolsBrowserTest::RunTestWithDevTools(
724 const char* name, int test_flags) { 723 const char* name, int test_flags) {
725 using content::DevToolsAgentHostRegistry; 724 using content::DevToolsAgentHostRegistry;
726 ExtensionTestMessageListener launched_listener("Launched", false);
727 const Extension* extension = LoadAndLaunchPlatformApp(name); 725 const Extension* extension = LoadAndLaunchPlatformApp(name);
728 ASSERT_TRUE(extension); 726 ASSERT_TRUE(extension);
729 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
730 ShellWindow* window = GetFirstShellWindow(); 727 ShellWindow* window = GetFirstShellWindow();
731 ASSERT_TRUE(window); 728 ASSERT_TRUE(window);
732 ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0); 729 ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0);
733 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost(); 730 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost();
734 ASSERT_TRUE(rvh); 731 ASSERT_TRUE(rvh);
735 732
736 // Ensure no DevTools open for the ShellWindow, then open one. 733 // Ensure no DevTools open for the ShellWindow, then open one.
737 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); 734 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
738 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh); 735 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh);
739 content::WindowedNotificationObserver loaded_observer( 736 content::WindowedNotificationObserver loaded_observer(
(...skipping 17 matching lines...) Expand all
757 NEW_WINDOW)); 754 NEW_WINDOW));
758 app_loaded_observer.Wait(); 755 app_loaded_observer.Wait();
759 window = GetFirstShellWindow(); 756 window = GetFirstShellWindow();
760 ASSERT_TRUE(window); 757 ASSERT_TRUE(window);
761 758
762 // DevTools should have reopened with the relaunch. 759 // DevTools should have reopened with the relaunch.
763 rvh = window->web_contents()->GetRenderViewHost(); 760 rvh = window->web_contents()->GetRenderViewHost();
764 ASSERT_TRUE(rvh); 761 ASSERT_TRUE(rvh);
765 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); 762 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
766 } 763 }
764 CloseShellWindowsAndWaitForAppToExit();
767 } 765 }
768 766
769 } // namespace 767 } // namespace
770 768
771 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithID) { 769 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithID) {
772 RunTestWithDevTools("minimal_id", RELAUNCH | HAS_ID); 770 RunTestWithDevTools("minimal_id", RELAUNCH | HAS_ID);
773 } 771 }
774 772
775 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithURL) { 773 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, ReOpenedWithURL) {
776 RunTestWithDevTools("minimal", RELAUNCH); 774 RunTestWithDevTools("minimal", RELAUNCH);
(...skipping 21 matching lines...) Expand all
798 // Verify that the shell window has a constrained window attached. 796 // Verify that the shell window has a constrained window attached.
799 ConstrainedWindowTabHelper* constrained_window_tab_helper = 797 ConstrainedWindowTabHelper* constrained_window_tab_helper =
800 ConstrainedWindowTabHelper::FromWebContents(web_contents); 798 ConstrainedWindowTabHelper::FromWebContents(web_contents);
801 EXPECT_EQ(1u, constrained_window_tab_helper->constrained_window_count()); 799 EXPECT_EQ(1u, constrained_window_tab_helper->constrained_window_count());
802 800
803 // Close the constrained window and wait for the reply to the permission 801 // Close the constrained window and wait for the reply to the permission
804 // request. 802 // request.
805 ExtensionTestMessageListener listener("PermissionRequestDone", false); 803 ExtensionTestMessageListener listener("PermissionRequestDone", false);
806 constrained_window_tab_helper->CloseConstrainedWindows(); 804 constrained_window_tab_helper->CloseConstrainedWindows();
807 ASSERT_TRUE(listener.WaitUntilSatisfied()); 805 ASSERT_TRUE(listener.WaitUntilSatisfied());
806
807 CloseShellWindowsAndWaitForAppToExit();
808 } 808 }
809 809
810 // Tests that an app calling chrome.runtime.reload will reload the app and 810 // Tests that an app calling chrome.runtime.reload will reload the app and
811 // relaunch it if it was running. 811 // relaunch it if it was running.
812 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { 812 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
813 ExtensionTestMessageListener launched_listener("Launched", true); 813 ExtensionTestMessageListener launched_listener("Launched", true);
814 const Extension* extension = LoadAndLaunchPlatformApp("reload"); 814 const Extension* extension = LoadPlatformApp("reload");
815 ASSERT_TRUE(extension); 815 ASSERT_TRUE(extension);
816 application_launch::OpenApplication(application_launch::LaunchParams(
817 browser()->profile(), extension, extension_misc::LAUNCH_NONE,
818 NEW_WINDOW));
816 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 819 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
817 ASSERT_TRUE(GetFirstShellWindow()); 820 ASSERT_TRUE(GetFirstShellWindow());
818 821
819 // Now tell the app to reload itself 822 // Now tell the app to reload itself
820 ExtensionTestMessageListener launched_listener2("Launched", false); 823 ExtensionTestMessageListener launched_listener2("Launched", false);
821 launched_listener.Reply("reload"); 824 launched_listener.Reply("reload");
822 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); 825 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
823 ASSERT_TRUE(GetFirstShellWindow()); 826 ASSERT_TRUE(GetFirstShellWindow());
827 CloseShellWindowsAndWaitForAppToExit();
824 } 828 }
825 829
826 } // namespace extensions 830 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698