blob: ceb75f6f0da3dd0f6f76942a2f0a41f7486d450d [file] [log] [blame]
[email protected]c333e792012-01-06 16:57:391// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]3a8eecb2010-04-22 23:56:302// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]3a8eecb2010-04-22 23:56:305#include "chrome/browser/extensions/extension_apitest.h"
6#include "chrome/browser/extensions/extension_host.h"
[email protected]6f371442011-11-09 06:45:467#include "chrome/browser/extensions/extension_service.h"
[email protected]06bdd2b2012-11-30 18:47:138#include "chrome/browser/extensions/extension_system.h"
[email protected]6f371442011-11-09 06:45:469#include "chrome/browser/extensions/process_map.h"
[email protected]8ecad5e2010-12-02 21:18:3310#include "chrome/browser/profiles/profile.h"
[email protected]079b3cc2012-09-26 19:59:1311#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
[email protected]7b5dc002010-11-16 23:08:1012#include "chrome/browser/ui/browser.h"
[email protected]a37d4b02012-06-25 21:56:1013#include "chrome/browser/ui/browser_commands.h"
[email protected]d8748142012-05-16 21:13:4314#include "chrome/browser/ui/browser_finder.h"
[email protected]71b73f02011-04-06 15:57:2915#include "chrome/browser/ui/browser_list.h"
[email protected]d55c2382011-08-18 23:10:3616#include "chrome/browser/ui/browser_window.h"
[email protected]e0448872013-01-11 19:35:0217#include "chrome/browser/ui/tabs/tab_strip_model.h"
[email protected]884033e2012-04-16 19:38:4218#include "chrome/common/chrome_notification_types.h"
[email protected]3a8eecb2010-04-22 23:56:3019#include "chrome/common/chrome_switches.h"
[email protected]814a7bf0f2011-08-13 05:30:5920#include "chrome/common/extensions/extension.h"
[email protected]c2f36e3a2011-12-14 01:27:1921#include "chrome/common/extensions/extension_file_util.h"
[email protected]af44e7fb2011-07-29 18:32:3222#include "chrome/test/base/ui_test_utils.h"
[email protected]ad23a092011-12-28 07:02:0423#include "content/public/browser/navigation_entry.h"
[email protected]ad50def52011-10-19 23:17:0724#include "content/public/browser/notification_service.h"
[email protected]c333e792012-01-06 16:57:3925#include "content/public/browser/render_process_host.h"
[email protected]9c1662b2012-03-06 15:44:3326#include "content/public/browser/render_view_host.h"
[email protected]6acde6352012-01-04 16:52:2027#include "content/public/browser/web_contents.h"
[email protected]7d478cb2012-07-24 17:19:4228#include "content/public/test/browser_test_utils.h"
[email protected]5b8ff1c2012-06-02 20:42:2029#include "content/public/test/test_navigation_observer.h"
[email protected]3a8eecb2010-04-22 23:56:3030#include "net/base/mock_host_resolver.h"
[email protected]36b643212012-09-07 12:53:0031#include "sync/api/string_ordinal.h"
[email protected]3a8eecb2010-04-22 23:56:3032
[email protected]c5eed492012-01-04 17:07:5033using content::NavigationController;
[email protected]eaabba22012-03-07 15:02:1134using content::RenderViewHost;
[email protected]4ca15302012-01-03 05:53:2035using content::WebContents;
[email protected]1c321ee52012-05-21 03:02:3436using extensions::Extension;
[email protected]4ca15302012-01-03 05:53:2037
[email protected]7b54ca02012-03-02 18:06:5338class AppApiTest : public ExtensionApiTest {
39 protected:
40 // Gets the base URL for files for a specific test, making sure that it uses
41 // "localhost" as the hostname, since that is what the extent is declared
42 // as in the test apps manifests.
43 GURL GetTestBaseURL(std::string test_directory) {
44 GURL::Replacements replace_host;
45 std::string host_str("localhost"); // must stay in scope with replace_host
46 replace_host.SetHostStr(host_str);
47 GURL base_url = test_server()->GetURL(
48 "files/extensions/api_test/" + test_directory + "/");
49 return base_url.ReplaceComponents(replace_host);
50 }
51
52 // Pass flags to make testing apps easier.
[email protected]49aeab62013-02-07 02:53:1153 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
[email protected]7b54ca02012-03-02 18:06:5354 ExtensionApiTest::SetUpCommandLine(command_line);
55 CommandLine::ForCurrentProcess()->AppendSwitch(
56 switches::kDisablePopupBlocking);
57 CommandLine::ForCurrentProcess()->AppendSwitch(
58 switches::kAllowHTTPBackgroundPage);
59 }
60
61 // Helper function to test that independent tabs of the named app are loaded
62 // into separate processes.
63 void TestAppInstancesHelper(std::string app_name) {
64 LOG(INFO) << "Start of test.";
65
[email protected]06bdd2b2012-11-30 18:47:1366 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get(
67 browser()->profile())->extension_service()->process_map();
[email protected]7b54ca02012-03-02 18:06:5368
69 host_resolver()->AddRule("*", "127.0.0.1");
70 ASSERT_TRUE(test_server()->Start());
71
72 ASSERT_TRUE(LoadExtension(
73 test_data_dir_.AppendASCII(app_name)));
74
75 // Open two tabs in the app, one outside it.
76 GURL base_url = GetTestBaseURL(app_name);
77
78 // Test both opening a URL in a new tab, and opening a tab and then
79 // navigating it. Either way, app tabs should be considered extension
80 // processes, but they have no elevated privileges and thus should not
81 // have WebUI bindings.
82 ui_test_utils::NavigateToURLWithDisposition(
83 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
84 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
85 LOG(INFO) << "Nav 1.";
86 EXPECT_TRUE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:0287 browser()->tab_strip_model()->GetWebContentsAt(1)->
88 GetRenderProcessHost()->GetID()));
89 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI());
[email protected]7b54ca02012-03-02 18:06:5390
[email protected]a7fe9112012-07-20 02:34:4591 content::WindowedNotificationObserver tab_added_observer(
[email protected]884033e2012-04-16 19:38:4292 chrome::NOTIFICATION_TAB_ADDED,
[email protected]7b54ca02012-03-02 18:06:5393 content::NotificationService::AllSources());
[email protected]a37d4b02012-06-25 21:56:1094 chrome::NewTab(browser());
[email protected]7b54ca02012-03-02 18:06:5395 tab_added_observer.Wait();
96 LOG(INFO) << "New tab.";
97 ui_test_utils::NavigateToURL(browser(),
98 base_url.Resolve("path2/empty.html"));
99 LOG(INFO) << "Nav 2.";
100 EXPECT_TRUE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02101 browser()->tab_strip_model()->GetWebContentsAt(2)->
102 GetRenderProcessHost()->GetID()));
103 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI());
[email protected]7b54ca02012-03-02 18:06:53104
105 // We should have opened 2 new extension tabs. Including the original blank
106 // tab, we now have 3 tabs. The two app tabs should not be in the same
107 // process, since they do not have the background permission. (Thus, we
108 // want to separate them to improve responsiveness.)
[email protected]e0448872013-01-11 19:35:02109 ASSERT_EQ(3, browser()->tab_strip_model()->count());
110 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1);
111 WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2);
[email protected]19da16a92012-05-23 17:11:29112 EXPECT_NE(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost());
[email protected]7b54ca02012-03-02 18:06:53113
114 // Opening tabs with window.open should keep the page in the opener's
115 // process.
[email protected]52ff7d932012-10-28 19:46:46116 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
[email protected]19da16a92012-05-23 17:11:29117 OpenWindow(tab1, base_url.Resolve("path1/empty.html"), true, NULL);
[email protected]7b54ca02012-03-02 18:06:53118 LOG(INFO) << "WindowOpenHelper 1.";
[email protected]19da16a92012-05-23 17:11:29119 OpenWindow(tab2, base_url.Resolve("path2/empty.html"), true, NULL);
[email protected]7b54ca02012-03-02 18:06:53120 LOG(INFO) << "End of test.";
121 }
122};
123
[email protected]079b3cc2012-09-26 19:59:13124// Omits the disable-popup-blocking flag so we can cover that case.
125class BlockedAppApiTest : public AppApiTest {
126 protected:
[email protected]49aeab62013-02-07 02:53:11127 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
[email protected]079b3cc2012-09-26 19:59:13128 ExtensionApiTest::SetUpCommandLine(command_line);
129 CommandLine::ForCurrentProcess()->AppendSwitch(
130 switches::kAllowHTTPBackgroundPage);
131 }
132};
133
[email protected]7b54ca02012-03-02 18:06:53134// Tests that hosted apps with the background permission get a process-per-app
135// model, since all pages need to be able to script the background page.
[email protected]c9c206082013-01-29 00:42:56136// http://crbug.com/172750
137#if defined(OS_WIN)
138#define MAYBE_AppProcess DISABLED_AppProcess
139#else
140#define MAYBE_AppProcess AppProcess
141#endif
142IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcess) {
[email protected]87c7c292011-10-27 16:16:41143 LOG(INFO) << "Start of test.";
[email protected]9b600832011-10-26 20:31:59144
[email protected]06bdd2b2012-11-30 18:47:13145 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get(
146 browser()->profile())->extension_service()->process_map();
[email protected]718eab62011-10-05 21:16:52147
[email protected]3a8eecb2010-04-22 23:56:30148 host_resolver()->AddRule("*", "127.0.0.1");
[email protected]95409e12010-08-17 20:07:11149 ASSERT_TRUE(test_server()->Start());
[email protected]3a8eecb2010-04-22 23:56:30150
[email protected]cbf4d1912010-08-12 18:24:57151 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process")));
[email protected]3a8eecb2010-04-22 23:56:30152
[email protected]87c7c292011-10-27 16:16:41153 LOG(INFO) << "Loaded extension.";
154
[email protected]cbf4d1912010-08-12 18:24:57155 // Open two tabs in the app, one outside it.
[email protected]118d3122011-08-10 17:09:53156 GURL base_url = GetTestBaseURL("app_process");
[email protected]fe3048872010-10-18 14:58:59157
[email protected]f0e13332011-05-20 22:41:14158 // Test both opening a URL in a new tab, and opening a tab and then navigating
159 // it. Either way, app tabs should be considered extension processes, but
160 // they have no elevated privileges and thus should not have WebUI bindings.
161 ui_test_utils::NavigateToURLWithDisposition(
162 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
163 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
[email protected]6f371442011-11-09 06:45:46164 EXPECT_TRUE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02165 browser()->tab_strip_model()->GetWebContentsAt(1)->
166 GetRenderProcessHost()->GetID()));
167 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI());
[email protected]87c7c292011-10-27 16:16:41168 LOG(INFO) << "Nav 1.";
169
170 ui_test_utils::NavigateToURLWithDisposition(
171 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB,
172 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
[email protected]6f371442011-11-09 06:45:46173 EXPECT_TRUE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02174 browser()->tab_strip_model()->GetWebContentsAt(2)->
175 GetRenderProcessHost()->GetID()));
176 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI());
[email protected]87c7c292011-10-27 16:16:41177 LOG(INFO) << "Nav 2.";
178
[email protected]a7fe9112012-07-20 02:34:45179 content::WindowedNotificationObserver tab_added_observer(
[email protected]884033e2012-04-16 19:38:42180 chrome::NOTIFICATION_TAB_ADDED,
[email protected]87c7c292011-10-27 16:16:41181 content::NotificationService::AllSources());
[email protected]a37d4b02012-06-25 21:56:10182 chrome::NewTab(browser());
[email protected]87c7c292011-10-27 16:16:41183 tab_added_observer.Wait();
184 LOG(INFO) << "New tab.";
[email protected]cbf4d1912010-08-12 18:24:57185 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html"));
[email protected]87c7c292011-10-27 16:16:41186 LOG(INFO) << "Nav 3.";
[email protected]6f371442011-11-09 06:45:46187 EXPECT_FALSE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02188 browser()->tab_strip_model()->GetWebContentsAt(3)->
189 GetRenderProcessHost()->GetID()));
190 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(3)->GetWebUI());
[email protected]3a8eecb2010-04-22 23:56:30191
[email protected]056ad2a2011-07-12 02:13:55192 // We should have opened 3 new extension tabs. Including the original blank
193 // tab, we now have 4 tabs. Because the app_process app has the background
194 // permission, all of its instances are in the same process. Thus two tabs
195 // should be part of the extension app and grouped in the same process.
[email protected]e0448872013-01-11 19:35:02196 ASSERT_EQ(4, browser()->tab_strip_model()->count());
197 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1);
[email protected]cbf4d1912010-08-12 18:24:57198
[email protected]19da16a92012-05-23 17:11:29199 EXPECT_EQ(tab->GetRenderProcessHost(),
[email protected]e0448872013-01-11 19:35:02200 browser()->tab_strip_model()->GetWebContentsAt(2)->
201 GetRenderProcessHost());
[email protected]19da16a92012-05-23 17:11:29202 EXPECT_NE(tab->GetRenderProcessHost(),
[email protected]e0448872013-01-11 19:35:02203 browser()->tab_strip_model()->GetWebContentsAt(3)->
204 GetRenderProcessHost());
[email protected]3a8eecb2010-04-22 23:56:30205
206 // Now let's do the same using window.open. The same should happen.
[email protected]52ff7d932012-10-28 19:46:46207 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
[email protected]19da16a92012-05-23 17:11:29208 OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL);
[email protected]87c7c292011-10-27 16:16:41209 LOG(INFO) << "WindowOpenHelper 1.";
[email protected]19da16a92012-05-23 17:11:29210 OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL);
[email protected]87c7c292011-10-27 16:16:41211 LOG(INFO) << "WindowOpenHelper 2.";
[email protected]361a5f1f2011-10-05 20:11:15212 // TODO(creis): This should open in a new process (i.e., false for the last
[email protected]ea7b7d82012-05-25 17:29:17213 // argument), but we temporarily avoid swapping processes away from a hosted
214 // app if it has an opener, because some OAuth providers make script calls
215 // between non-app popups and non-app iframes in the app process.
[email protected]361a5f1f2011-10-05 20:11:15216 // See crbug.com/59285.
[email protected]19da16a92012-05-23 17:11:29217 OpenWindow(tab, base_url.Resolve("path3/empty.html"), true, NULL);
[email protected]87c7c292011-10-27 16:16:41218 LOG(INFO) << "WindowOpenHelper 3.";
[email protected]3a8eecb2010-04-22 23:56:30219
220 // Now let's have these pages navigate, into or out of the extension web
221 // extent. They should switch processes.
[email protected]9a1e6d42010-04-26 22:29:36222 const GURL& app_url(base_url.Resolve("path1/empty.html"));
223 const GURL& non_app_url(base_url.Resolve("path3/empty.html"));
[email protected]e0448872013-01-11 19:35:02224 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2),
225 non_app_url);
[email protected]87c7c292011-10-27 16:16:41226 LOG(INFO) << "NavigateTabHelper 1.";
[email protected]e0448872013-01-11 19:35:02227 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(3),
228 app_url);
[email protected]87c7c292011-10-27 16:16:41229 LOG(INFO) << "NavigateTabHelper 2.";
[email protected]ea7b7d82012-05-25 17:29:17230 EXPECT_NE(tab->GetRenderProcessHost(),
[email protected]e0448872013-01-11 19:35:02231 browser()->tab_strip_model()->GetWebContentsAt(2)->
232 GetRenderProcessHost());
[email protected]19da16a92012-05-23 17:11:29233 EXPECT_EQ(tab->GetRenderProcessHost(),
[email protected]e0448872013-01-11 19:35:02234 browser()->tab_strip_model()->GetWebContentsAt(3)->
235 GetRenderProcessHost());
[email protected]08e94b82010-12-15 22:51:04236
237 // If one of the popup tabs navigates back to the app, window.opener should
238 // be valid.
[email protected]e0448872013-01-11 19:35:02239 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(6),
240 app_url);
[email protected]87c7c292011-10-27 16:16:41241 LOG(INFO) << "NavigateTabHelper 3.";
[email protected]19da16a92012-05-23 17:11:29242 EXPECT_EQ(tab->GetRenderProcessHost(),
[email protected]e0448872013-01-11 19:35:02243 browser()->tab_strip_model()->GetWebContentsAt(6)->
244 GetRenderProcessHost());
[email protected]08e94b82010-12-15 22:51:04245 bool windowOpenerValid = false;
[email protected]b6987e02013-01-04 18:30:43246 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
[email protected]e0448872013-01-11 19:35:02247 browser()->tab_strip_model()->GetWebContentsAt(6),
[email protected]06bc5d92013-01-02 22:44:13248 "window.domAutomationController.send(window.opener != null)",
[email protected]08e94b82010-12-15 22:51:04249 &windowOpenerValid));
250 ASSERT_TRUE(windowOpenerValid);
[email protected]87c7c292011-10-27 16:16:41251
252 LOG(INFO) << "End of test.";
[email protected]3a8eecb2010-04-22 23:56:30253}
[email protected]faf407b2011-01-05 01:24:32254
[email protected]056ad2a2011-07-12 02:13:55255// Test that hosted apps without the background permission use a process per app
256// instance model, such that separate instances are in separate processes.
[email protected]19da16a92012-05-23 17:11:29257IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) {
[email protected]7b54ca02012-03-02 18:06:53258 TestAppInstancesHelper("app_process_instances");
259}
[email protected]87c7c292011-10-27 16:16:41260
[email protected]7b54ca02012-03-02 18:06:53261// Test that hosted apps with the background permission but that set
262// allow_js_access to false also use a process per app instance model.
263// Separate instances should be in separate processes.
[email protected]0d70b7d42012-12-13 01:14:20264// Flaky on XP: http://crbug.com/165834
[email protected]0cfb748b2012-12-13 01:10:11265#if defined(OS_WIN)
266#define MAYBE_AppProcessBackgroundInstances \
267 DISABLED_AppProcessBackgroundInstances
268#else
269#define MAYBE_AppProcessBackgroundInstances AppProcessBackgroundInstances
270#endif
271IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcessBackgroundInstances) {
[email protected]7b54ca02012-03-02 18:06:53272 TestAppInstancesHelper("app_process_background_instances");
[email protected]056ad2a2011-07-12 02:13:55273}
274
[email protected]15877ca2011-11-18 22:40:52275// Tests that bookmark apps do not use the app process model and are treated
276// like normal web pages instead. http://crbug.com/104636.
[email protected]19da16a92012-05-23 17:11:29277IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) {
[email protected]06bdd2b2012-11-30 18:47:13278 ExtensionService* service = extensions::ExtensionSystem::Get(
279 browser()->profile())->extension_service();
[email protected]c2f36e3a2011-12-14 01:27:19280 extensions::ProcessMap* process_map = service->process_map();
[email protected]15877ca2011-11-18 22:40:52281
282 host_resolver()->AddRule("*", "127.0.0.1");
283 ASSERT_TRUE(test_server()->Start());
[email protected]15877ca2011-11-18 22:40:52284 GURL base_url = GetTestBaseURL("app_process");
285
[email protected]c2f36e3a2011-12-14 01:27:19286 // Load an app as a bookmark app.
287 std::string error;
288 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
289 test_data_dir_.AppendASCII("app_process"),
[email protected]12075d12013-02-27 05:38:05290 extensions::Manifest::UNPACKED,
[email protected]c2f36e3a2011-12-14 01:27:19291 Extension::FROM_BOOKMARK,
292 &error));
[email protected]26367b62012-10-04 23:03:32293 service->OnExtensionInstalled(extension,
[email protected]98270432012-09-11 20:51:24294 syncer::StringOrdinal::CreateInitialOrdinal(),
[email protected]0db124b02012-11-07 04:55:05295 false /* no requirement errors */,
296 false /* don't wait for idle */);
[email protected]c2f36e3a2011-12-14 01:27:19297 ASSERT_TRUE(extension.get());
298 ASSERT_TRUE(extension->from_bookmark());
299
[email protected]15877ca2011-11-18 22:40:52300 // Test both opening a URL in a new tab, and opening a tab and then navigating
301 // it. Either way, bookmark app tabs should be considered normal processes
302 // with no elevated privileges and no WebUI bindings.
303 ui_test_utils::NavigateToURLWithDisposition(
304 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB,
305 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
306 EXPECT_FALSE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02307 browser()->tab_strip_model()->GetWebContentsAt(1)->
308 GetRenderProcessHost()->GetID()));
309 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI());
[email protected]15877ca2011-11-18 22:40:52310
[email protected]a7fe9112012-07-20 02:34:45311 content::WindowedNotificationObserver tab_added_observer(
[email protected]884033e2012-04-16 19:38:42312 chrome::NOTIFICATION_TAB_ADDED,
[email protected]15877ca2011-11-18 22:40:52313 content::NotificationService::AllSources());
[email protected]a37d4b02012-06-25 21:56:10314 chrome::NewTab(browser());
[email protected]15877ca2011-11-18 22:40:52315 tab_added_observer.Wait();
316 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html"));
317 EXPECT_FALSE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02318 browser()->tab_strip_model()->GetWebContentsAt(2)->
319 GetRenderProcessHost()->GetID()));
320 EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(2)->GetWebUI());
[email protected]15877ca2011-11-18 22:40:52321
322 // We should have opened 2 new bookmark app tabs. Including the original blank
323 // tab, we now have 3 tabs. Because normal pages use the
324 // process-per-site-instance model, each should be in its own process.
[email protected]e0448872013-01-11 19:35:02325 ASSERT_EQ(3, browser()->tab_strip_model()->count());
326 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1);
[email protected]19da16a92012-05-23 17:11:29327 EXPECT_NE(tab->GetRenderProcessHost(),
[email protected]e0448872013-01-11 19:35:02328 browser()->tab_strip_model()->GetWebContentsAt(2)->
329 GetRenderProcessHost());
[email protected]15877ca2011-11-18 22:40:52330
331 // Now let's do the same using window.open. The same should happen.
[email protected]52ff7d932012-10-28 19:46:46332 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
[email protected]19da16a92012-05-23 17:11:29333 OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL);
334 OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL);
[email protected]15877ca2011-11-18 22:40:52335
336 // Now let's have a tab navigate out of and back into the app's web
337 // extent. Neither navigation should switch processes.
338 const GURL& app_url(base_url.Resolve("path1/empty.html"));
339 const GURL& non_app_url(base_url.Resolve("path3/empty.html"));
[email protected]52877dbc62012-06-29 22:22:03340 RenderViewHost* host2 =
[email protected]e0448872013-01-11 19:35:02341 browser()->tab_strip_model()->GetWebContentsAt(2)->GetRenderViewHost();
342 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2),
343 non_app_url);
[email protected]9f76c1e2012-03-05 15:15:58344 EXPECT_EQ(host2->GetProcess(),
[email protected]e0448872013-01-11 19:35:02345 browser()->tab_strip_model()->GetWebContentsAt(2)->
346 GetRenderProcessHost());
347 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2),
348 app_url);
[email protected]9f76c1e2012-03-05 15:15:58349 EXPECT_EQ(host2->GetProcess(),
[email protected]e0448872013-01-11 19:35:02350 browser()->tab_strip_model()->GetWebContentsAt(2)->
351 GetRenderProcessHost());
[email protected]15877ca2011-11-18 22:40:52352}
353
[email protected]faf407b2011-01-05 01:24:32354// Tests that app process switching works properly in the following scenario:
355// 1. navigate to a page1 in the app
356// 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect")
357// 3. page2 redirects back to a page in the app
358// The final navigation should end up in the app process.
359// See http://crbug.com/61757
[email protected]ea7b7d82012-05-25 17:29:17360IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) {
[email protected]faf407b2011-01-05 01:24:32361 host_resolver()->AddRule("*", "127.0.0.1");
362 ASSERT_TRUE(test_server()->Start());
363
364 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process")));
365
366 // Open two tabs in the app.
[email protected]118d3122011-08-10 17:09:53367 GURL base_url = GetTestBaseURL("app_process");
[email protected]faf407b2011-01-05 01:24:32368
[email protected]a37d4b02012-06-25 21:56:10369 chrome::NewTab(browser());
[email protected]faf407b2011-01-05 01:24:32370 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
[email protected]a37d4b02012-06-25 21:56:10371 chrome::NewTab(browser());
[email protected]ea7b7d82012-05-25 17:29:17372 // Wait until the second tab finishes its redirect train (2 hops).
[email protected]4ad5d77d2011-12-03 02:00:48373 // 1. We navigate to redirect.html
374 // 2. Renderer navigates and finishes, counting as a load stop.
375 // 3. Renderer issues the meta refresh to navigate to server-redirect.
376 // 4. Renderer is now in a "provisional load", waiting for navigation to
377 // complete.
378 // 5. Browser sees a redirect response from server-redirect to empty.html, and
379 // transfers that to a new navigation, using RequestTransferURL.
[email protected]ea7b7d82012-05-25 17:29:17380 // 6. Renderer navigates to empty.html, and finishes loading, counting as the
381 // second load stop
[email protected]4ad5d77d2011-12-03 02:00:48382 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
[email protected]ea7b7d82012-05-25 17:29:17383 browser(), base_url.Resolve("path1/redirect.html"), 2);
[email protected]faf407b2011-01-05 01:24:32384
385 // 3 tabs, including the initial about:blank. The last 2 should be the same
386 // process.
[email protected]e0448872013-01-11 19:35:02387 ASSERT_EQ(3, browser()->tab_strip_model()->count());
[email protected]089e8c332011-01-06 21:37:29388 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html",
[email protected]e0448872013-01-11 19:35:02389 browser()->tab_strip_model()->GetWebContentsAt(2)->
390 GetController().GetLastCommittedEntry()->GetURL().path());
391 EXPECT_EQ(browser()->tab_strip_model()->GetWebContentsAt(1)->
392 GetRenderProcessHost(),
393 browser()->tab_strip_model()->GetWebContentsAt(2)->
394 GetRenderProcessHost());
[email protected]faf407b2011-01-05 01:24:32395}
[email protected]d292d8a2011-05-25 03:47:11396
397// Ensure that reloading a URL after installing or uninstalling it as an app
398// correctly swaps the process. (http://crbug.com/80621)
[email protected]28505fc2012-05-02 10:33:09399//
400// The test times out under AddressSanitizer, see http://crbug.com/103371
401#if defined(ADDRESS_SANITIZER)
402#define MAYBE_ReloadIntoAppProcess DISABLED_ReloadIntoAppProcess
403#else
404#define MAYBE_ReloadIntoAppProcess ReloadIntoAppProcess
405#endif
406IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) {
[email protected]06bdd2b2012-11-30 18:47:13407 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get(
408 browser()->profile())->extension_service()->process_map();
[email protected]718eab62011-10-05 21:16:52409
[email protected]d292d8a2011-05-25 03:47:11410 host_resolver()->AddRule("*", "127.0.0.1");
411 ASSERT_TRUE(test_server()->Start());
412
413 // The app under test acts on URLs whose host is "localhost",
414 // so the URLs we navigate to must have host "localhost".
[email protected]118d3122011-08-10 17:09:53415 GURL base_url = GetTestBaseURL("app_process");
[email protected]d292d8a2011-05-25 03:47:11416
417 // Load an app URL before loading the app.
418 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
[email protected]e0448872013-01-11 19:35:02419 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0);
[email protected]6f371442011-11-09 06:45:46420 EXPECT_FALSE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52421 contents->GetRenderProcessHost()->GetID()));
[email protected]d292d8a2011-05-25 03:47:11422
[email protected]8d3132f62011-10-12 07:13:42423 // Load app and navigate to the page.
[email protected]d292d8a2011-05-25 03:47:11424 const Extension* app =
425 LoadExtension(test_data_dir_.AppendASCII("app_process"));
426 ASSERT_TRUE(app);
427 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
[email protected]6f371442011-11-09 06:45:46428 EXPECT_TRUE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52429 contents->GetRenderProcessHost()->GetID()));
[email protected]d292d8a2011-05-25 03:47:11430
[email protected]8d3132f62011-10-12 07:13:42431 // Disable app and navigate to the page.
[email protected]d292d8a2011-05-25 03:47:11432 DisableExtension(app->id());
433 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
[email protected]6f371442011-11-09 06:45:46434 EXPECT_FALSE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52435 contents->GetRenderProcessHost()->GetID()));
[email protected]d292d8a2011-05-25 03:47:11436
[email protected]8d3132f62011-10-12 07:13:42437 // Enable app and reload the page.
438 EnableExtension(app->id());
[email protected]a7fe9112012-07-20 02:34:45439 content::WindowedNotificationObserver reload_observer(
[email protected]8d3132f62011-10-12 07:13:42440 content::NOTIFICATION_LOAD_STOP,
[email protected]c5eed492012-01-04 17:07:50441 content::Source<NavigationController>(
[email protected]e0448872013-01-11 19:35:02442 &browser()->tab_strip_model()->GetActiveWebContents()->
443 GetController()));
[email protected]a37d4b02012-06-25 21:56:10444 chrome::Reload(browser(), CURRENT_TAB);
[email protected]8d3132f62011-10-12 07:13:42445 reload_observer.Wait();
[email protected]6f371442011-11-09 06:45:46446 EXPECT_TRUE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52447 contents->GetRenderProcessHost()->GetID()));
[email protected]8d3132f62011-10-12 07:13:42448
449 // Disable app and reload the page.
450 DisableExtension(app->id());
[email protected]a7fe9112012-07-20 02:34:45451 content::WindowedNotificationObserver reload_observer2(
[email protected]8d3132f62011-10-12 07:13:42452 content::NOTIFICATION_LOAD_STOP,
[email protected]c5eed492012-01-04 17:07:50453 content::Source<NavigationController>(
[email protected]e0448872013-01-11 19:35:02454 &browser()->tab_strip_model()->GetActiveWebContents()->
455 GetController()));
[email protected]a37d4b02012-06-25 21:56:10456 chrome::Reload(browser(), CURRENT_TAB);
[email protected]8d3132f62011-10-12 07:13:42457 reload_observer2.Wait();
[email protected]6f371442011-11-09 06:45:46458 EXPECT_FALSE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52459 contents->GetRenderProcessHost()->GetID()));
[email protected]8d3132f62011-10-12 07:13:42460
[email protected]d292d8a2011-05-25 03:47:11461 // Enable app and reload via JavaScript.
462 EnableExtension(app->id());
[email protected]a7fe9112012-07-20 02:34:45463 content::WindowedNotificationObserver js_reload_observer(
[email protected]8d3132f62011-10-12 07:13:42464 content::NOTIFICATION_LOAD_STOP,
[email protected]c5eed492012-01-04 17:07:50465 content::Source<NavigationController>(
[email protected]e0448872013-01-11 19:35:02466 &browser()->tab_strip_model()->GetActiveWebContents()->
467 GetController()));
[email protected]b6987e02013-01-04 18:30:43468 ASSERT_TRUE(content::ExecuteScript(contents, "location.reload();"));
[email protected]8d3132f62011-10-12 07:13:42469 js_reload_observer.Wait();
[email protected]6f371442011-11-09 06:45:46470 EXPECT_TRUE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52471 contents->GetRenderProcessHost()->GetID()));
[email protected]d292d8a2011-05-25 03:47:11472
473 // Disable app and reload via JavaScript.
474 DisableExtension(app->id());
[email protected]a7fe9112012-07-20 02:34:45475 content::WindowedNotificationObserver js_reload_observer2(
[email protected]8d3132f62011-10-12 07:13:42476 content::NOTIFICATION_LOAD_STOP,
[email protected]c5eed492012-01-04 17:07:50477 content::Source<NavigationController>(
[email protected]e0448872013-01-11 19:35:02478 &browser()->tab_strip_model()->GetActiveWebContents()->
479 GetController()));
[email protected]b6987e02013-01-04 18:30:43480 ASSERT_TRUE(content::ExecuteScript(contents, "location = location;"));
[email protected]8d3132f62011-10-12 07:13:42481 js_reload_observer2.Wait();
[email protected]6f371442011-11-09 06:45:46482 EXPECT_FALSE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52483 contents->GetRenderProcessHost()->GetID()));
[email protected]d292d8a2011-05-25 03:47:11484}
[email protected]118d3122011-08-10 17:09:53485
[email protected]118d3122011-08-10 17:09:53486// Tests that if we have a non-app process (path3/container.html) that has an
487// iframe with a URL in the app's extent (path1/iframe.html), then opening a
488// link from that iframe to a new window to a URL in the app's extent (path1/
489// empty.html) results in the new window being in an app process. See
490// http://crbug.com/89272 for more details.
[email protected]1f4495b2012-10-12 05:51:05491IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) {
[email protected]06bdd2b2012-11-30 18:47:13492 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get(
493 browser()->profile())->extension_service()->process_map();
[email protected]718eab62011-10-05 21:16:52494
[email protected]118d3122011-08-10 17:09:53495 host_resolver()->AddRule("*", "127.0.0.1");
496 ASSERT_TRUE(test_server()->Start());
497
498 GURL base_url = GetTestBaseURL("app_process");
499
500 // Load app and start URL (not in the app).
501 const Extension* app =
502 LoadExtension(test_data_dir_.AppendASCII("app_process"));
503 ASSERT_TRUE(app);
[email protected]19da16a92012-05-23 17:11:29504
[email protected]a7fe9112012-07-20 02:34:45505 content::WindowedNotificationObserver popup_observer(
[email protected]079b3cc2012-09-26 19:59:13506 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
507 content::NotificationService::AllSources());
[email protected]19da16a92012-05-23 17:11:29508 ui_test_utils::NavigateToURL(browser(),
509 base_url.Resolve("path3/container.html"));
[email protected]6f371442011-11-09 06:45:46510 EXPECT_FALSE(process_map->Contains(
[email protected]e0448872013-01-11 19:35:02511 browser()->tab_strip_model()->GetWebContentsAt(0)->
512 GetRenderProcessHost()->GetID()));
[email protected]19da16a92012-05-23 17:11:29513 popup_observer.Wait();
[email protected]118d3122011-08-10 17:09:53514
515 // Popup window should be in the app's process.
[email protected]19da16a92012-05-23 17:11:29516 RenderViewHost* popup_host =
517 content::Source<RenderViewHost>(popup_observer.source()).ptr();
518 EXPECT_TRUE(process_map->Contains(popup_host->GetProcess()->GetID()));
[email protected]118d3122011-08-10 17:09:53519}
[email protected]a09add52011-08-12 03:59:23520
[email protected]079b3cc2012-09-26 19:59:13521// Similar to the previous test, but ensure that popup blocking bypass
522// isn't granted to the iframe. See crbug.com/117446.
[email protected]1f4495b2012-10-12 05:51:05523#if defined(OS_CHROMEOS)
524// http://crbug.com/153513
525#define MAYBE_OpenAppFromIframe DISABLED_OpenAppFromIframe
526#else
527#define MAYBE_OpenAppFromIframe OpenAppFromIframe
528#endif
529IN_PROC_BROWSER_TEST_F(BlockedAppApiTest, MAYBE_OpenAppFromIframe) {
[email protected]079b3cc2012-09-26 19:59:13530 host_resolver()->AddRule("*", "127.0.0.1");
531 ASSERT_TRUE(test_server()->Start());
532
533 // Load app and start URL (not in the app).
534 const Extension* app =
535 LoadExtension(test_data_dir_.AppendASCII("app_process"));
536 ASSERT_TRUE(app);
537
538 content::WindowedNotificationObserver blocker_observer(
539 chrome::NOTIFICATION_CONTENT_BLOCKED_STATE_CHANGED,
540 content::NotificationService::AllSources());
541 ui_test_utils::NavigateToURL(
542 browser(), GetTestBaseURL("app_process").Resolve("path3/container.html"));
543
544 blocker_observer.Wait();
545
[email protected]e0448872013-01-11 19:35:02546 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
[email protected]079b3cc2012-09-26 19:59:13547 BlockedContentTabHelper* blocked_content_tab_helper =
548 BlockedContentTabHelper::FromWebContents(tab);
549 std::vector<WebContents*> blocked_contents;
550 blocked_content_tab_helper->GetBlockedContents(&blocked_contents);
551 EXPECT_EQ(blocked_contents.size(), 1u);
552}
553
[email protected]88aae972011-12-16 01:14:18554// Tests that if an extension launches an app via chrome.tabs.create with an URL
555// that's not in the app's extent but that redirects to it, we still end up with
556// an app process. See http://crbug.com/99349 for more details.
557IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromExtension) {
558 host_resolver()->AddRule("*", "127.0.0.1");
559 ASSERT_TRUE(StartTestServer());
560
561 LoadExtension(test_data_dir_.AppendASCII("app_process"));
562 const Extension* launcher =
563 LoadExtension(test_data_dir_.AppendASCII("app_launcher"));
564
565 // There should be three navigations by the time the app page is loaded.
566 // 1. The extension launcher page.
567 // 2. The URL that the extension launches, which redirects.
568 // 3. The app's URL.
[email protected]5b8ff1c2012-06-02 20:42:20569 content::TestNavigationObserver test_navigation_observer(
570 content::NotificationService::AllSources(),
571 NULL,
572 3);
[email protected]88aae972011-12-16 01:14:18573
574 // Load the launcher extension, which should launch the app.
575 ui_test_utils::NavigateToURLWithDisposition(
576 browser(),
577 launcher->GetResourceURL("main.html"),
578 CURRENT_TAB,
579 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
580
581 // Wait for app tab to be created and loaded.
582 test_navigation_observer.WaitForObservation(
[email protected]729eb632012-07-26 04:45:26583 base::Bind(&content::RunMessageLoop),
[email protected]88aae972011-12-16 01:14:18584 base::Bind(&MessageLoop::Quit,
585 base::Unretained(MessageLoopForUI::current())));
586
587 // App has loaded, and chrome.app.isInstalled should be true.
588 bool is_installed = false;
[email protected]b6987e02013-01-04 18:30:43589 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
[email protected]e0448872013-01-11 19:35:02590 browser()->tab_strip_model()->GetActiveWebContents(),
[email protected]06bc5d92013-01-02 22:44:13591 "window.domAutomationController.send(chrome.app.isInstalled)",
[email protected]88aae972011-12-16 01:14:18592 &is_installed));
593 ASSERT_TRUE(is_installed);
594}
595
[email protected]d55c2382011-08-18 23:10:36596// Tests that if we have an app process (path1/container.html) with a non-app
597// iframe (path3/iframe.html), then opening a link from that iframe to a new
598// window to a same-origin non-app URL (path3/empty.html) should keep the window
599// in the app process.
600// This is in contrast to OpenAppFromIframe, since here the popup will not be
601// missing special permissions and should be scriptable from the iframe.
602// See http://crbug.com/92669 for more details.
[email protected]19da16a92012-05-23 17:11:29603IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) {
[email protected]06bdd2b2012-11-30 18:47:13604 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get(
605 browser()->profile())->extension_service()->process_map();
[email protected]718eab62011-10-05 21:16:52606
[email protected]d55c2382011-08-18 23:10:36607 host_resolver()->AddRule("*", "127.0.0.1");
608 ASSERT_TRUE(test_server()->Start());
609
610 GURL base_url = GetTestBaseURL("app_process");
611
612 // Load app and start URL (in the app).
613 const Extension* app =
614 LoadExtension(test_data_dir_.AppendASCII("app_process"));
615 ASSERT_TRUE(app);
[email protected]19da16a92012-05-23 17:11:29616
[email protected]a7fe9112012-07-20 02:34:45617 content::WindowedNotificationObserver popup_observer(
[email protected]19da16a92012-05-23 17:11:29618 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
619 content::NotificationService::AllSources());
620 ui_test_utils::NavigateToURL(browser(),
621 base_url.Resolve("path1/container.html"));
[email protected]f3b1a082011-11-18 00:34:30622 content::RenderProcessHost* process =
[email protected]e0448872013-01-11 19:35:02623 browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderProcessHost();
[email protected]f3b1a082011-11-18 00:34:30624 EXPECT_TRUE(process_map->Contains(process->GetID()));
[email protected]d55c2382011-08-18 23:10:36625
[email protected]19da16a92012-05-23 17:11:29626 // Wait for popup window to appear.
627 popup_observer.Wait();
[email protected]d55c2382011-08-18 23:10:36628
629 // Popup window should be in the app's process.
[email protected]19da16a92012-05-23 17:11:29630 RenderViewHost* popup_host =
631 content::Source<RenderViewHost>(popup_observer.source()).ptr();
632 EXPECT_EQ(process, popup_host->GetProcess());
[email protected]d55c2382011-08-18 23:10:36633}
634
[email protected]a344b762012-03-16 18:53:49635// http://crbug.com/118502
636#if defined(OS_MACOSX) || defined(OS_LINUX)
637#define MAYBE_ReloadAppAfterCrash DISABLED_ReloadAppAfterCrash
638#else
639#define MAYBE_ReloadAppAfterCrash ReloadAppAfterCrash
640#endif
641IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) {
[email protected]06bdd2b2012-11-30 18:47:13642 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get(
643 browser()->profile())->extension_service()->process_map();
[email protected]6f371442011-11-09 06:45:46644
[email protected]a09add52011-08-12 03:59:23645 host_resolver()->AddRule("*", "127.0.0.1");
646 ASSERT_TRUE(test_server()->Start());
647
648 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process")));
649
650 GURL base_url = GetTestBaseURL("app_process");
651
652 // Load the app, chrome.app.isInstalled should be true.
653 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
[email protected]e0448872013-01-11 19:35:02654 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0);
[email protected]6f371442011-11-09 06:45:46655 EXPECT_TRUE(process_map->Contains(
[email protected]151a63d2011-12-20 22:32:52656 contents->GetRenderProcessHost()->GetID()));
[email protected]a09add52011-08-12 03:59:23657 bool is_installed = false;
[email protected]b6987e02013-01-04 18:30:43658 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
659 contents,
[email protected]06bc5d92013-01-02 22:44:13660 "window.domAutomationController.send(chrome.app.isInstalled)",
[email protected]a09add52011-08-12 03:59:23661 &is_installed));
662 ASSERT_TRUE(is_installed);
663
664 // Crash the tab and reload it, chrome.app.isInstalled should still be true.
[email protected]e0448872013-01-11 19:35:02665 content::CrashTab(browser()->tab_strip_model()->GetActiveWebContents());
[email protected]a7fe9112012-07-20 02:34:45666 content::WindowedNotificationObserver observer(
[email protected]ae673742011-08-24 19:48:37667 content::NOTIFICATION_LOAD_STOP,
[email protected]c5eed492012-01-04 17:07:50668 content::Source<NavigationController>(
[email protected]e0448872013-01-11 19:35:02669 &browser()->tab_strip_model()->GetActiveWebContents()->
670 GetController()));
[email protected]a37d4b02012-06-25 21:56:10671 chrome::Reload(browser(), CURRENT_TAB);
[email protected]ae673742011-08-24 19:48:37672 observer.Wait();
[email protected]b6987e02013-01-04 18:30:43673 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
674 contents,
[email protected]06bc5d92013-01-02 22:44:13675 "window.domAutomationController.send(chrome.app.isInstalled)",
[email protected]a09add52011-08-12 03:59:23676 &is_installed));
677 ASSERT_TRUE(is_installed);
678}