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

Side by Side Diff: chrome/common/extensions/extension_unittest.cc

Issue 7432006: Add an experimental permissions API for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang Created 9 years, 5 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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 hosts = extension->GetEffectiveHostPermissions(); 382 hosts = extension->GetEffectiveHostPermissions();
383 EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com"))); 383 EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com")));
384 EXPECT_TRUE(hosts.MatchesURL(GURL("https://google.com"))); 384 EXPECT_TRUE(hosts.MatchesURL(GURL("https://google.com")));
385 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 385 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
386 386
387 extension = LoadManifest("effective_host_permissions", 387 extension = LoadManifest("effective_host_permissions",
388 "two_content_scripts.json"); 388 "two_content_scripts.json");
389 hosts = extension->GetEffectiveHostPermissions(); 389 hosts = extension->GetEffectiveHostPermissions();
390 EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com"))); 390 EXPECT_TRUE(hosts.MatchesURL(GURL("http://google.com")));
391 EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.reddit.com"))); 391 EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.reddit.com")));
392 EXPECT_TRUE(extension->permission_set()->HasEffectiveAccessToURL( 392 EXPECT_TRUE(extension->GetActivePermissions()->HasEffectiveAccessToURL(
393 GURL("http://www.reddit.com"))); 393 GURL("http://www.reddit.com")));
394 EXPECT_TRUE(hosts.MatchesURL(GURL("http://news.ycombinator.com"))); 394 EXPECT_TRUE(hosts.MatchesURL(GURL("http://news.ycombinator.com")));
395 EXPECT_TRUE(extension->permission_set()->HasEffectiveAccessToURL( 395 EXPECT_TRUE(extension->GetActivePermissions()->HasEffectiveAccessToURL(
396 GURL("http://news.ycombinator.com"))); 396 GURL("http://news.ycombinator.com")));
397 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts()); 397 EXPECT_FALSE(extension->HasEffectiveAccessToAllHosts());
398 398
399 extension = LoadManifest("effective_host_permissions", "all_hosts.json"); 399 extension = LoadManifest("effective_host_permissions", "all_hosts.json");
400 hosts = extension->GetEffectiveHostPermissions(); 400 hosts = extension->GetEffectiveHostPermissions();
401 EXPECT_TRUE(hosts.MatchesURL(GURL("http://test/"))); 401 EXPECT_TRUE(hosts.MatchesURL(GURL("http://test/")));
402 EXPECT_FALSE(hosts.MatchesURL(GURL("https://test/"))); 402 EXPECT_FALSE(hosts.MatchesURL(GURL("https://test/")));
403 EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com"))); 403 EXPECT_TRUE(hosts.MatchesURL(GURL("http://www.google.com")));
404 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts()); 404 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts());
405 405
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 EXPECT_TRUE(Extension::GenerateId("test", &result)); 778 EXPECT_TRUE(Extension::GenerateId("test", &result));
779 EXPECT_EQ(result, "jpignaibiiemhngfjkcpokkamffknabf"); 779 EXPECT_EQ(result, "jpignaibiiemhngfjkcpokkamffknabf");
780 780
781 EXPECT_TRUE(Extension::GenerateId("_", &result)); 781 EXPECT_TRUE(Extension::GenerateId("_", &result));
782 EXPECT_EQ(result, "ncocknphbhhlhkikpnnlmbcnbgdempcd"); 782 EXPECT_EQ(result, "ncocknphbhhlhkikpnnlmbcnbgdempcd");
783 783
784 EXPECT_TRUE(Extension::GenerateId( 784 EXPECT_TRUE(Extension::GenerateId(
785 "this_string_is_longer_than_a_single_sha256_hash_digest", &result)); 785 "this_string_is_longer_than_a_single_sha256_hash_digest", &result));
786 EXPECT_EQ(result, "jimneklojkjdibfkgiiophfhjhbdgcfi"); 786 EXPECT_EQ(result, "jimneklojkjdibfkgiiophfhjhbdgcfi");
787 } 787 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_permission_set_unittest.cc ('k') | chrome/common/extensions/url_pattern_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698