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

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

Issue 62713003: Move ExtensionProcessManager to src/extensions, part 4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 1 month 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" 10 #include "chrome/browser/bookmarks/bookmark_test_helpers.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (extension) 97 if (extension)
98 page_complete.Wait(); 98 page_complete.Wait();
99 return extension; 99 return extension;
100 } 100 }
101 }; 101 };
102 102
103 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BrowserActionCreateTab) { 103 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BrowserActionCreateTab) {
104 ASSERT_TRUE(LoadExtensionAndWait("browser_action_create_tab")); 104 ASSERT_TRUE(LoadExtensionAndWait("browser_action_create_tab"));
105 105
106 // Lazy Background Page doesn't exist yet. 106 // Lazy Background Page doesn't exist yet.
107 ExtensionProcessManager* pm = 107 extensions::ProcessManager* pm =
108 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 108 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
109 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 109 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
110 int num_tabs_before = browser()->tab_strip_model()->count(); 110 int num_tabs_before = browser()->tab_strip_model()->count();
111 111
112 // Observe background page being created and closed after 112 // Observe background page being created and closed after
113 // the browser action is clicked. 113 // the browser action is clicked.
114 LazyBackgroundObserver page_complete; 114 LazyBackgroundObserver page_complete;
115 BrowserActionTestUtil(browser()).Press(0); 115 BrowserActionTestUtil(browser()).Press(0);
116 page_complete.Wait(); 116 page_complete.Wait();
117 117
118 // Background page created a new tab before it closed. 118 // Background page created a new tab before it closed.
119 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 119 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
120 EXPECT_EQ(num_tabs_before + 1, browser()->tab_strip_model()->count()); 120 EXPECT_EQ(num_tabs_before + 1, browser()->tab_strip_model()->count());
121 EXPECT_EQ(std::string(chrome::kChromeUIExtensionsURL), 121 EXPECT_EQ(std::string(chrome::kChromeUIExtensionsURL),
122 browser()->tab_strip_model()->GetActiveWebContents()-> 122 browser()->tab_strip_model()->GetActiveWebContents()->
123 GetURL().spec()); 123 GetURL().spec());
124 } 124 }
125 125
126 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, 126 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest,
127 BrowserActionCreateTabAfterCallback) { 127 BrowserActionCreateTabAfterCallback) {
128 ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback")); 128 ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback"));
129 129
130 // Lazy Background Page doesn't exist yet. 130 // Lazy Background Page doesn't exist yet.
131 ExtensionProcessManager* pm = 131 extensions::ProcessManager* pm =
132 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 132 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
133 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 133 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
134 int num_tabs_before = browser()->tab_strip_model()->count(); 134 int num_tabs_before = browser()->tab_strip_model()->count();
135 135
136 // Observe background page being created and closed after 136 // Observe background page being created and closed after
137 // the browser action is clicked. 137 // the browser action is clicked.
138 LazyBackgroundObserver page_complete; 138 LazyBackgroundObserver page_complete;
139 BrowserActionTestUtil(browser()).Press(0); 139 BrowserActionTestUtil(browser()).Press(0);
140 page_complete.Wait(); 140 page_complete.Wait();
141 141
142 // Background page is closed after creating a new tab. 142 // Background page is closed after creating a new tab.
143 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 143 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
144 EXPECT_EQ(num_tabs_before + 1, browser()->tab_strip_model()->count()); 144 EXPECT_EQ(num_tabs_before + 1, browser()->tab_strip_model()->count());
145 } 145 }
146 146
147 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BroadcastEvent) { 147 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BroadcastEvent) {
148 ASSERT_TRUE(StartEmbeddedTestServer()); 148 ASSERT_TRUE(StartEmbeddedTestServer());
149 149
150 const Extension* extension = LoadExtensionAndWait("broadcast_event"); 150 const Extension* extension = LoadExtensionAndWait("broadcast_event");
151 ASSERT_TRUE(extension); 151 ASSERT_TRUE(extension);
152 152
153 // Lazy Background Page doesn't exist yet. 153 // Lazy Background Page doesn't exist yet.
154 ExtensionProcessManager* pm = 154 extensions::ProcessManager* pm =
155 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 155 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
156 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 156 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
157 int num_page_actions = browser()->window()->GetLocationBar()-> 157 int num_page_actions = browser()->window()->GetLocationBar()->
158 GetLocationBarForTesting()->PageActionVisibleCount(); 158 GetLocationBarForTesting()->PageActionVisibleCount();
159 159
160 // Open a tab to a URL that will trigger the page action to show. 160 // Open a tab to a URL that will trigger the page action to show.
161 LazyBackgroundObserver page_complete; 161 LazyBackgroundObserver page_complete;
162 content::WindowedNotificationObserver page_action_changed( 162 content::WindowedNotificationObserver page_action_changed(
163 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 163 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
164 content::NotificationService::AllSources()); 164 content::NotificationService::AllSources());
(...skipping 10 matching lines...) Expand all
175 GetLocationBarForTesting()->PageActionVisibleCount()); 175 GetLocationBarForTesting()->PageActionVisibleCount());
176 } 176 }
177 177
178 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Filters) { 178 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Filters) {
179 ASSERT_TRUE(StartEmbeddedTestServer()); 179 ASSERT_TRUE(StartEmbeddedTestServer());
180 180
181 const Extension* extension = LoadExtensionAndWait("filters"); 181 const Extension* extension = LoadExtensionAndWait("filters");
182 ASSERT_TRUE(extension); 182 ASSERT_TRUE(extension);
183 183
184 // Lazy Background Page doesn't exist yet. 184 // Lazy Background Page doesn't exist yet.
185 ExtensionProcessManager* pm = 185 extensions::ProcessManager* pm =
186 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 186 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
187 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 187 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
188 188
189 // Open a tab to a URL that will fire a webNavigation event. 189 // Open a tab to a URL that will fire a webNavigation event.
190 LazyBackgroundObserver page_complete; 190 LazyBackgroundObserver page_complete;
191 ui_test_utils::NavigateToURL( 191 ui_test_utils::NavigateToURL(
192 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); 192 browser(), embedded_test_server()->GetURL("/extensions/test_file.html"));
193 page_complete.Wait(); 193 page_complete.Wait();
194 } 194 }
195 195
196 // Tests that the lazy background page receives the onInstalled event and shuts 196 // Tests that the lazy background page receives the onInstalled event and shuts
197 // down. 197 // down.
198 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnInstalled) { 198 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnInstalled) {
199 ResultCatcher catcher; 199 ResultCatcher catcher;
200 ASSERT_TRUE(LoadExtensionAndWait("on_installed")); 200 ASSERT_TRUE(LoadExtensionAndWait("on_installed"));
201 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 201 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
202 202
203 // Lazy Background Page has been shut down. 203 // Lazy Background Page has been shut down.
204 ExtensionProcessManager* pm = 204 extensions::ProcessManager* pm =
205 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 205 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
206 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 206 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
207 } 207 }
208 208
209 // Tests that the lazy background page stays alive until all visible views are 209 // Tests that the lazy background page stays alive until all visible views are
210 // closed. 210 // closed.
211 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForView) { 211 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForView) {
212 LazyBackgroundObserver page_complete; 212 LazyBackgroundObserver page_complete;
213 ResultCatcher catcher; 213 ResultCatcher catcher;
214 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). 214 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page").
215 AppendASCII("wait_for_view"); 215 AppendASCII("wait_for_view");
216 const Extension* extension = LoadExtension(extdir); 216 const Extension* extension = LoadExtension(extdir);
217 ASSERT_TRUE(extension); 217 ASSERT_TRUE(extension);
218 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 218 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
219 219
220 // The extension should've opened a new tab to an extension page. 220 // The extension should've opened a new tab to an extension page.
221 EXPECT_EQ(extension->GetResourceURL("extension_page.html").spec(), 221 EXPECT_EQ(extension->GetResourceURL("extension_page.html").spec(),
222 browser()->tab_strip_model()->GetActiveWebContents()-> 222 browser()->tab_strip_model()->GetActiveWebContents()->
223 GetURL().spec()); 223 GetURL().spec());
224 224
225 // Lazy Background Page still exists, because the extension created a new tab 225 // Lazy Background Page still exists, because the extension created a new tab
226 // to an extension page. 226 // to an extension page.
227 ExtensionProcessManager* pm = 227 extensions::ProcessManager* pm =
228 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 228 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
229 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 229 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
230 230
231 // Close the new tab. 231 // Close the new tab.
232 browser()->tab_strip_model()->CloseWebContentsAt( 232 browser()->tab_strip_model()->CloseWebContentsAt(
233 browser()->tab_strip_model()->active_index(), TabStripModel::CLOSE_NONE); 233 browser()->tab_strip_model()->active_index(), TabStripModel::CLOSE_NONE);
234 page_complete.Wait(); 234 page_complete.Wait();
235 235
236 // Lazy Background Page has been shut down. 236 // Lazy Background Page has been shut down.
237 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 237 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
238 } 238 }
239 239
240 // Tests that the lazy background page stays alive until all network requests 240 // Tests that the lazy background page stays alive until all network requests
241 // are complete. 241 // are complete.
242 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) { 242 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) {
243 host_resolver()->AddRule("*", "127.0.0.1"); 243 host_resolver()->AddRule("*", "127.0.0.1");
244 ASSERT_TRUE(StartEmbeddedTestServer()); 244 ASSERT_TRUE(StartEmbeddedTestServer());
245 245
246 LazyBackgroundObserver page_complete; 246 LazyBackgroundObserver page_complete;
247 ResultCatcher catcher; 247 ResultCatcher catcher;
248 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). 248 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page").
249 AppendASCII("wait_for_request"); 249 AppendASCII("wait_for_request");
250 const Extension* extension = LoadExtension(extdir); 250 const Extension* extension = LoadExtension(extdir);
251 ASSERT_TRUE(extension); 251 ASSERT_TRUE(extension);
252 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 252 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
253 253
254 // Lazy Background Page still exists, because the extension started a request. 254 // Lazy Background Page still exists, because the extension started a request.
255 ExtensionProcessManager* pm = 255 extensions::ProcessManager* pm =
256 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 256 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
257 extensions::ExtensionHost* host = 257 extensions::ExtensionHost* host =
258 pm->GetBackgroundHostForExtension(last_loaded_extension_id()); 258 pm->GetBackgroundHostForExtension(last_loaded_extension_id());
259 ASSERT_TRUE(host); 259 ASSERT_TRUE(host);
260 260
261 // Abort the request. 261 // Abort the request.
262 bool result = false; 262 bool result = false;
263 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 263 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
264 host->render_view_host(), "abortRequest()", &result)); 264 host->render_view_host(), "abortRequest()", &result));
265 EXPECT_TRUE(result); 265 EXPECT_TRUE(result);
(...skipping 20 matching lines...) Expand all
286 ASSERT_TRUE(extension); 286 ASSERT_TRUE(extension);
287 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 287 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
288 288
289 // The extension should've opened a new tab to an extension page. 289 // The extension should've opened a new tab to an extension page.
290 EXPECT_TRUE(chrome::IsNTPURL( 290 EXPECT_TRUE(chrome::IsNTPURL(
291 browser()->tab_strip_model()->GetActiveWebContents()->GetURL(), 291 browser()->tab_strip_model()->GetActiveWebContents()->GetURL(),
292 browser()->profile())); 292 browser()->profile()));
293 293
294 // Lazy Background Page still exists, because the extension created a new tab 294 // Lazy Background Page still exists, because the extension created a new tab
295 // to an extension page. 295 // to an extension page.
296 ExtensionProcessManager* pm = 296 extensions::ProcessManager* pm =
297 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 297 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
298 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 298 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
299 299
300 // Navigate away from the NTP, which should close the event page. 300 // Navigate away from the NTP, which should close the event page.
301 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 301 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
302 lazybg.Wait(); 302 lazybg.Wait();
303 303
304 // Lazy Background Page has been shut down. 304 // Lazy Background Page has been shut down.
305 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 305 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
306 } 306 }
(...skipping 15 matching lines...) Expand all
322 // Load the extension with incognito enabled. 322 // Load the extension with incognito enabled.
323 { 323 {
324 LoadedIncognitoObserver loaded(browser()->profile()); 324 LoadedIncognitoObserver loaded(browser()->profile());
325 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). 325 base::FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page").
326 AppendASCII("incognito_split"); 326 AppendASCII("incognito_split");
327 ASSERT_TRUE(LoadExtensionIncognito(extdir)); 327 ASSERT_TRUE(LoadExtensionIncognito(extdir));
328 loaded.Wait(); 328 loaded.Wait();
329 } 329 }
330 330
331 // Lazy Background Page doesn't exist yet. 331 // Lazy Background Page doesn't exist yet.
332 ExtensionProcessManager* pm = 332 extensions::ProcessManager* pm =
333 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 333 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
334 ExtensionProcessManager* pmi = 334 extensions::ProcessManager* pmi =
335 extensions::ExtensionSystem::Get(incognito_browser->profile())-> 335 extensions::ExtensionSystem::Get(incognito_browser->profile())->
336 process_manager(); 336 process_manager();
337 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 337 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
338 EXPECT_FALSE(pmi->GetBackgroundHostForExtension(last_loaded_extension_id())); 338 EXPECT_FALSE(pmi->GetBackgroundHostForExtension(last_loaded_extension_id()));
339 339
340 // Trigger a browserAction event in the original profile and ensure only 340 // Trigger a browserAction event in the original profile and ensure only
341 // the original event page received it (since the event is scoped to the 341 // the original event page received it (since the event is scoped to the
342 // profile). 342 // profile).
343 { 343 {
344 ExtensionTestMessageListener listener("waiting", false); 344 ExtensionTestMessageListener listener("waiting", false);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 } 382 }
383 383
384 // Tests that messages from the content script activate the lazy background 384 // Tests that messages from the content script activate the lazy background
385 // page, and keep it alive until all channels are closed. 385 // page, and keep it alive until all channels are closed.
386 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Messaging) { 386 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Messaging) {
387 ASSERT_TRUE(StartEmbeddedTestServer()); 387 ASSERT_TRUE(StartEmbeddedTestServer());
388 ASSERT_TRUE(LoadExtensionAndWait("messaging")); 388 ASSERT_TRUE(LoadExtensionAndWait("messaging"));
389 389
390 // Lazy Background Page doesn't exist yet. 390 // Lazy Background Page doesn't exist yet.
391 ExtensionProcessManager* pm = 391 extensions::ProcessManager* pm =
392 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 392 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
393 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 393 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
394 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 394 EXPECT_EQ(1, browser()->tab_strip_model()->count());
395 395
396 // Navigate to a page that opens a message channel to the background page. 396 // Navigate to a page that opens a message channel to the background page.
397 ResultCatcher catcher; 397 ResultCatcher catcher;
398 LazyBackgroundObserver lazybg; 398 LazyBackgroundObserver lazybg;
399 ui_test_utils::NavigateToURL( 399 ui_test_utils::NavigateToURL(
400 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); 400 browser(), embedded_test_server()->GetURL("/extensions/test_file.html"));
401 lazybg.WaitUntilLoaded(); 401 lazybg.WaitUntilLoaded();
(...skipping 11 matching lines...) Expand all
413 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 413 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
414 } 414 }
415 415
416 // Tests that the lazy background page receives the unload event when we 416 // Tests that the lazy background page receives the unload event when we
417 // close it, and that it can execute simple API calls that don't require an 417 // close it, and that it can execute simple API calls that don't require an
418 // asynchronous response. 418 // asynchronous response.
419 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnUnload) { 419 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnUnload) {
420 ASSERT_TRUE(LoadExtensionAndWait("on_unload")); 420 ASSERT_TRUE(LoadExtensionAndWait("on_unload"));
421 421
422 // Lazy Background Page has been shut down. 422 // Lazy Background Page has been shut down.
423 ExtensionProcessManager* pm = 423 extensions::ProcessManager* pm =
424 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 424 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
425 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 425 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
426 426
427 // The browser action has a new title. 427 // The browser action has a new title.
428 BrowserActionTestUtil browser_action(browser()); 428 BrowserActionTestUtil browser_action(browser());
429 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); 429 ASSERT_EQ(1, browser_action.NumberOfBrowserActions());
430 EXPECT_EQ("Success", browser_action.GetTooltip(0)); 430 EXPECT_EQ("Success", browser_action.GetTooltip(0));
431 } 431 }
432 432
433 // Tests that both a regular page and an event page will receive events when 433 // Tests that both a regular page and an event page will receive events when
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 ASSERT_TRUE(extension); 476 ASSERT_TRUE(extension);
477 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 477 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
478 478
479 // The extension should've opened a new tab to an extension page. 479 // The extension should've opened a new tab to an extension page.
480 EXPECT_EQ(extension->GetResourceURL("extension_page.html").spec(), 480 EXPECT_EQ(extension->GetResourceURL("extension_page.html").spec(),
481 browser()->tab_strip_model()->GetActiveWebContents()-> 481 browser()->tab_strip_model()->GetActiveWebContents()->
482 GetURL().spec()); 482 GetURL().spec());
483 483
484 // Lazy Background Page still exists, because the extension created a new tab 484 // Lazy Background Page still exists, because the extension created a new tab
485 // to an extension page. 485 // to an extension page.
486 ExtensionProcessManager* pm = 486 extensions::ProcessManager* pm =
487 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 487 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
488 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 488 EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
489 489
490 // Close the new tab. 490 // Close the new tab.
491 LazyBackgroundObserver page_complete; 491 LazyBackgroundObserver page_complete;
492 browser()->tab_strip_model()->CloseWebContentsAt( 492 browser()->tab_strip_model()->CloseWebContentsAt(
493 browser()->tab_strip_model()->active_index(), TabStripModel::CLOSE_NONE); 493 browser()->tab_strip_model()->active_index(), TabStripModel::CLOSE_NONE);
494 page_complete.WaitUntilClosed(); 494 page_complete.WaitUntilClosed();
495 495
496 // Lazy Background Page has been shut down. 496 // Lazy Background Page has been shut down.
(...skipping 14 matching lines...) Expand all
511 511
512 // Tests that the lazy background page will be unloaded if the onSuspend event 512 // Tests that the lazy background page will be unloaded if the onSuspend event
513 // handler calls an API function such as chrome.storage.local.set(). 513 // handler calls an API function such as chrome.storage.local.set().
514 // See: http://crbug.com/296834 514 // See: http://crbug.com/296834
515 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { 515 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) {
516 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); 516 EXPECT_TRUE(LoadExtensionAndWait("on_suspend"));
517 } 517 }
518 518
519 // TODO: background page with timer. 519 // TODO: background page with timer.
520 // TODO: background page that interacts with popup. 520 // TODO: background page that interacts with popup.
OLDNEW
« no previous file with comments | « chrome/browser/extensions/gtalk_extension_browsertest.cc ('k') | chrome/browser/extensions/notifications_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698