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

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

Issue 8116015: Now closes existing background contents if app opens a new one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed presubmit error (added license header to js file) Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 " \"permissions\": [\"background\"]" 72 " \"permissions\": [\"background\"]"
73 "}", 73 "}",
74 test_server()->host_port_pair().port()); 74 test_server()->host_port_pair().port());
75 75
76 FilePath app_dir; 76 FilePath app_dir;
77 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 77 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
78 ASSERT_TRUE(LoadExtension(app_dir)); 78 ASSERT_TRUE(LoadExtension(app_dir));
79 ASSERT_TRUE(RunExtensionTest("app_background_page/basic")) << message_; 79 ASSERT_TRUE(RunExtensionTest("app_background_page/basic")) << message_;
80 } 80 }
81 81
82 // Crashy, http://crbug.com/49215. 82 // Crashy, http://crbug.com/69215.
83 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_LacksPermission) { 83 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_LacksPermission) {
84 host_resolver()->AddRule("a.com", "127.0.0.1"); 84 host_resolver()->AddRule("a.com", "127.0.0.1");
85 ASSERT_TRUE(StartTestServer()); 85 ASSERT_TRUE(StartTestServer());
86 86
87 std::string app_manifest = base::StringPrintf( 87 std::string app_manifest = base::StringPrintf(
88 "{" 88 "{"
89 " \"name\": \"App\"," 89 " \"name\": \"App\","
90 " \"version\": \"0.1\"," 90 " \"version\": \"0.1\","
91 " \"app\": {" 91 " \"app\": {"
92 " \"urls\": [" 92 " \"urls\": ["
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 FilePath app_dir; 131 FilePath app_dir;
132 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 132 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
133 ASSERT_TRUE(LoadExtension(app_dir)); 133 ASSERT_TRUE(LoadExtension(app_dir));
134 134
135 const Extension* extension = GetSingleLoadedExtension(); 135 const Extension* extension = GetSingleLoadedExtension();
136 ASSERT_TRUE( 136 ASSERT_TRUE(
137 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())-> 137 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())->
138 GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); 138 GetAppBackgroundContents(ASCIIToUTF16(extension->id())));
139 } 139 }
140
141 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) {
142 host_resolver()->AddRule("a.com", "127.0.0.1");
143 ASSERT_TRUE(StartTestServer());
144
145 std::string app_manifest = base::StringPrintf(
146 "{"
147 " \"name\": \"App\","
148 " \"version\": \"0.1\","
149 " \"app\": {"
150 " \"urls\": ["
151 " \"http://a.com/\""
152 " ],"
153 " \"launch\": {"
154 " \"web_url\": \"http://a.com:%d/\""
155 " }"
156 " },"
157 " \"permissions\": [\"background\"]"
158 "}",
159 test_server()->host_port_pair().port());
160
161 FilePath app_dir;
162 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
163 ASSERT_TRUE(LoadExtension(app_dir));
164 ASSERT_TRUE(RunExtensionTest("app_background_page/two_pages")) << message_;
165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698