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

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

Issue 1117023002: Keep event page alive when there's some Pepper plugin on it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | content/common/view_messages.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f87c7a8e53229b3824d3c1259441f193bd9a5b05..73c1dc34d93b1b023989c52d0b266e88d992b078 100644
--- a/chrome/browser/extensions/lazy_background_page_apitest.cc
+++ b/chrome/browser/extensions/lazy_background_page_apitest.cc
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/path_service.h"
#include "base/scoped_observer.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
@@ -14,6 +16,8 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/app_modal/app_modal_dialog.h"
@@ -22,6 +26,7 @@
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
@@ -92,6 +97,14 @@ class LazyBackgroundPageApiTest : public ExtensionApiTest {
extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1);
}
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ // Disable background network activity as it can suddenly bring the Lazy
+ // Background Page alive.
+ command_line->AppendSwitch(switches::kDisableBackgroundNetworking);
+ command_line->AppendSwitch(switches::kNoProxyServer);
+ }
+
// Loads the extension, which temporarily starts the lazy background page
// to dispatch the onInstalled event. We wait until it shuts down again.
const Extension* LoadExtensionAndWait(const std::string& test_name) {
@@ -298,6 +311,42 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) {
EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
}
+// Tests that the lazy background page stays alive while a NaCl module exists in
+// its DOM.
+IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, NaCl) {
+#if !defined(DISABLE_NACL)
not at google - send to devlin 2015/05/11 17:53:48 Is it better to ifdef out the entire test? That wa
emaxx 2015/05/18 15:06:29 Done.
+ {
+ base::FilePath extdir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &extdir));
bartfab (slow) 2015/05/18 09:57:41 Nit: #include "testing/gtest/include/gtest/gtest.h
emaxx 2015/05/18 15:06:29 Done.
+ extdir = extdir.AppendASCII("ppapi/tests/extensions/load_unload/newlib");
+ LazyBackgroundObserver page_complete;
+ ASSERT_TRUE(LoadExtension(base::FilePath(extdir)));
bartfab (slow) 2015/05/18 09:57:41 Why do you cast |extdir| to |base::FilePath| once
emaxx 2015/05/18 15:06:29 Done (it was left from some old version).
+ page_complete.Wait();
+ }
+
+ // The NaCl module is loaded, and the Lazy Background Page stays alive.
+ {
+ ExtensionTestMessageListener nacl_module_loaded("nacl_module_loaded",
+ false);
+ BrowserActionTestUtil(browser()).Press(0);
+ nacl_module_loaded.WaitUntilSatisfied();
+ content::RunAllBlockingPoolTasksUntilIdle();
not at google - send to devlin 2015/05/11 17:53:48 It's a pity, we're basically forcing this test to
bartfab (slow) 2015/05/18 09:57:41 I would be worried not just about early returns bu
emaxx 2015/05/18 15:06:29 Actually the test class LazyBackgroundPageApiTest
emaxx 2015/05/18 15:06:29 Done (see the answer above).
+ EXPECT_TRUE(IsBackgroundPageAlive(last_loaded_extension_id()));
+ }
+
+ // The NaCl module is detached from DOM, and the Lazy Background Page shuts
+ // down.
+ {
+ LazyBackgroundObserver page_complete;
+ BrowserActionTestUtil(browser()).Press(0);
+ page_complete.WaitUntilClosed();
+ }
+
+ // The Lazy Background Page has been shut down.
+ EXPECT_FALSE(IsBackgroundPageAlive(last_loaded_extension_id()));
+#endif
+}
+
// Tests that the lazy background page stays alive until all visible views are
// closed.
// http://crbug.com/175778; test fails frequently on OS X
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | content/common/view_messages.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698