blob: 57c0ee608f5763427e53150a9d385657687be409 [file] [log] [blame]
[email protected]a44657202012-01-09 05:48:311// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]cfc6cca2011-12-01 02:30:062// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]a6db6122012-09-03 06:00:235#include "base/bind.h"
[email protected]939532d02012-08-31 23:37:336#include "base/test/test_timeouts.h"
7#include "base/threading/platform_thread.h"
[email protected]b3c019b2012-08-28 02:43:488#include "base/utf_string_conversions.h"
[email protected]ad687a72012-06-08 06:03:119#include "chrome/app/chrome_command_ids.h"
[email protected]605fb8102012-05-04 01:36:5510#include "chrome/browser/automation/automation_util.h"
[email protected]e85cc642012-10-24 06:14:2311#include "chrome/browser/debugger/devtools_window.h"
[email protected]ddf42162012-11-06 21:14:5512#include "chrome/browser/extensions/api/permissions/permissions_api.h"
[email protected]b64ca6842012-11-02 22:21:0013#include "chrome/browser/lifetime/application_lifetime.h"
[email protected]28c3eeb2012-10-15 05:47:5314#include "chrome/browser/extensions/app_restore_service_factory.h"
15#include "chrome/browser/extensions/app_restore_service.h"
[email protected]a6db6122012-09-03 06:00:2316#include "chrome/browser/extensions/extension_browsertest.h"
[email protected]28c3eeb2012-10-15 05:47:5317#include "chrome/browser/extensions/extension_prefs.h"
18#include "chrome/browser/extensions/extension_service.h"
19#include "chrome/browser/extensions/extension_system.h"
[email protected]259771102012-05-31 16:52:2020#include "chrome/browser/extensions/extension_test_message_listener.h"
21#include "chrome/browser/extensions/platform_app_browsertest_util.h"
[email protected]a6db6122012-09-03 06:00:2322#include "chrome/browser/extensions/platform_app_launcher.h"
[email protected]259771102012-05-31 16:52:2023#include "chrome/browser/extensions/shell_window_registry.h"
[email protected]e85cc642012-10-24 06:14:2324#include "chrome/browser/tab_contents/render_view_context_menu.h"
[email protected]cfc6cca2011-12-01 02:30:0625#include "chrome/browser/ui/browser.h"
[email protected]b64ca6842012-11-02 22:21:0026#include "chrome/browser/ui/browser_window.h"
[email protected]52877dbc62012-06-29 22:22:0327#include "chrome/browser/ui/browser_tabstrip.h"
[email protected]ddf42162012-11-06 21:14:5528#include "chrome/browser/ui/constrained_window_tab_helper.h"
[email protected]a5a0be02012-07-18 05:51:5429#include "chrome/browser/ui/extensions/application_launch.h"
[email protected]d72d3a62012-05-10 03:45:0830#include "chrome/browser/ui/extensions/shell_window.h"
[email protected]e85cc642012-10-24 06:14:2331#include "chrome/browser/ui/tab_contents/tab_contents.h"
[email protected]5b1a04b42012-06-15 00:41:4432#include "chrome/common/chrome_notification_types.h"
[email protected]4d007b312012-10-17 03:00:4833#include "chrome/common/url_constants.h"
[email protected]cfc6cca2011-12-01 02:30:0634#include "chrome/test/base/ui_test_utils.h"
[email protected]e85cc642012-10-24 06:14:2335#include "content/public/browser/devtools_agent_host_registry.h"
[email protected]fb29e6cf2012-07-12 21:27:2036#include "content/public/browser/render_process_host.h"
[email protected]a6db6122012-09-03 06:00:2337#include "content/public/browser/web_intents_dispatcher.h"
[email protected]28c3eeb2012-10-15 05:47:5338#include "content/public/test/test_utils.h"
[email protected]a6db6122012-09-03 06:00:2339#include "googleurl/src/gurl.h"
40#include "webkit/glue/web_intent_data.h"
[email protected]cfc6cca2011-12-01 02:30:0641
[email protected]bb81f382012-01-03 22:45:4442using content::WebContents;
[email protected]d9ede582012-08-14 19:21:3843
44namespace extensions {
[email protected]31bdbfef2012-05-22 19:59:1545
[email protected]375003a2011-12-13 02:53:2146namespace {
[email protected]85d3d5e2012-08-31 21:19:1747
[email protected]375003a2011-12-13 02:53:2148// Non-abstract RenderViewContextMenu class.
49class PlatformAppContextMenu : public RenderViewContextMenu {
50 public:
[email protected]bb81f382012-01-03 22:45:4451 PlatformAppContextMenu(WebContents* web_contents,
[email protected]35be7ec2012-02-12 20:42:5152 const content::ContextMenuParams& params)
[email protected]bb81f382012-01-03 22:45:4453 : RenderViewContextMenu(web_contents, params) {}
[email protected]375003a2011-12-13 02:53:2154
[email protected]ad687a72012-06-08 06:03:1155 bool HasCommandWithId(int command_id) {
56 return menu_model_.GetIndexOfCommandId(command_id) != -1;
57 }
58
[email protected]375003a2011-12-13 02:53:2159 protected:
[email protected]85d3d5e2012-08-31 21:19:1760 // RenderViewContextMenu implementation.
61 virtual bool GetAcceleratorForCommandId(
62 int command_id,
63 ui::Accelerator* accelerator) OVERRIDE {
[email protected]375003a2011-12-13 02:53:2164 return false;
65 }
[email protected]85d3d5e2012-08-31 21:19:1766 virtual void PlatformInit() OVERRIDE {}
67 virtual void PlatformCancel() OVERRIDE {}
[email protected]375003a2011-12-13 02:53:2168};
69
[email protected]a6db6122012-09-03 06:00:2370// State holder for the LaunchReply test. This provides an WebIntentsDispatcher
71// that will, when used to launch a Web Intent, will return its reply via this
72// class. The result may then be waited on via WaitUntilReply().
73class LaunchReplyHandler {
74 public:
75 explicit LaunchReplyHandler(webkit_glue::WebIntentData& data)
76 : data_(data),
77 replied_(false),
78 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
79 intents_dispatcher_ = content::WebIntentsDispatcher::Create(data);
80 intents_dispatcher_->RegisterReplyNotification(base::Bind(
81 &LaunchReplyHandler::OnReply, weak_ptr_factory_.GetWeakPtr()));
82 }
83
84 content::WebIntentsDispatcher* intents_dispatcher() {
85 return intents_dispatcher_;
86 }
87
88 // Waits until a reply to this Web Intent is provided via the
89 // WebIntentsDispatcher.
90 bool WaitUntilReply() {
91 if (replied_)
92 return true;
93 waiting_ = true;
94 content::RunMessageLoop();
95 waiting_ = false;
96 return replied_;
97 }
98
99 private:
100 void OnReply(webkit_glue::WebIntentReplyType reply) {
101 // Note that the ReplyNotification registered on WebIntentsDispatcher does
102 // not include the result data: this is reserved for the source page (which
103 // we don't care about).
104 replied_ = true;
105 if (waiting_)
106 MessageLoopForUI::current()->Quit();
107 }
108
109 webkit_glue::WebIntentData data_;
110 bool replied_;
111 bool waiting_;
112 content::WebIntentsDispatcher* intents_dispatcher_;
113 base::WeakPtrFactory<LaunchReplyHandler> weak_ptr_factory_;
114};
115
[email protected]4d007b312012-10-17 03:00:48116// This class keeps track of tabs as they are added to the browser. It will be
117// "done" (i.e. won't block on Wait()) once |observations| tabs have been added.
118class TabsAddedNotificationObserver
119 : public content::WindowedNotificationObserver {
120 public:
121 explicit TabsAddedNotificationObserver(size_t observations)
122 : content::WindowedNotificationObserver(
123 chrome::NOTIFICATION_TAB_ADDED,
124 content::NotificationService::AllSources()),
125 observations_(observations) {
126 }
127
128 virtual void Observe(int type,
129 const content::NotificationSource& source,
130 const content::NotificationDetails& details) OVERRIDE {
131 observed_tabs_.push_back(
132 content::Details<WebContents>(details).ptr());
133 if (observed_tabs_.size() == observations_)
134 content::WindowedNotificationObserver::Observe(type, source, details);
135 }
136
137 const std::vector<content::WebContents*>& tabs() { return observed_tabs_; }
138
139 private:
140 size_t observations_;
141 std::vector<content::WebContents*> observed_tabs_;
142
143 DISALLOW_COPY_AND_ASSIGN(TabsAddedNotificationObserver);
144};
145
[email protected]85d3d5e2012-08-31 21:19:17146const char kTestFilePath[] = "platform_apps/launch_files/test.txt";
147
[email protected]375003a2011-12-13 02:53:21148} // namespace
149
[email protected]b64ca6842012-11-02 22:21:00150// TODO(benwells): Break up this file into some sensible smaller files.
151
[email protected]eb4bcac2012-06-27 01:32:08152// Tests that CreateShellWindow doesn't crash if you close it straight away.
153// LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for
154// ash, so we test that it works here.
155IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) {
156 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
157 ShellWindow* window = CreateShellWindow(extension);
158 CloseShellWindow(window);
[email protected]b64ca6842012-11-02 22:21:00159 CloseShellWindowsAndWaitForAppToExit();
[email protected]eb4bcac2012-06-27 01:32:08160}
161
[email protected]688a1732012-10-18 20:19:31162// Tests that platform apps can be launched in incognito mode without crashing.
[email protected]50a04d32012-11-05 11:44:22163// Times out on ChromeOS: http://crbug.com/159392
164#if defined(OS_CHROMEOS)
165#define MAYBE_LaunchAppIncognito DISABLED_LaunchAppIncognito
166#else
167#define MAYBE_LaunchAppIncognito LaunchAppIncognito
168#endif
169IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_LaunchAppIncognito) {
[email protected]688a1732012-10-18 20:19:31170 Browser* browser_incognito = ui_test_utils::OpenURLOffTheRecord(
171 browser()->profile(), GURL("about:blank"));
172
173 ExtensionTestMessageListener launched_listener("Launched", false);
174
175 const Extension* extension = LoadExtensionIncognito(
176 test_data_dir_.AppendASCII("platform_apps").AppendASCII("minimal"));
177 EXPECT_TRUE(extension);
178
179 application_launch::OpenApplication(application_launch::LaunchParams(
180 browser_incognito->profile(), extension, extension_misc::LAUNCH_NONE,
181 NEW_WINDOW));
182
183 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
[email protected]b64ca6842012-11-02 22:21:00184 CloseShellWindowsAndWaitForAppToExit();
185}
186
187// Tests that the browser process is kept alive by the platform app's background
188// page.
189IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppEventPageKeepsBrowserAlive) {
190 LoadAndLaunchPlatformApp("minimal");
191 browser()->window()->Close();
192 ASSERT_TRUE(browser::WillKeepAlive());
193 CloseShellWindowsAndWaitForAppToExit();
[email protected]688a1732012-10-18 20:19:31194}
195
[email protected]dc37b002012-04-23 23:02:26196// Tests that platform apps received the "launch" event when launched.
197IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) {
198 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_;
[email protected]cfc6cca2011-12-01 02:30:06199}
[email protected]375003a2011-12-13 02:53:21200
[email protected]a6db6122012-09-03 06:00:23201// Tests that platform apps can reply to "launch" events that contain a Web
202// Intent. This test does not test the mechanics of invoking a Web Intent
203// from a source page, and short-circuits to LaunchPlatformAppWithWebIntent.
204IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchReply) {
205 FilePath path = test_data_dir_.AppendASCII("platform_apps/launch_reply");
206 const extensions::Extension* extension = LoadExtension(path);
207 ASSERT_TRUE(extension) << "Failed to load extension.";
208
209 webkit_glue::WebIntentData data(
210 UTF8ToUTF16("http://webintents.org/view"),
211 UTF8ToUTF16("text/plain"),
212 UTF8ToUTF16("irrelevant unserialized string data"));
213 LaunchReplyHandler handler(data);
214
215 // Navigate to a boring page: we don't care what it is, but we require some
216 // source WebContents to launch the Web Intent "from".
217 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
218 WebContents* web_contents = chrome::GetActiveWebContents(browser());
219 ASSERT_TRUE(web_contents);
220
221 extensions::LaunchPlatformAppWithWebIntent(
222 browser()->profile(),
223 extension,
224 handler.intents_dispatcher(),
225 web_contents);
226
227 ASSERT_TRUE(handler.WaitUntilReply());
[email protected]b64ca6842012-11-02 22:21:00228 CloseShellWindowsAndWaitForAppToExit();
[email protected]a6db6122012-09-03 06:00:23229}
230
[email protected]567230b2012-08-21 21:11:44231// Tests that platform apps cannot use certain disabled window properties, but
232// can override them and then use them.
233IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) {
234 ASSERT_TRUE(RunPlatformAppTest("platform_apps/disabled_window_properties"))
235 << message_;
236}
237
[email protected]edd7ed692012-02-08 02:50:03238IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
[email protected]31bdbfef2012-05-22 19:59:15239 LoadAndLaunchPlatformApp("minimal");
[email protected]dc37b002012-04-23 23:02:26240
[email protected]375003a2011-12-13 02:53:21241 // The empty app doesn't add any context menu items, so its menu should
[email protected]0cfacd82012-02-09 01:55:33242 // only include the developer tools.
[email protected]d72d3a62012-05-10 03:45:08243 WebContents* web_contents = GetFirstShellWindowWebContents();
[email protected]a44657202012-01-09 05:48:31244 ASSERT_TRUE(web_contents);
[email protected]375003a2011-12-13 02:53:21245 WebKit::WebContextMenuData data;
[email protected]35be7ec2012-02-12 20:42:51246 content::ContextMenuParams params(data);
[email protected]85d3d5e2012-08-31 21:19:17247 scoped_ptr<PlatformAppContextMenu> menu;
248 menu.reset(new PlatformAppContextMenu(web_contents, params));
[email protected]375003a2011-12-13 02:53:21249 menu->Init();
[email protected]ad687a72012-06-08 06:03:11250 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
[email protected]65992d52012-09-19 23:05:31251 ASSERT_TRUE(
252 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
[email protected]671c9702012-09-27 07:51:19253 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
[email protected]ad687a72012-06-08 06:03:11254 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
255 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
[email protected]b64ca6842012-11-02 22:21:00256 CloseShellWindowsAndWaitForAppToExit();
[email protected]375003a2011-12-13 02:53:21257}
258
[email protected]edd7ed692012-02-08 02:50:03259IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
[email protected]375003a2011-12-13 02:53:21260 LoadAndLaunchPlatformApp("context_menu");
261
[email protected]271d01c2012-08-27 23:48:05262 // The context_menu app has two context menu items. These, along with a
[email protected]0cfacd82012-02-09 01:55:33263 // separator and the developer tools, is all that should be in the menu.
[email protected]d72d3a62012-05-10 03:45:08264 WebContents* web_contents = GetFirstShellWindowWebContents();
[email protected]a44657202012-01-09 05:48:31265 ASSERT_TRUE(web_contents);
[email protected]375003a2011-12-13 02:53:21266 WebKit::WebContextMenuData data;
[email protected]35be7ec2012-02-12 20:42:51267 content::ContextMenuParams params(data);
[email protected]85d3d5e2012-08-31 21:19:17268 scoped_ptr<PlatformAppContextMenu> menu;
269 menu.reset(new PlatformAppContextMenu(web_contents, params));
[email protected]375003a2011-12-13 02:53:21270 menu->Init();
[email protected]ad687a72012-06-08 06:03:11271 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
[email protected]271d01c2012-08-27 23:48:05272 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
[email protected]ad687a72012-06-08 06:03:11273 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
[email protected]65992d52012-09-19 23:05:31274 ASSERT_TRUE(
275 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
[email protected]671c9702012-09-27 07:51:19276 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
[email protected]ad687a72012-06-08 06:03:11277 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
278 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
[email protected]b3c019b2012-08-28 02:43:48279 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
[email protected]b64ca6842012-11-02 22:21:00280 CloseShellWindowsAndWaitForAppToExit();
[email protected]b3c019b2012-08-28 02:43:48281}
282
[email protected]65992d52012-09-19 23:05:31283IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) {
[email protected]65992d52012-09-19 23:05:31284 InstallAndLaunchPlatformApp("context_menu");
285
[email protected]65992d52012-09-19 23:05:31286 // The context_menu app has two context menu items. For an installed app
287 // these are all that should be in the menu.
288 WebContents* web_contents = GetFirstShellWindowWebContents();
289 ASSERT_TRUE(web_contents);
290 WebKit::WebContextMenuData data;
291 content::ContextMenuParams params(data);
292 scoped_ptr<PlatformAppContextMenu> menu;
293 menu.reset(new PlatformAppContextMenu(web_contents, params));
294 menu->Init();
295 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
296 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + 1));
297 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
298 ASSERT_FALSE(
299 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
[email protected]671c9702012-09-27 07:51:19300 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
[email protected]65992d52012-09-19 23:05:31301 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
302 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
303 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
[email protected]b64ca6842012-11-02 22:21:00304 CloseShellWindowsAndWaitForAppToExit();
[email protected]65992d52012-09-19 23:05:31305}
306
[email protected]b3c019b2012-08-28 02:43:48307IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
[email protected]b3c019b2012-08-28 02:43:48308 LoadAndLaunchPlatformApp("context_menu");
309
[email protected]b3c019b2012-08-28 02:43:48310 // The context_menu app has one context menu item. This, along with a
311 // separator and the developer tools, is all that should be in the menu.
312 WebContents* web_contents = GetFirstShellWindowWebContents();
313 ASSERT_TRUE(web_contents);
314 WebKit::WebContextMenuData data;
315 content::ContextMenuParams params(data);
316 params.is_editable = true;
[email protected]85d3d5e2012-08-31 21:19:17317 scoped_ptr<PlatformAppContextMenu> menu;
318 menu.reset(new PlatformAppContextMenu(web_contents, params));
[email protected]b3c019b2012-08-28 02:43:48319 menu->Init();
320 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
321 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
[email protected]65992d52012-09-19 23:05:31322 ASSERT_TRUE(
323 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
[email protected]671c9702012-09-27 07:51:19324 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
[email protected]b3c019b2012-08-28 02:43:48325 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
326 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
327 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
328 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
[email protected]b64ca6842012-11-02 22:21:00329 CloseShellWindowsAndWaitForAppToExit();
[email protected]b3c019b2012-08-28 02:43:48330}
331
332IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) {
[email protected]b3c019b2012-08-28 02:43:48333 LoadAndLaunchPlatformApp("context_menu");
334
[email protected]b3c019b2012-08-28 02:43:48335 // The context_menu app has one context menu item. This, along with a
336 // separator and the developer tools, is all that should be in the menu.
337 WebContents* web_contents = GetFirstShellWindowWebContents();
338 ASSERT_TRUE(web_contents);
339 WebKit::WebContextMenuData data;
340 content::ContextMenuParams params(data);
341 params.selection_text = ASCIIToUTF16("Hello World");
[email protected]85d3d5e2012-08-31 21:19:17342 scoped_ptr<PlatformAppContextMenu> menu;
343 menu.reset(new PlatformAppContextMenu(web_contents, params));
[email protected]b3c019b2012-08-28 02:43:48344 menu->Init();
345 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
346 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
[email protected]65992d52012-09-19 23:05:31347 ASSERT_TRUE(
348 menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE));
[email protected]671c9702012-09-27 07:51:19349 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
[email protected]b3c019b2012-08-28 02:43:48350 ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
351 ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
352 ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
353 ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
[email protected]b64ca6842012-11-02 22:21:00354 CloseShellWindowsAndWaitForAppToExit();
[email protected]375003a2011-12-13 02:53:21355}
[email protected]5f000f272012-01-19 05:25:08356
[email protected]dc83c582012-08-17 02:18:14357IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
[email protected]dc83c582012-08-17 02:18:14358 LoadAndLaunchPlatformApp("context_menu_click");
359
[email protected]dc83c582012-08-17 02:18:14360 // Test that the menu item shows up
361 WebContents* web_contents = GetFirstShellWindowWebContents();
362 ASSERT_TRUE(web_contents);
363 WebKit::WebContextMenuData data;
364 content::ContextMenuParams params(data);
365 params.page_url = GURL("http://foo.bar");
[email protected]85d3d5e2012-08-31 21:19:17366 scoped_ptr<PlatformAppContextMenu> menu;
367 menu.reset(new PlatformAppContextMenu(web_contents, params));
[email protected]dc83c582012-08-17 02:18:14368 menu->Init();
369 ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
370
371 // Execute the menu item
372 ExtensionTestMessageListener onclicked_listener("onClicked fired for id1",
373 false);
374 menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST);
375
376 ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied());
[email protected]b64ca6842012-11-02 22:21:00377 CloseShellWindowsAndWaitForAppToExit();
[email protected]dc83c582012-08-17 02:18:14378}
379
[email protected]edd7ed692012-02-08 02:50:03380IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
[email protected]4d007b312012-10-17 03:00:48381 TabsAddedNotificationObserver observer(2);
382
[email protected]dc37b002012-04-23 23:02:26383 ASSERT_TRUE(StartTestServer());
[email protected]b64ca6842012-11-02 22:21:00384 ASSERT_TRUE(RunPlatformAppTestReturnImmediately("platform_apps/navigation"))
385 << message_;
[email protected]4d007b312012-10-17 03:00:48386
387 observer.Wait();
388 ASSERT_EQ(2U, observer.tabs().size());
389 EXPECT_EQ(std::string(chrome::kExtensionInvalidRequestURL),
390 observer.tabs()[0]->GetURL().spec());
391 EXPECT_EQ("http://chromium.org/",
392 observer.tabs()[1]->GetURL().spec());
[email protected]b64ca6842012-11-02 22:21:00393 browser()->window()->Close();
394 CloseShellWindowsAndWaitForAppToExit();
[email protected]5f000f272012-01-19 05:25:08395}
[email protected]863e6472012-01-24 19:33:58396
[email protected]40eefd52012-10-04 22:54:22397IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) {
[email protected]fd3238af2012-05-22 18:55:30398 ASSERT_TRUE(StartTestServer());
399 ASSERT_TRUE(RunPlatformAppTest("platform_apps/iframes")) << message_;
400}
401
[email protected]2aac7ff2012-01-25 18:05:11402// Tests that localStorage and WebSQL are disabled for platform apps.
[email protected]edd7ed692012-02-08 02:50:03403IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowStorage) {
[email protected]2aac7ff2012-01-25 18:05:11404 ASSERT_TRUE(RunPlatformAppTest("platform_apps/storage")) << message_;
405}
[email protected]6a5a2e52012-03-22 03:21:12406
[email protected]c0cecd1f2012-04-05 16:50:12407IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) {
408 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_;
409}
410
[email protected]f0233ff2012-07-20 20:14:50411// Tests that platform apps can use the chrome.app.window.* API.
[email protected]dc37b002012-04-23 23:02:26412IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApi) {
[email protected]6a5a2e52012-03-22 03:21:12413 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_;
414}
[email protected]605fb8102012-05-04 01:36:55415
[email protected]1df22042012-08-30 19:48:55416// Tests that extensions can't use platform-app-only APIs.
417IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, PlatformAppsOnly) {
418 ASSERT_TRUE(RunExtensionTestIgnoreManifestWarnings(
419 "platform_apps/apps_only")) << message_;
420}
421
[email protected]605fb8102012-05-04 01:36:55422// Tests that platform apps have isolated storage by default.
423IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Isolation) {
424 ASSERT_TRUE(StartTestServer());
425
426 // Load a (non-app) page under the "localhost" origin that sets a cookie.
427 GURL set_cookie_url = test_server()->GetURL(
428 "files/extensions/platform_apps/isolation/set_cookie.html");
429 GURL::Replacements replace_host;
430 std::string host_str("localhost"); // Must stay in scope with replace_host.
431 replace_host.SetHostStr(host_str);
432 set_cookie_url = set_cookie_url.ReplaceComponents(replace_host);
433
434 ui_test_utils::NavigateToURLWithDisposition(
435 browser(), set_cookie_url,
436 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
437
438 // Make sure the cookie is set.
439 int cookie_size;
440 std::string cookie_value;
441 automation_util::GetCookies(
442 set_cookie_url,
[email protected]52877dbc62012-06-29 22:22:03443 chrome::GetWebContentsAt(browser(), 0),
[email protected]605fb8102012-05-04 01:36:55444 &cookie_size,
445 &cookie_value);
446 ASSERT_EQ("testCookie=1", cookie_value);
447
448 // Let the platform app request the same URL, and make sure that it doesn't
449 // see the cookie.
450 ASSERT_TRUE(RunPlatformAppTest("platform_apps/isolation")) << message_;
451}
[email protected]31bdbfef2012-05-22 19:59:15452
453IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExtensionWindowingApis) {
454 // Initially there should be just the one browser window visible to the
455 // extensions API.
456 const Extension* extension = LoadExtension(
457 test_data_dir_.AppendASCII("common/background_page"));
458 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
459
460 // And no shell windows.
461 ASSERT_EQ(0U, GetShellWindowCount());
462
463 // Launch a platform app that shows a window.
[email protected]ad5bb8a92012-06-07 03:55:58464 LoadAndLaunchPlatformApp("minimal");
[email protected]31bdbfef2012-05-22 19:59:15465 ASSERT_EQ(1U, GetShellWindowCount());
466 ShellWindowRegistry::ShellWindowSet shell_windows =
467 ShellWindowRegistry::Get(browser()->profile())->shell_windows();
468 int shell_window_id = (*shell_windows.begin())->session_id().id();
469
470 // But it's not visible to the extensions API, it still thinks there's just
471 // one browser window.
472 ASSERT_EQ(1U, RunGetWindowsFunctionForExtension(extension));
473 // It can't look it up by ID either
474 ASSERT_FALSE(RunGetWindowFunctionForExtension(shell_window_id, extension));
475
476 // The app can also only see one window (its own).
[email protected]ad5bb8a92012-06-07 03:55:58477 // TODO(jeremya): add an extension function to get a shell window by ID, and
478 // to get a list of all the shell windows, so we can test this.
[email protected]31bdbfef2012-05-22 19:59:15479
480 // Launch another platform app that also shows a window.
[email protected]ad5bb8a92012-06-07 03:55:58481 LoadAndLaunchPlatformApp("context_menu");
[email protected]31bdbfef2012-05-22 19:59:15482
483 // There are two total shell windows, but each app can only see its own.
484 ASSERT_EQ(2U, GetShellWindowCount());
[email protected]ad5bb8a92012-06-07 03:55:58485 // TODO(jeremya): as above, this requires more extension functions.
[email protected]b64ca6842012-11-02 22:21:00486 CloseShellWindowsAndWaitForAppToExit();
[email protected]31bdbfef2012-05-22 19:59:15487}
[email protected]12e540452012-05-26 07:09:36488
[email protected]a2ece522012-10-16 03:41:10489// ChromeOS does not support passing arguments on the command line, so the tests
490// that rely on this functionality are disabled.
[email protected]12e540452012-05-26 07:09:36491#if !defined(OS_CHROMEOS)
492// Tests that command line parameters get passed through to platform apps
493// via launchData correctly when launching with a file.
494IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) {
[email protected]85d3d5e2012-08-31 21:19:17495 SetCommandLineArg(kTestFilePath);
[email protected]12e540452012-05-26 07:09:36496 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file"))
497 << message_;
498}
499
[email protected]a5a0be02012-07-18 05:51:54500// Tests that relative paths can be passed through to the platform app.
501// This test doesn't use the normal test infrastructure as it needs to open
502// the application differently to all other platform app tests, by setting
503// the application_launch::LaunchParams.current_directory field.
504IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithRelativeFile) {
505 // Setup the command line
506 ClearCommandLineArgs();
507 CommandLine* command_line = CommandLine::ForCurrentProcess();
[email protected]85d3d5e2012-08-31 21:19:17508 FilePath relative_test_doc = FilePath::FromUTF8Unsafe(kTestFilePath);
[email protected]a5a0be02012-07-18 05:51:54509 relative_test_doc = relative_test_doc.NormalizePathSeparators();
510 command_line->AppendArgPath(relative_test_doc);
511
512 // Load the extension
513 ResultCatcher catcher;
[email protected]d9ede582012-08-14 19:21:38514 const Extension* extension = LoadExtension(
[email protected]a5a0be02012-07-18 05:51:54515 test_data_dir_.AppendASCII("platform_apps/launch_file"));
516 ASSERT_TRUE(extension);
517
518 // Run the test
519 application_launch::LaunchParams params(browser()->profile(), extension,
520 extension_misc::LAUNCH_NONE,
521 NEW_WINDOW);
522 params.command_line = CommandLine::ForCurrentProcess();
523 params.current_directory = test_data_dir_;
524 application_launch::OpenApplication(params);
525
526 if (!catcher.GetNextResult()) {
527 message_ = catcher.message();
528 ASSERT_TRUE(0);
529 }
[email protected]b64ca6842012-11-02 22:21:00530 CloseShellWindowsAndWaitForAppToExit();
[email protected]a5a0be02012-07-18 05:51:54531}
532
[email protected]12e540452012-05-26 07:09:36533// Tests that no launch data is sent through if the file is of the wrong MIME
534// type.
535IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) {
[email protected]85d3d5e2012-08-31 21:19:17536 SetCommandLineArg(kTestFilePath);
[email protected]12e540452012-05-26 07:09:36537 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type"))
538 << message_;
539}
540
541// Tests that no launch data is sent through if the platform app does not
542// provide an intent.
543IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNoIntent) {
[email protected]85d3d5e2012-08-31 21:19:17544 SetCommandLineArg(kTestFilePath);
[email protected]12e540452012-05-26 07:09:36545 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_intent"))
546 << message_;
547}
548
549// Tests that no launch data is sent through if the file MIME type cannot
550// be read.
551IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoType) {
552 SetCommandLineArg("platform_apps/launch_files/test.unknownextension");
553 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid"))
554 << message_;
555}
556
557// Tests that no launch data is sent through if the file does not exist.
558IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoFile) {
559 SetCommandLineArg("platform_apps/launch_files/doesnotexist.txt");
560 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid"))
561 << message_;
562}
563
564// Tests that no launch data is sent through if the argument is a directory.
565IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithDirectory) {
566 SetCommandLineArg("platform_apps/launch_files");
567 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid"))
568 << message_;
569}
570
571// Tests that no launch data is sent through if there are no arguments passed
572// on the command line
573IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNothing) {
574 ClearCommandLineArgs();
575 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_nothing"))
576 << message_;
577}
[email protected]ffc7b4d2012-06-08 00:05:32578
579// Test that platform apps can use the chrome.fileSystem.getDisplayPath
580// function to get the native file system path of a file they are launched with.
581IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, GetDisplayPath) {
[email protected]85d3d5e2012-08-31 21:19:17582 SetCommandLineArg(kTestFilePath);
[email protected]ffc7b4d2012-06-08 00:05:32583 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path"))
584 << message_;
585}
586
[email protected]12e540452012-05-26 07:09:36587#endif // defined(OS_CHROMEOS)
[email protected]5b1a04b42012-06-15 00:41:44588
589IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) {
590 ASSERT_TRUE(StartTestServer());
[email protected]a7fe9112012-07-20 02:34:45591 content::WindowedNotificationObserver observer(
[email protected]5b1a04b42012-06-15 00:41:44592 chrome::NOTIFICATION_TAB_ADDED,
593 content::Source<content::WebContentsDelegate>(browser()));
594 LoadAndLaunchPlatformApp("open_link");
595 observer.Wait();
596 ASSERT_EQ(2, browser()->tab_count());
[email protected]b64ca6842012-11-02 22:21:00597 browser()->window()->Close();
598 CloseShellWindowsAndWaitForAppToExit();
[email protected]5b1a04b42012-06-15 00:41:44599}
[email protected]d9ede582012-08-14 19:21:38600
[email protected]3a8e61942012-08-23 01:46:45601IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
602 ASSERT_TRUE(RunPlatformAppTest("platform_apps/mutation_events")) << message_;
603}
604
[email protected]939532d02012-08-31 23:37:33605// Test that windows created with an id will remember and restore their
606// geometry when opening new windows.
[email protected]ee429b52012-10-18 20:53:18607// Flaky, see http://crbug.com/155459.
[email protected]9d53c1c2012-10-18 00:49:54608IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
609 FLAKY_ShellWindowRestorePosition) {
[email protected]939532d02012-08-31 23:37:33610 ExtensionTestMessageListener page2_listener("WaitForPage2", true);
611 ExtensionTestMessageListener page3_listener("WaitForPage3", true);
612 ExtensionTestMessageListener done_listener("Done1", false);
613 ExtensionTestMessageListener done2_listener("Done2", false);
614 ExtensionTestMessageListener done3_listener("Done3", false);
615
616 ASSERT_TRUE(LoadAndLaunchPlatformApp("geometry"));
617
618 // Wait for the app to be launched (although this is mostly to have a
619 // message to reply to to let the script know it should create its second
620 // window.
621 ASSERT_TRUE(page2_listener.WaitUntilSatisfied());
622
623 // Wait for the first window to verify its geometry was correctly set
624 // from the default* attributes passed to the create function.
625 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
626
627 // Programatically move and resize the window.
628 ShellWindow* window = GetFirstShellWindow();
629 ASSERT_TRUE(window);
630 gfx::Rect bounds(137, 143, 203, 187);
631 window->GetBaseWindow()->SetBounds(bounds);
632
633#if defined(TOOLKIT_GTK)
634 // TODO(mek): On GTK we have to wait for a roundtrip to the X server before
635 // a resize actually happens:
636 // "if you call gtk_window_resize() then immediately call
637 // gtk_window_get_size(), the size won't have taken effect yet. After the
638 // window manager processes the resize request, GTK+ receives notification
639 // that the size has changed via a configure event, and the size of the
640 // window gets updated."
641 // Because of this we have to wait for an unknown time for the resize to
642 // actually take effect. So wait some time or until the resize got
643 // handled.
644 base::TimeTicks end_time = base::TimeTicks::Now() +
645 TestTimeouts::action_timeout();
646 while (base::TimeTicks::Now() < end_time &&
647 bounds != window->GetBaseWindow()->GetBounds()) {
648 content::RunAllPendingInMessageLoop();
649 }
650
651 // In the GTK ShellWindow implementation there also is a delay between
652 // getting the correct bounds and it calling SaveWindowPosition, so call that
653 // method explicitly to make sure the value was stored.
654 window->SaveWindowPosition();
655#endif // defined(TOOLKIT_GTK)
656
657 // Make sure the window was properly moved&resized.
658 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds());
659
660 // Tell javascript to open a second window.
661 page2_listener.Reply("continue");
662
663 // Wait for javascript to verify that the second window got the updated
664 // coordinates, ignoring the default coordinates passed to the create method.
665 ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
666
667 // Tell javascript to open a third window.
668 page3_listener.Reply("continue");
669
670 // Wait for javascript to verify that the third window got the restored size
671 // and explicitly specified coordinates.
672 ASSERT_TRUE(done3_listener.WaitUntilSatisfied());
[email protected]b64ca6842012-11-02 22:21:00673 CloseShellWindowsAndWaitForAppToExit();
[email protected]939532d02012-08-31 23:37:33674}
[email protected]939532d02012-08-31 23:37:33675
[email protected]28c3eeb2012-10-15 05:47:53676// Tests that a running app is recorded in the preferences as such.
677IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
678 content::WindowedNotificationObserver extension_suspended(
679 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
680 content::NotificationService::AllSources());
681
682 const Extension* extension = LoadExtension(
683 test_data_dir_.AppendASCII("platform_apps/restart_test"));
684 ASSERT_TRUE(extension);
685 ExtensionService* extension_service =
686 ExtensionSystem::Get(browser()->profile())->extension_service();
687 ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
688
689 // App is running.
690 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id()));
691
692 // Wait for the extension to get suspended.
693 extension_suspended.Wait();
694
695 // App isn't running because it got suspended.
696 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id()));
697
698 // Pretend that the app is supposed to be running.
699 extension_prefs->SetExtensionRunning(extension->id(), true);
700
701 ExtensionTestMessageListener restart_listener("onRestarted", false);
[email protected]119454622012-10-18 09:48:32702 AppRestoreServiceFactory::GetForProfile(browser()->profile())->
703 HandleStartup(true);
[email protected]28c3eeb2012-10-15 05:47:53704 restart_listener.WaitUntilSatisfied();
[email protected]b64ca6842012-11-02 22:21:00705 CloseShellWindowsAndWaitForAppToExit();
[email protected]28c3eeb2012-10-15 05:47:53706}
707
[email protected]22e219a2012-11-05 23:48:08708IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DevToolsOpenedWithReload) {
[email protected]e85cc642012-10-24 06:14:23709 using content::DevToolsAgentHostRegistry;
[email protected]e85cc642012-10-24 06:14:23710 const Extension* extension = LoadAndLaunchPlatformApp("minimal_id");
711 ASSERT_TRUE(extension);
[email protected]e85cc642012-10-24 06:14:23712 ShellWindow* window = GetFirstShellWindow();
713 ASSERT_TRUE(window);
714 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost();
715 ASSERT_TRUE(rvh);
716
717 // Ensure no DevTools open for the ShellWindow, then open one.
718 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
719 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh);
720 content::WindowedNotificationObserver loaded_observer(
721 content::NOTIFICATION_LOAD_STOP,
722 content::Source<content::NavigationController>(
723 &devtools_window->tab_contents()->web_contents()->GetController()));
724 loaded_observer.Wait();
725 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
726
727 // Close the ShellWindow, and ensure it is gone.
728 CloseShellWindow(window);
729 ASSERT_FALSE(GetFirstShellWindow());
730
731 // Relaunch the app and get a new ShellWindow.
732 content::WindowedNotificationObserver app_loaded_observer(
733 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
734 content::NotificationService::AllSources());
735 application_launch::OpenApplication(application_launch::LaunchParams(
736 browser()->profile(), extension, extension_misc::LAUNCH_NONE,
737 NEW_WINDOW));
738 app_loaded_observer.Wait();
739 window = GetFirstShellWindow();
740 ASSERT_TRUE(window);
741
742 // DevTools should have reopened with the relaunch.
743 rvh = window->web_contents()->GetRenderViewHost();
744 ASSERT_TRUE(rvh);
745 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
[email protected]b64ca6842012-11-02 22:21:00746 CloseShellWindowsAndWaitForAppToExit();
[email protected]e85cc642012-10-24 06:14:23747}
748
[email protected]ddf42162012-11-06 21:14:55749// Test that showing a permission request as a constrained window works and is
750// correctly parented.
751#if defined(OS_MACOSX)
752#define MAYBE_ConstrainedWindowRequest ConstrainedWindowRequest
753#else
754// TODO(sail): Enable this on other platforms once http://crbug.com/95455 is
755// fixed.
756#define MAYBE_ConstrainedWindowRequest DISABLED_ConstrainedWindowRequest
757#endif
758
759IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) {
760 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
761 const Extension* extension =
762 LoadAndLaunchPlatformApp("optional_permission_request");
763 ASSERT_TRUE(extension) << "Failed to load extension.";
764
765 WebContents* web_contents = GetFirstShellWindowWebContents();
766 ASSERT_TRUE(web_contents);
767
768 // Verify that the shell window has a constrained window attached.
769 ConstrainedWindowTabHelper* constrained_window_tab_helper =
770 ConstrainedWindowTabHelper::FromWebContents(web_contents);
771 EXPECT_EQ(1u, constrained_window_tab_helper->constrained_window_count());
772
773 // Close the constrained window and wait for the reply to the permission
774 // request.
775 ExtensionTestMessageListener listener("PermissionRequestDone", false);
776 constrained_window_tab_helper->CloseConstrainedWindows();
777 ASSERT_TRUE(listener.WaitUntilSatisfied());
778
779 CloseShellWindowsAndWaitForAppToExit();
780}
781
[email protected]d9ede582012-08-14 19:21:38782} // namespace extensions