summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/app_background_page_apitest.cc
diff options
context:
space:
mode:
authormihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-29 04:03:01 +0000
committermihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-29 04:03:01 +0000
commit03b6d5583ccccfdaba18d8ddca0c8e1d2da10959 (patch)
tree857ee21badbd1260937834fb35ba84254dbb10e5 /chrome/browser/extensions/app_background_page_apitest.cc
parent3d552e16b861cb4d37a020b924dda2f4fade036d (diff)
downloadchromium_src-03b6d5583ccccfdaba18d8ddca0c8e1d2da10959.zip
chromium_src-03b6d5583ccccfdaba18d8ddca0c8e1d2da10959.tar.gz
chromium_src-03b6d5583ccccfdaba18d8ddca0c8e1d2da10959.tar.bz2
Make it so that allow_js_access: false can be used with background pages created by window.open.
We want attempts to create those windows to succeed, but the window.open call should still return null. This is accomplished by opening the background contents in another process, in the same manner as r125180. BUG=120446 R=creis@chromium.org Review URL: http://codereview.chromium.org/9837074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129574 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.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/chrome/browser/extensions/app_background_page_apitest.cc b/chrome/browser/extensions/app_background_page_apitest.cc
index 32af291..5321306 100644
--- a/chrome/browser/extensions/app_background_page_apitest.cc
+++ b/chrome/browser/extensions/app_background_page_apitest.cc
@@ -143,6 +143,47 @@ IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) {
GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
}
+IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, NoJsBackgroundPage) {
+ host_resolver()->AddRule("a.com", "127.0.0.1");
+ ASSERT_TRUE(StartTestServer());
+
+ std::string app_manifest = base::StringPrintf(
+ "{"
+ " \"name\": \"App\","
+ " \"version\": \"0.1\","
+ " \"manifest_version\": 2,"
+ " \"app\": {"
+ " \"urls\": ["
+ " \"http://a.com/\""
+ " ],"
+ " \"launch\": {"
+ " \"web_url\": \"http://a.com:%d/test.html\""
+ " }"
+ " },"
+ " \"permissions\": [\"background\"],"
+ " \"background\": {"
+ " \"allow_js_access\": false"
+ " }"
+ "}",
+ test_server()->host_port_pair().port());
+
+ FilePath app_dir;
+ ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
+ ASSERT_TRUE(LoadExtension(app_dir));
+
+ // There isn't a background page loaded initially.
+ const Extension* extension = GetSingleLoadedExtension();
+ ASSERT_FALSE(
+ BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
+ GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
+ // The test makes sure that window.open returns null.
+ ASSERT_TRUE(RunExtensionTest("app_background_page/no_js")) << message_;
+ // And after it runs there should be a background page.
+ ASSERT_TRUE(
+ BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
+ GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
+}
+
IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, NoJsManifestBackgroundPage) {
host_resolver()->AddRule("a.com", "127.0.0.1");
ASSERT_TRUE(StartTestServer());
@@ -178,7 +219,8 @@ IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, NoJsManifestBackgroundPage) {
ASSERT_TRUE(
BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
- ASSERT_TRUE(RunExtensionTest("app_background_page/no_js")) << message_;
+ ASSERT_TRUE(RunExtensionTest("app_background_page/no_js_manifest")) <<
+ message_;
}
IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) {