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

Side by Side Diff: chrome/browser/site_details_browsertest.cc

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/site_details.h" 5 #include "chrome/browser/site_details.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Create and install an extension that has a couple of web-accessible 184 // Create and install an extension that has a couple of web-accessible
185 // resources and, optionally, a background process. 185 // resources and, optionally, a background process.
186 const Extension* CreateExtension(const std::string& name, 186 const Extension* CreateExtension(const std::string& name,
187 bool has_background_process) { 187 bool has_background_process) {
188 scoped_ptr<TestExtensionDir> dir(new TestExtensionDir); 188 scoped_ptr<TestExtensionDir> dir(new TestExtensionDir);
189 189
190 DictionaryBuilder manifest; 190 DictionaryBuilder manifest;
191 manifest.Set("name", name) 191 manifest.Set("name", name)
192 .Set("version", "1.0") 192 .Set("version", "1.0")
193 .Set("manifest_version", 2) 193 .Set("manifest_version", 2)
194 .Set("web_accessible_resources", 194 .Set("web_accessible_resources", ListBuilder()
195 std::move(ListBuilder() 195 .Append("blank_iframe.html")
196 .Append("blank_iframe.html") 196 .Append("http_iframe.html")
197 .Append("http_iframe.html") 197 .Append("two_http_iframes.html")
198 .Append("two_http_iframes.html"))); 198 .Build());
199 199
200 if (has_background_process) { 200 if (has_background_process) {
201 manifest.Set( 201 manifest.Set(
202 "background", 202 "background",
203 std::move(DictionaryBuilder().Set( 203 DictionaryBuilder()
204 "scripts", std::move(ListBuilder().Append("script.js"))))); 204 .Set("scripts", ListBuilder().Append("script.js").Build())
205 .Build());
205 dir->WriteFile(FILE_PATH_LITERAL("script.js"), 206 dir->WriteFile(FILE_PATH_LITERAL("script.js"),
206 "console.log('" + name + " running');"); 207 "console.log('" + name + " running');");
207 } 208 }
208 209
209 dir->WriteFile(FILE_PATH_LITERAL("blank_iframe.html"), 210 dir->WriteFile(FILE_PATH_LITERAL("blank_iframe.html"),
210 base::StringPrintf("<html><body>%s, blank iframe:" 211 base::StringPrintf("<html><body>%s, blank iframe:"
211 " <iframe width=80 height=80></iframe>" 212 " <iframe width=80 height=80></iframe>"
212 "</body></html>", 213 "</body></html>",
213 name.c_str())); 214 name.c_str()));
214 std::string iframe_url = 215 std::string iframe_url =
(...skipping 26 matching lines...) Expand all
241 } 242 }
242 243
243 const Extension* CreateHostedApp(const std::string& name, 244 const Extension* CreateHostedApp(const std::string& name,
244 const GURL& app_url) { 245 const GURL& app_url) {
245 scoped_ptr<TestExtensionDir> dir(new TestExtensionDir); 246 scoped_ptr<TestExtensionDir> dir(new TestExtensionDir);
246 247
247 DictionaryBuilder manifest; 248 DictionaryBuilder manifest;
248 manifest.Set("name", name) 249 manifest.Set("name", name)
249 .Set("version", "1.0") 250 .Set("version", "1.0")
250 .Set("manifest_version", 2) 251 .Set("manifest_version", 2)
251 .Set("app", 252 .Set(
252 std::move(DictionaryBuilder() 253 "app",
253 .Set("urls", 254 DictionaryBuilder()
254 std::move(ListBuilder().Append(app_url.spec()))) 255 .Set("urls", ListBuilder().Append(app_url.spec()).Build())
255 .Set("launch", std::move(DictionaryBuilder().Set( 256 .Set("launch",
256 "web_url", app_url.spec()))))); 257 DictionaryBuilder().Set("web_url", app_url.spec()).Build())
258 .Build());
257 dir->WriteManifest(manifest.ToJSON()); 259 dir->WriteManifest(manifest.ToJSON());
258 260
259 const Extension* extension = LoadExtension(dir->unpacked_path()); 261 const Extension* extension = LoadExtension(dir->unpacked_path());
260 EXPECT_TRUE(extension); 262 EXPECT_TRUE(extension);
261 temp_dirs_.push_back(dir.release()); 263 temp_dirs_.push_back(dir.release());
262 return extension; 264 return extension;
263 } 265 }
264 266
265 int GetRenderProcessCount() { 267 int GetRenderProcessCount() {
266 int count = 0; 268 int count = 0;
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 content::NavigateIframeToURL( 1230 content::NavigateIframeToURL(
1229 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); 1231 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html"));
1230 details = new TestMemoryDetails(); 1232 details = new TestMemoryDetails();
1231 details->StartFetchAndWait(); 1233 details->StartFetchAndWait();
1232 EXPECT_THAT(details->uma()->GetAllSamples( 1234 EXPECT_THAT(details->uma()->GetAllSamples(
1233 "SiteIsolation.SiteInstancesPerBrowsingInstance"), 1235 "SiteIsolation.SiteInstancesPerBrowsingInstance"),
1234 DependingOnPolicy(ElementsAre(Bucket(1, 2)), 1236 DependingOnPolicy(ElementsAre(Bucket(1, 2)),
1235 ElementsAre(Bucket(1, 1), Bucket(3, 1)), 1237 ElementsAre(Bucket(1, 1), Bucket(3, 1)),
1236 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); 1238 ElementsAre(Bucket(1, 1), Bucket(5, 1))));
1237 } 1239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698