diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 20:07:32 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 20:07:32 +0000 |
commit | 41619a9a170f58ba841613b30d405340e60e5b58 (patch) | |
tree | 0613568b613ae365180bc1a46537884ac4ae5f62 /chrome/browser/extensions/app_background_page_apitest.cc | |
parent | c08805c3c24fce0f61bf2838a219ae8651a0e375 (diff) | |
download | chromium_src-41619a9a170f58ba841613b30d405340e60e5b58.zip chromium_src-41619a9a170f58ba841613b30d405340e60e5b58.tar.gz chromium_src-41619a9a170f58ba841613b30d405340e60e5b58.tar.bz2 |
apps: Add 'background_page' support for hosted apps.
A hosted app can have a 'background_page' if it has 'background' 'permission'.
The 'background_page' will launch immediately after the app is installed.
BUG=77718
TEST=AppBackgroundPageApiTest.ManifestBackgroundPage, and existing tests.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=81438
Review URL: http://codereview.chromium.org/6708100
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81467 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/app_background_page_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/app_background_page_apitest.cc | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/chrome/browser/extensions/app_background_page_apitest.cc b/chrome/browser/extensions/app_background_page_apitest.cc index f1f98bf..b13dc77 100644 --- a/chrome/browser/extensions/app_background_page_apitest.cc +++ b/chrome/browser/extensions/app_background_page_apitest.cc @@ -1,10 +1,15 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/string_util.h" +#include "chrome/browser/background_contents_service.h" #include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/test/ui_test_utils.h" #include "net/base/mock_host_resolver.h" @@ -13,6 +18,7 @@ class AppBackgroundPageApiTest : public ExtensionApiTest { void SetUpCommandLine(CommandLine* command_line) { ExtensionApiTest::SetUpCommandLine(command_line); command_line->AppendSwitch(switches::kDisablePopupBlocking); + command_line->AppendSwitch(switches::kAllowHTTPBackgroundPage); } bool CreateApp(const std::string& app_manifest, @@ -90,3 +96,34 @@ IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_LacksPermission) { ASSERT_TRUE(RunExtensionTest("app_background_page/lacks_permission")) << message_; } + +IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) { + host_resolver()->AddRule("a.com", "127.0.0.1"); + ASSERT_TRUE(StartTestServer()); + + std::string app_manifest = StringPrintf( + "{" + " \"name\": \"App\"," + " \"version\": \"0.1\"," + " \"app\": {" + " \"urls\": [" + " \"http://a.com/\"" + " ]," + " \"launch\": {" + " \"web_url\": \"http://a.com:%d/\"" + " }" + " }," + " \"permissions\": [\"background\"]," + " \"background_page\": \"http://a.com:%d/test.html\"" + "}", + test_server()->host_port_pair().port(), + test_server()->host_port_pair().port()); + + FilePath app_dir; + ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); + ASSERT_TRUE(LoadExtension(app_dir)); + + const Extension* extension = GetSingleLoadedExtension(); + ASSERT_TRUE(browser()->profile()->GetBackgroundContentsService()-> + GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); +} |