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

Unified Diff: chrome/browser/extensions/lazy_background_page_apitest.cc

Issue 60613004: Add KeepaliveImpulse to extension process manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tapted comments addressed Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/lazy_background_page_apitest.cc
diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc
index e0873193fa3cc5a65df03b653f0156919acf52b8..9f355a40eb50f523516bf2c968cd1a48875538a4 100644
--- a/chrome/browser/extensions/lazy_background_page_apitest.cc
+++ b/chrome/browser/extensions/lazy_background_page_apitest.cc
@@ -81,9 +81,9 @@ class LazyBackgroundPageApiTest : public ExtensionApiTest {
ExtensionApiTest::SetUpCommandLine(command_line);
// Set shorter delays to prevent test timeouts.
command_line->AppendSwitchASCII(
- extensions::switches::kEventPageIdleTime, "1");
+ extensions::switches::kEventPageIdleTime, "1000");
command_line->AppendSwitchASCII(
- extensions::switches::kEventPageSuspendingTime, "1");
+ extensions::switches::kEventPageSuspendingTime, "1000");
}
// Loads the extension, which temporarily starts the lazy background page
@@ -411,6 +411,40 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Messaging) {
EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
}
+// Tests that a KeepaliveImpulse increments the keep alive count, but eventually
+// times out and background page will still close.
+IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, ImpulseAddsCount) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ const Extension* extension = LoadExtensionAndWait("messaging");
+ ASSERT_TRUE(extension);
+
+ // Lazy Background Page doesn't exist yet.
+ extensions::ProcessManager* pm =
+ extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
+ EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+
+ // Navigate to a page that opens a message channel to the background page.
+ ResultCatcher catcher;
+ LazyBackgroundObserver lazybg;
+ ui_test_utils::NavigateToURL(
+ browser(), embedded_test_server()->GetURL("/extensions/test_file.html"));
+ lazybg.WaitUntilLoaded();
+
+ // Add an impulse and the keep alive count increases.
+ int previous_keep_alive_count = pm->GetLazyKeepaliveCount(extension);
+ pm->KeepaliveImpulse(extension);
+ EXPECT_EQ(previous_keep_alive_count + 1,
+ pm->GetLazyKeepaliveCount(extension));
+
+ // Navigate away, closing the message channel and therefore the background
+ // page after the impulse times out.
+ ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
+ lazybg.WaitUntilClosed();
+
+ EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
+}
+
// Tests that the lazy background page receives the unload event when we
// close it, and that it can execute simple API calls that don't require an
// asynchronous response.

Powered by Google App Engine
This is Rietveld 408576698