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

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

Issue 1414783002: Don't keep the lazy background page alive after a view with a Pepper plugin is closed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/path_service.h" 7 #include "base/path_service.h"
8 #include "base/scoped_observer.h" 8 #include "base/scoped_observer.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 EXPECT_TRUE(result); 303 EXPECT_TRUE(result);
304 page_complete.Wait(); 304 page_complete.Wait();
305 305
306 // Lazy Background Page has been shut down. 306 // Lazy Background Page has been shut down.
307 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 307 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
308 } 308 }
309 309
310 // Tests that the lazy background page stays alive while a NaCl module exists in 310 // Tests that the lazy background page stays alive while a NaCl module exists in
311 // its DOM. 311 // its DOM.
312 #if !defined(DISABLE_NACL) && !defined(DISABLE_NACL_BROWSERTESTS) 312 #if !defined(DISABLE_NACL) && !defined(DISABLE_NACL_BROWSERTESTS)
313 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaCl) { 313
314 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaClInBackgroundPage) {
314 { 315 {
315 base::FilePath extdir; 316 base::FilePath extdir;
316 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir)); 317 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir));
317 extdir = extdir.AppendASCII("ppapi/tests/extensions/load_unload/newlib"); 318 extdir = extdir.AppendASCII("ppapi/tests/extensions/load_unload/newlib");
318 LazyBackgroundObserver page_complete; 319 LazyBackgroundObserver page_complete;
319 ASSERT_TRUE(LoadExtension(extdir)); 320 ASSERT_TRUE(LoadExtension(extdir));
320 page_complete.Wait(); 321 page_complete.Wait();
321 } 322 }
322 323
323 // The NaCl module is loaded, and the Lazy Background Page stays alive. 324 // The NaCl module is loaded, and the Lazy Background Page stays alive.
(...skipping 10 matching lines...) Expand all
334 // down. 335 // down.
335 { 336 {
336 LazyBackgroundObserver page_complete; 337 LazyBackgroundObserver page_complete;
337 BrowserActionTestUtil(browser()).Press(0); 338 BrowserActionTestUtil(browser()).Press(0);
338 page_complete.WaitUntilClosed(); 339 page_complete.WaitUntilClosed();
339 } 340 }
340 341
341 // The Lazy Background Page has been shut down. 342 // The Lazy Background Page has been shut down.
342 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id())); 343 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id()));
343 } 344 }
345
346 // Tests that the lazy background page shuts down when all visible views with
347 // NaCl modules are closed.
348 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaClInView) {
349 // The extension is loaded and should've opened a new tab to an extension
350 // page, and the Lazy Background Page stays alive.
351 {
352 base::FilePath extdir;
353 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir));
354 extdir = extdir.AppendASCII("ppapi/tests/extensions/popup/newlib");
355 ResultCatcher catcher;
356 const Extension* extension = LoadExtension(extdir);
357 ASSERT_TRUE(extension);
358 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
359 EXPECT_EQ(
360 extension->GetResourceURL("popup.html").spec(),
361 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec());
362 EXPECT_TRUE(IsBackgroundPageAlive(last_loaded_extension_id()));
363 }
364
365 // Close the new tab.
366 {
367 LazyBackgroundObserver page_complete;
368 browser()->tab_strip_model()->CloseWebContentsAt(
369 browser()->tab_strip_model()->active_index(),
370 TabStripModel::CLOSE_NONE);
371 page_complete.WaitUntilClosed();
372 }
373
374 // The Lazy Background Page has been shut down.
375 EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id()));
376 }
344 #endif 377 #endif
345 378
346 // Tests that the lazy background page stays alive until all visible views are 379 // Tests that the lazy background page stays alive until all visible views are
347 // closed. 380 // closed.
348 // http://crbug.com/175778; test fails frequently on OS X 381 // http://crbug.com/175778; test fails frequently on OS X
349 #if defined(OS_MACOSX) 382 #if defined(OS_MACOSX)
350 #define MAYBE_WaitForNTP DISABLED_WaitForNTP 383 #define MAYBE_WaitForNTP DISABLED_WaitForNTP
351 #else 384 #else
352 #define MAYBE_WaitForNTP WaitForNTP 385 #define MAYBE_WaitForNTP WaitForNTP
353 #endif 386 #endif
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 // handler calls an API function such as chrome.storage.local.set(). 649 // handler calls an API function such as chrome.storage.local.set().
617 // See: http://crbug.com/296834 650 // See: http://crbug.com/296834
618 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) { 651 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnSuspendUseStorageApi) {
619 EXPECT_TRUE(LoadExtensionAndWait("on_suspend")); 652 EXPECT_TRUE(LoadExtensionAndWait("on_suspend"));
620 } 653 }
621 654
622 // TODO: background page with timer. 655 // TODO: background page with timer.
623 // TODO: background page that interacts with popup. 656 // TODO: background page that interacts with popup.
624 657
625 } // namespace extensions 658 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698