OLD | NEW |
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 Loading... |
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/bg.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 ASSERT_TRUE(RunExtensionTest("app_background_page/no_js")) << message_; |
| 182 } |
| 183 |
146 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) { | 184 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) { |
147 host_resolver()->AddRule("a.com", "127.0.0.1"); | 185 host_resolver()->AddRule("a.com", "127.0.0.1"); |
148 ASSERT_TRUE(StartTestServer()); | 186 ASSERT_TRUE(StartTestServer()); |
149 | 187 |
150 std::string app_manifest = base::StringPrintf( | 188 std::string app_manifest = base::StringPrintf( |
151 "{" | 189 "{" |
152 " \"name\": \"App\"," | 190 " \"name\": \"App\"," |
153 " \"version\": \"0.1\"," | 191 " \"version\": \"0.1\"," |
154 " \"manifest_version\": 2," | 192 " \"manifest_version\": 2," |
155 " \"app\": {" | 193 " \"app\": {" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 " \"permissions\": [\"background\"]" | 263 " \"permissions\": [\"background\"]" |
226 "}", | 264 "}", |
227 test_server()->host_port_pair().port(), | 265 test_server()->host_port_pair().port(), |
228 test_server()->host_port_pair().port()); | 266 test_server()->host_port_pair().port()); |
229 | 267 |
230 FilePath app_dir; | 268 FilePath app_dir; |
231 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); | 269 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); |
232 ASSERT_TRUE(LoadExtension(app_dir)); | 270 ASSERT_TRUE(LoadExtension(app_dir)); |
233 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_; | 271 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_; |
234 } | 272 } |
OLD | NEW |