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

Side by Side Diff: chrome/browser/extensions/scripting_permissions_modifier_unittest.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, 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
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 <utility> 5 #include <utility>
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/extensions/extension_service_test_base.h" 8 #include "chrome/browser/extensions/extension_service_test_base.h"
9 #include "chrome/browser/extensions/extension_util.h" 9 #include "chrome/browser/extensions/extension_util.h"
10 #include "chrome/browser/extensions/permissions_updater.h" 10 #include "chrome/browser/extensions/permissions_updater.h"
(...skipping 24 matching lines...) Expand all
35 scriptable_host_list.Append(pattern->GetAsString()); 35 scriptable_host_list.Append(pattern->GetAsString());
36 } 36 }
37 37
38 ListBuilder explicit_host_list; 38 ListBuilder explicit_host_list;
39 for (std::set<URLPattern>::const_iterator pattern = explicit_hosts.begin(); 39 for (std::set<URLPattern>::const_iterator pattern = explicit_hosts.begin();
40 pattern != explicit_hosts.end(); ++pattern) { 40 pattern != explicit_hosts.end(); ++pattern) {
41 explicit_host_list.Append(pattern->GetAsString()); 41 explicit_host_list.Append(pattern->GetAsString());
42 } 42 }
43 43
44 DictionaryBuilder script; 44 DictionaryBuilder script;
45 script.Set("matches", std::move(scriptable_host_list)) 45 script.Set("matches", scriptable_host_list.Build())
46 .Set("js", std::move(ListBuilder().Append("foo.js"))); 46 .Set("js", ListBuilder().Append("foo.js").Build());
47 47
48 return ExtensionBuilder() 48 return ExtensionBuilder()
49 .SetLocation(location) 49 .SetLocation(location)
50 .SetManifest( 50 .SetManifest(DictionaryBuilder()
51 std::move(DictionaryBuilder() 51 .Set("name", name)
52 .Set("name", name) 52 .Set("description", "foo")
53 .Set("description", "foo") 53 .Set("manifest_version", 2)
54 .Set("manifest_version", 2) 54 .Set("version", "0.1.2.3")
55 .Set("version", "0.1.2.3") 55 .Set("content_scripts",
56 .Set("content_scripts", 56 ListBuilder().Append(script.Build()).Build())
57 std::move(ListBuilder().Append(std::move(script)))) 57 .Set("permissions", explicit_host_list.Build())
58 .Set("permissions", std::move(explicit_host_list)))) 58 .Build())
59 .SetID(crx_file::id_util::GenerateId(name)) 59 .SetID(crx_file::id_util::GenerateId(name))
60 .Build(); 60 .Build();
61 } 61 }
62 62
63 testing::AssertionResult SetsAreEqual(const std::set<URLPattern>& set1, 63 testing::AssertionResult SetsAreEqual(const std::set<URLPattern>& set1,
64 const std::set<URLPattern>& set2) { 64 const std::set<URLPattern>& set2) {
65 // Take the (set1 - set2) U (set2 - set1). This is then the set of all 65 // Take the (set1 - set2) U (set2 - set1). This is then the set of all
66 // elements which are in either set1 or set2, but not both. 66 // elements which are in either set1 or set2, but not both.
67 // If the sets are equal, this is none. 67 // If the sets are equal, this is none.
68 std::set<URLPattern> difference = base::STLSetUnion<std::set<URLPattern>>( 68 std::set<URLPattern> difference = base::STLSetUnion<std::set<URLPattern>>(
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2)); 323 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2));
324 324
325 modifier.RemoveGrantedHostPermission(kUrl); 325 modifier.RemoveGrantedHostPermission(kUrl);
326 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl)); 326 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl));
327 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl2)); 327 EXPECT_FALSE(modifier.HasGrantedHostPermission(kUrl2));
328 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl)); 328 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl));
329 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2)); 329 EXPECT_EQ(PermissionsData::ACCESS_WITHHELD, get_page_access(kUrl2));
330 } 330 }
331 331
332 } // namespace extensions 332 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698