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

Side by Side Diff: chrome/browser/extensions/app_background_page_apitest.cc

Issue 9508008: Allow apps with background pages to request process-per-app-instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prevent script access to background page. Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/background/background_contents_service.h" 7 #include "chrome/browser/background/background_contents_service.h"
8 #include "chrome/browser/background/background_contents_service_factory.h" 8 #include "chrome/browser/background/background_contents_service_factory.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 FilePath app_dir; 136 FilePath app_dir;
137 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 137 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
138 ASSERT_TRUE(LoadExtension(app_dir)); 138 ASSERT_TRUE(LoadExtension(app_dir));
139 139
140 const Extension* extension = GetSingleLoadedExtension(); 140 const Extension* extension = GetSingleLoadedExtension();
141 ASSERT_TRUE( 141 ASSERT_TRUE(
142 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())-> 142 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
143 GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); 143 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
144 } 144 }
145 145
146 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, NoJsManifestBackgroundPage) {
147 host_resolver()->AddRule("a.com", "127.0.0.1");
148 ASSERT_TRUE(StartTestServer());
149
150 std::string app_manifest = base::StringPrintf(
151 "{"
152 " \"name\": \"App\","
153 " \"version\": \"0.1\","
154 " \"manifest_version\": 2,"
155 " \"app\": {"
156 " \"urls\": ["
157 " \"http://a.com/\""
158 " ],"
159 " \"launch\": {"
160 " \"web_url\": \"http://a.com:%d/\""
161 " }"
162 " },"
163 " \"permissions\": [\"background\"],"
164 " \"background\": {"
165 " \"page\": \"http://a.com:%d/test.html\","
166 " \"allow_js_access\": false"
167 " }"
168 "}",
169 test_server()->host_port_pair().port(),
170 test_server()->host_port_pair().port());
171
172 FilePath app_dir;
173 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
174 ASSERT_TRUE(LoadExtension(app_dir));
175
176 // The background page should load, but window.open should return null.
177 const Extension* extension = GetSingleLoadedExtension();
178 ASSERT_TRUE(
179 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
180 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
181 // TODO(creis): Add this test directory.
182 ASSERT_TRUE(RunExtensionTest("app_background_page/no_js")) << message_;
Charlie Reis 2012/03/01 00:38:22 I spent most of the afternoon trying to understand
Charlie Reis 2012/03/01 02:45:22 Thanks for the explanation, Drew! It would have t
183 }
184
146 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) { 185 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) {
147 host_resolver()->AddRule("a.com", "127.0.0.1"); 186 host_resolver()->AddRule("a.com", "127.0.0.1");
148 ASSERT_TRUE(StartTestServer()); 187 ASSERT_TRUE(StartTestServer());
149 188
150 std::string app_manifest = base::StringPrintf( 189 std::string app_manifest = base::StringPrintf(
151 "{" 190 "{"
152 " \"name\": \"App\"," 191 " \"name\": \"App\","
153 " \"version\": \"0.1\"," 192 " \"version\": \"0.1\","
154 " \"manifest_version\": 2," 193 " \"manifest_version\": 2,"
155 " \"app\": {" 194 " \"app\": {"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 " \"permissions\": [\"background\"]" 264 " \"permissions\": [\"background\"]"
226 "}", 265 "}",
227 test_server()->host_port_pair().port(), 266 test_server()->host_port_pair().port(),
228 test_server()->host_port_pair().port()); 267 test_server()->host_port_pair().port());
229 268
230 FilePath app_dir; 269 FilePath app_dir;
231 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 270 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
232 ASSERT_TRUE(LoadExtension(app_dir)); 271 ASSERT_TRUE(LoadExtension(app_dir));
233 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_; 272 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_;
234 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698