Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / extensions / app_background_page_apitest.cc
blob3e51aa063824fc8a156d7aca0130a461c2df654d
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
3 // found in the LICENSE file.
5 #include "base/location.h"
6 #include "base/path_service.h"
7 #include "base/single_thread_task_runner.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/background/background_contents_service.h"
12 #include "chrome/browser/background/background_contents_service_factory.h"
13 #include "chrome/browser/background/background_mode_manager.h"
14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/extensions/extension_apitest.h"
16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_dialogs.h"
21 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/extensions/application_launch.h"
23 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h"
25 #include "content/public/browser/notification_service.h"
26 #include "content/public/test/test_notification_tracker.h"
27 #include "content/public/test/test_utils.h"
28 #include "extensions/browser/process_manager.h"
29 #include "extensions/common/extension.h"
30 #include "extensions/common/switches.h"
31 #include "extensions/test/extension_test_message_listener.h"
32 #include "net/dns/mock_host_resolver.h"
33 #include "net/test/embedded_test_server/embedded_test_server.h"
35 #if !defined(DISABLE_NACL)
36 #include "components/nacl/browser/nacl_process_host.h"
37 #endif
39 #if defined(OS_MACOSX)
40 #include "base/mac/scoped_nsautorelease_pool.h"
41 #endif
43 using base::ASCIIToUTF16;
44 using extensions::Extension;
46 class AppBackgroundPageApiTest : public ExtensionApiTest {
47 public:
48 void SetUpCommandLine(base::CommandLine* command_line) override {
49 ExtensionApiTest::SetUpCommandLine(command_line);
50 command_line->AppendSwitch(switches::kDisablePopupBlocking);
51 command_line->AppendSwitch(extensions::switches::kAllowHTTPBackgroundPage);
54 bool CreateApp(const std::string& app_manifest,
55 base::FilePath* app_dir) {
56 if (!app_dir_.CreateUniqueTempDir()) {
57 LOG(ERROR) << "Unable to create a temporary directory.";
58 return false;
60 base::FilePath manifest_path = app_dir_.path().AppendASCII("manifest.json");
61 int bytes_written = base::WriteFile(manifest_path,
62 app_manifest.data(),
63 app_manifest.size());
64 if (bytes_written != static_cast<int>(app_manifest.size())) {
65 LOG(ERROR) << "Unable to write complete manifest to file. Return code="
66 << bytes_written;
67 return false;
69 *app_dir = app_dir_.path();
70 return true;
73 bool WaitForBackgroundMode(bool expected_background_mode) {
74 #if defined(OS_CHROMEOS)
75 // BackgroundMode is not supported on chromeos, so we should test the
76 // behavior of BackgroundContents, but not the background mode state itself.
77 return true;
78 #else
79 BackgroundModeManager* manager =
80 g_browser_process->background_mode_manager();
81 // If background mode is disabled on this platform (e.g. cros), then skip
82 // this check.
83 if (!manager || !manager->IsBackgroundModePrefEnabled()) {
84 DLOG(WARNING) << "Skipping check - background mode disabled";
85 return true;
87 if (manager->IsBackgroundModeActive() == expected_background_mode)
88 return true;
90 // We are not currently in the expected state - wait for the state to
91 // change.
92 content::WindowedNotificationObserver watcher(
93 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED,
94 content::NotificationService::AllSources());
95 watcher.Wait();
96 return manager->IsBackgroundModeActive() == expected_background_mode;
97 #endif
100 void UnloadExtensionViaTask(const std::string& id) {
101 base::ThreadTaskRunnerHandle::Get()->PostTask(
102 FROM_HERE,
103 base::Bind(&AppBackgroundPageApiTest::UnloadExtension, this, id));
106 private:
107 base::ScopedTempDir app_dir_;
110 namespace {
112 // Fixture to assist in testing v2 app background pages containing
113 // Native Client embeds.
114 class AppBackgroundPageNaClTest : public AppBackgroundPageApiTest {
115 public:
116 AppBackgroundPageNaClTest()
117 : extension_(NULL) {}
118 ~AppBackgroundPageNaClTest() override {}
120 void SetUpOnMainThread() override {
121 AppBackgroundPageApiTest::SetUpOnMainThread();
122 #if !defined(DISABLE_NACL)
123 nacl::NaClProcessHost::SetPpapiKeepAliveThrottleForTesting(50);
124 #endif
125 extensions::ProcessManager::SetEventPageIdleTimeForTesting(1000);
126 extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1000);
129 const Extension* extension() { return extension_; }
131 protected:
132 void LaunchTestingApp() {
133 base::FilePath app_dir;
134 PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir);
135 app_dir = app_dir.AppendASCII(
136 "ppapi/tests/extensions/background_keepalive/newlib");
137 extension_ = LoadExtension(app_dir);
138 ASSERT_TRUE(extension_);
141 private:
142 const Extension* extension_;
145 // Produces an extensions::ProcessManager::ImpulseCallbackForTesting callback
146 // that will match a specified goal and can be waited on.
147 class ImpulseCallbackCounter {
148 public:
149 explicit ImpulseCallbackCounter(extensions::ProcessManager* manager,
150 const std::string& extension_id)
151 : observed_(0),
152 goal_(0),
153 manager_(manager),
154 extension_id_(extension_id) {
157 extensions::ProcessManager::ImpulseCallbackForTesting
158 SetGoalAndGetCallback(int goal) {
159 observed_ = 0;
160 goal_ = goal;
161 message_loop_runner_ = new content::MessageLoopRunner();
162 return base::Bind(&ImpulseCallbackCounter::ImpulseCallback,
163 base::Unretained(this),
164 message_loop_runner_->QuitClosure(),
165 extension_id_);
168 void Wait() {
169 message_loop_runner_->Run();
171 private:
172 void ImpulseCallback(
173 const base::Closure& quit_callback,
174 const std::string& extension_id_from_test,
175 const std::string& extension_id_from_manager) {
176 if (extension_id_from_test == extension_id_from_manager) {
177 if (++observed_ >= goal_) {
178 // Clear callback to free reference to message loop.
179 manager_->SetKeepaliveImpulseCallbackForTesting(
180 extensions::ProcessManager::ImpulseCallbackForTesting());
181 manager_->SetKeepaliveImpulseDecrementCallbackForTesting(
182 extensions::ProcessManager::ImpulseCallbackForTesting());
183 quit_callback.Run();
188 int observed_;
189 int goal_;
190 extensions::ProcessManager* manager_;
191 const std::string extension_id_;
192 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
195 } // namespace
197 // Disable on Mac only. http://crbug.com/95139
198 #if defined(OS_MACOSX)
199 #define MAYBE_Basic DISABLED_Basic
200 #else
201 #define MAYBE_Basic Basic
202 #endif
204 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, MAYBE_Basic) {
205 host_resolver()->AddRule("a.com", "127.0.0.1");
206 ASSERT_TRUE(StartEmbeddedTestServer());
208 std::string app_manifest = base::StringPrintf(
210 " \"name\": \"App\","
211 " \"version\": \"0.1\","
212 " \"manifest_version\": 2,"
213 " \"app\": {"
214 " \"urls\": ["
215 " \"http://a.com/\""
216 " ],"
217 " \"launch\": {"
218 " \"web_url\": \"http://a.com:%u/\""
219 " }"
220 " },"
221 " \"permissions\": [\"background\"]"
222 "}",
223 embedded_test_server()->port());
225 base::FilePath app_dir;
226 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
227 ASSERT_TRUE(LoadExtension(app_dir));
228 // Background mode should not be active until a background page is created.
229 ASSERT_TRUE(WaitForBackgroundMode(false));
230 ASSERT_TRUE(RunExtensionTest("app_background_page/basic")) << message_;
231 // The test closes the background contents, so we should fall back to no
232 // background mode at the end.
233 ASSERT_TRUE(WaitForBackgroundMode(false));
236 // Crashy, http://crbug.com/69215.
237 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_LacksPermission) {
238 host_resolver()->AddRule("a.com", "127.0.0.1");
239 ASSERT_TRUE(StartEmbeddedTestServer());
241 std::string app_manifest = base::StringPrintf(
243 " \"name\": \"App\","
244 " \"version\": \"0.1\","
245 " \"manifest_version\": 2,"
246 " \"app\": {"
247 " \"urls\": ["
248 " \"http://a.com/\""
249 " ],"
250 " \"launch\": {"
251 " \"web_url\": \"http://a.com:%u/\""
252 " }"
253 " }"
254 "}",
255 embedded_test_server()->port());
257 base::FilePath app_dir;
258 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
259 ASSERT_TRUE(LoadExtension(app_dir));
260 ASSERT_TRUE(RunExtensionTest("app_background_page/lacks_permission"))
261 << message_;
262 ASSERT_TRUE(WaitForBackgroundMode(false));
265 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) {
266 host_resolver()->AddRule("a.com", "127.0.0.1");
267 ASSERT_TRUE(StartEmbeddedTestServer());
269 std::string app_manifest = base::StringPrintf(
271 " \"name\": \"App\","
272 " \"version\": \"0.1\","
273 " \"manifest_version\": 2,"
274 " \"app\": {"
275 " \"urls\": ["
276 " \"http://a.com/\""
277 " ],"
278 " \"launch\": {"
279 " \"web_url\": \"http://a.com:%u/\""
280 " }"
281 " },"
282 " \"permissions\": [\"background\"],"
283 " \"background\": {"
284 " \"page\": \"http://a.com:%u/test.html\""
285 " }"
286 "}",
287 embedded_test_server()->port(),
288 embedded_test_server()->port());
290 base::FilePath app_dir;
291 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
292 // Background mode should not be active now because no background app was
293 // loaded.
294 ASSERT_TRUE(LoadExtension(app_dir));
295 // Background mode be active now because a background page was created when
296 // the app was loaded.
297 ASSERT_TRUE(WaitForBackgroundMode(true));
299 const Extension* extension = GetSingleLoadedExtension();
300 ASSERT_TRUE(
301 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
302 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
303 UnloadExtension(extension->id());
306 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, NoJsBackgroundPage) {
307 // Keep the task manager up through this test to verify that a crash doesn't
308 // happen when window.open creates a background page that switches
309 // RenderViewHosts. See http://crbug.com/165138.
310 // This test is for the old implementation of the task manager. We must
311 // explicitly disable the new one.
312 task_manager::browsertest_util::EnableOldTaskManager();
313 chrome::ShowTaskManager(browser());
315 // Make sure that no BackgroundContentses get deleted (a signal that repeated
316 // window.open calls recreate instances, instead of being no-ops).
317 content::TestNotificationTracker background_deleted_tracker;
318 background_deleted_tracker.ListenFor(
319 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
320 content::Source<Profile>(browser()->profile()));
322 host_resolver()->AddRule("a.com", "127.0.0.1");
323 ASSERT_TRUE(StartEmbeddedTestServer());
325 std::string app_manifest = base::StringPrintf(
327 " \"name\": \"App\","
328 " \"version\": \"0.1\","
329 " \"manifest_version\": 2,"
330 " \"app\": {"
331 " \"urls\": ["
332 " \"http://a.com/\""
333 " ],"
334 " \"launch\": {"
335 " \"web_url\": \"http://a.com:%u/test.html\""
336 " }"
337 " },"
338 " \"permissions\": [\"background\"],"
339 " \"background\": {"
340 " \"allow_js_access\": false"
341 " }"
342 "}",
343 embedded_test_server()->port());
345 base::FilePath app_dir;
346 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
347 ASSERT_TRUE(LoadExtension(app_dir));
349 // There isn't a background page loaded initially.
350 const Extension* extension = GetSingleLoadedExtension();
351 ASSERT_FALSE(
352 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
353 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
354 // The test makes sure that window.open returns null.
355 ASSERT_TRUE(RunExtensionTest("app_background_page/no_js")) << message_;
356 // And after it runs there should be a background page.
357 ASSERT_TRUE(
358 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
359 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
361 EXPECT_EQ(0u, background_deleted_tracker.size());
362 UnloadExtension(extension->id());
365 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, NoJsManifestBackgroundPage) {
366 host_resolver()->AddRule("a.com", "127.0.0.1");
367 ASSERT_TRUE(StartEmbeddedTestServer());
369 std::string app_manifest = base::StringPrintf(
371 " \"name\": \"App\","
372 " \"version\": \"0.1\","
373 " \"manifest_version\": 2,"
374 " \"app\": {"
375 " \"urls\": ["
376 " \"http://a.com/\""
377 " ],"
378 " \"launch\": {"
379 " \"web_url\": \"http://a.com:%u/\""
380 " }"
381 " },"
382 " \"permissions\": [\"background\"],"
383 " \"background\": {"
384 " \"page\": \"http://a.com:%u/bg.html\","
385 " \"allow_js_access\": false"
386 " }"
387 "}",
388 embedded_test_server()->port(),
389 embedded_test_server()->port());
391 base::FilePath app_dir;
392 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
393 ASSERT_TRUE(LoadExtension(app_dir));
395 // The background page should load, but window.open should return null.
396 const Extension* extension = GetSingleLoadedExtension();
397 ASSERT_TRUE(
398 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
399 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
400 ASSERT_TRUE(RunExtensionTest("app_background_page/no_js_manifest")) <<
401 message_;
402 UnloadExtension(extension->id());
405 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) {
406 host_resolver()->AddRule("a.com", "127.0.0.1");
407 ASSERT_TRUE(StartEmbeddedTestServer());
409 std::string app_manifest = base::StringPrintf(
411 " \"name\": \"App\","
412 " \"version\": \"0.1\","
413 " \"manifest_version\": 2,"
414 " \"app\": {"
415 " \"urls\": ["
416 " \"http://a.com/\""
417 " ],"
418 " \"launch\": {"
419 " \"web_url\": \"http://a.com:%u/\""
420 " }"
421 " },"
422 " \"permissions\": [\"background\"]"
423 "}",
424 embedded_test_server()->port());
426 base::FilePath app_dir;
427 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
428 ASSERT_TRUE(LoadExtension(app_dir));
429 const Extension* extension = GetSingleLoadedExtension();
430 ASSERT_TRUE(RunExtensionTest("app_background_page/two_pages")) << message_;
431 UnloadExtension(extension->id());
434 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoPagesWithManifest) {
435 host_resolver()->AddRule("a.com", "127.0.0.1");
436 ASSERT_TRUE(StartEmbeddedTestServer());
438 std::string app_manifest = base::StringPrintf(
440 " \"name\": \"App\","
441 " \"version\": \"0.1\","
442 " \"manifest_version\": 2,"
443 " \"app\": {"
444 " \"urls\": ["
445 " \"http://a.com/\""
446 " ],"
447 " \"launch\": {"
448 " \"web_url\": \"http://a.com:%u/\""
449 " }"
450 " },"
451 " \"background\": {"
452 " \"page\": \"http://a.com:%u/bg.html\""
453 " },"
454 " \"permissions\": [\"background\"]"
455 "}",
456 embedded_test_server()->port(),
457 embedded_test_server()->port());
459 base::FilePath app_dir;
460 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
461 ASSERT_TRUE(LoadExtension(app_dir));
462 const Extension* extension = GetSingleLoadedExtension();
463 ASSERT_TRUE(RunExtensionTest("app_background_page/two_with_manifest")) <<
464 message_;
465 UnloadExtension(extension->id());
468 // Times out occasionally -- see crbug.com/108493
469 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_OpenPopupFromBGPage) {
470 host_resolver()->AddRule("a.com", "127.0.0.1");
471 ASSERT_TRUE(StartEmbeddedTestServer());
473 std::string app_manifest = base::StringPrintf(
475 " \"name\": \"App\","
476 " \"version\": \"0.1\","
477 " \"manifest_version\": 2,"
478 " \"app\": {"
479 " \"urls\": ["
480 " \"http://a.com/\""
481 " ],"
482 " \"launch\": {"
483 " \"web_url\": \"http://a.com:%u/\""
484 " }"
485 " },"
486 " \"background\": { \"page\": \"http://a.com:%u/extensions/api_test/"
487 "app_background_page/bg_open/bg_open_bg.html\" },"
488 " \"permissions\": [\"background\"]"
489 "}",
490 embedded_test_server()->port(),
491 embedded_test_server()->port());
493 base::FilePath app_dir;
494 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
495 ASSERT_TRUE(LoadExtension(app_dir));
496 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_;
499 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_OpenThenClose) {
500 host_resolver()->AddRule("a.com", "127.0.0.1");
501 ASSERT_TRUE(StartEmbeddedTestServer());
503 std::string app_manifest = base::StringPrintf(
505 " \"name\": \"App\","
506 " \"version\": \"0.1\","
507 " \"manifest_version\": 2,"
508 " \"app\": {"
509 " \"urls\": ["
510 " \"http://a.com/\""
511 " ],"
512 " \"launch\": {"
513 " \"web_url\": \"http://a.com:%u/\""
514 " }"
515 " },"
516 " \"permissions\": [\"background\"]"
517 "}",
518 embedded_test_server()->port());
520 base::FilePath app_dir;
521 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
522 ASSERT_TRUE(LoadExtension(app_dir));
523 // There isn't a background page loaded initially.
524 const Extension* extension = GetSingleLoadedExtension();
525 ASSERT_FALSE(
526 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
527 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
528 // Background mode should not be active until a background page is created.
529 ASSERT_TRUE(WaitForBackgroundMode(false));
530 ASSERT_TRUE(RunExtensionTest("app_background_page/basic_open")) << message_;
531 // Background mode should be active now because a background page was created.
532 ASSERT_TRUE(WaitForBackgroundMode(true));
533 ASSERT_TRUE(
534 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
535 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
536 // Now close the BackgroundContents.
537 ASSERT_TRUE(RunExtensionTest("app_background_page/basic_close")) << message_;
538 // Background mode should no longer be active.
539 ASSERT_TRUE(WaitForBackgroundMode(false));
540 ASSERT_FALSE(
541 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
542 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
545 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, UnloadExtensionWhileHidden) {
546 host_resolver()->AddRule("a.com", "127.0.0.1");
547 ASSERT_TRUE(StartEmbeddedTestServer());
549 std::string app_manifest = base::StringPrintf(
551 " \"name\": \"App\","
552 " \"version\": \"0.1\","
553 " \"manifest_version\": 2,"
554 " \"app\": {"
555 " \"urls\": ["
556 " \"http://a.com/\""
557 " ],"
558 " \"launch\": {"
559 " \"web_url\": \"http://a.com:%u/\""
560 " }"
561 " },"
562 " \"permissions\": [\"background\"],"
563 " \"background\": {"
564 " \"page\": \"http://a.com:%u/test.html\""
565 " }"
566 "}",
567 embedded_test_server()->port(),
568 embedded_test_server()->port());
570 base::FilePath app_dir;
571 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
572 // Background mode should not be active now because no background app was
573 // loaded.
574 ASSERT_TRUE(LoadExtension(app_dir));
575 // Background mode be active now because a background page was created when
576 // the app was loaded.
577 ASSERT_TRUE(WaitForBackgroundMode(true));
579 const Extension* extension = GetSingleLoadedExtension();
580 ASSERT_TRUE(
581 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
582 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
584 // Close all browsers - app should continue running.
585 set_exit_when_last_browser_closes(false);
586 CloseBrowserSynchronously(browser());
588 // Post a task to unload the extension - this should cause Chrome to exit
589 // cleanly (not crash).
590 UnloadExtensionViaTask(extension->id());
591 content::RunAllPendingInMessageLoop();
592 ASSERT_TRUE(WaitForBackgroundMode(false));
595 // Verify active NaCl embeds cause many keepalive impulses to be sent.
596 // Disabled on Windows due to flakiness: http://crbug.com/346278
597 #if defined(OS_WIN)
598 #define MAYBE_BackgroundKeepaliveActive DISABLED_BackgroundKeepaliveActive
599 #else
600 // Disabling other platforms too since the test started failing
601 // consistently. http://crbug.com/490440
602 #define MAYBE_BackgroundKeepaliveActive DISABLED_BackgroundKeepaliveActive
603 #endif
604 IN_PROC_BROWSER_TEST_F(AppBackgroundPageNaClTest,
605 MAYBE_BackgroundKeepaliveActive) {
606 #if !defined(DISABLE_NACL)
607 ExtensionTestMessageListener nacl_modules_loaded("nacl_modules_loaded", true);
608 LaunchTestingApp();
609 extensions::ProcessManager* manager =
610 extensions::ProcessManager::Get(browser()->profile());
611 ImpulseCallbackCounter active_impulse_counter(manager, extension()->id());
612 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied());
614 // Target .5 seconds: .5 seconds / 50ms throttle * 2 embeds == 20 impulses.
615 manager->SetKeepaliveImpulseCallbackForTesting(
616 active_impulse_counter.SetGoalAndGetCallback(20));
617 active_impulse_counter.Wait();
618 #endif
621 // Verify that nacl modules that go idle will not send keepalive impulses.
622 // Disabled on windows due to Win XP failures:
623 // DesktopWindowTreeHostWin::HandleCreate not implemented. crbug.com/331954
624 #if defined(OS_WIN)
625 #define MAYBE_BackgroundKeepaliveIdle DISABLED_BackgroundKeepaliveIdle
626 #else
627 // ASAN errors appearing: https://crbug.com/332440
628 #define MAYBE_BackgroundKeepaliveIdle DISABLED_BackgroundKeepaliveIdle
629 #endif
630 IN_PROC_BROWSER_TEST_F(AppBackgroundPageNaClTest,
631 MAYBE_BackgroundKeepaliveIdle) {
632 #if !defined(DISABLE_NACL)
633 ExtensionTestMessageListener nacl_modules_loaded("nacl_modules_loaded", true);
634 LaunchTestingApp();
635 extensions::ProcessManager* manager =
636 extensions::ProcessManager::Get(browser()->profile());
637 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id());
638 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied());
640 manager->SetKeepaliveImpulseDecrementCallbackForTesting(
641 idle_impulse_counter.SetGoalAndGetCallback(1));
642 nacl_modules_loaded.Reply("be idle");
643 idle_impulse_counter.Wait();
644 #endif