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

Side by Side Diff: extensions/common/permissions/permissions_data_unittest.cc

Issue 510313002: Extensions-related fixups for scoped_refptr conversion operator removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « extensions/common/permissions/permissions_data.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 EXPECT_TRUE(Blocked(extension.get(), about_url)); 657 EXPECT_TRUE(Blocked(extension.get(), about_url));
658 EXPECT_TRUE(Blocked(extension.get(), extension_url)); 658 EXPECT_TRUE(Blocked(extension.get(), extension_url));
659 EXPECT_FALSE(extension->permissions_data()->HasHostPermission(settings_url)); 659 EXPECT_FALSE(extension->permissions_data()->HasHostPermission(settings_url));
660 } 660 }
661 661
662 TEST_F(ExtensionScriptAndCaptureVisibleTest, TabSpecific) { 662 TEST_F(ExtensionScriptAndCaptureVisibleTest, TabSpecific) {
663 scoped_refptr<Extension> extension = 663 scoped_refptr<Extension> extension =
664 LoadManifestStrict("script_and_capture", "tab_specific.json"); 664 LoadManifestStrict("script_and_capture", "tab_specific.json");
665 665
666 const PermissionsData* permissions_data = extension->permissions_data(); 666 const PermissionsData* permissions_data = extension->permissions_data();
667 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(0)); 667 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(0).get());
668 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(1)); 668 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(1).get());
669 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(2)); 669 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(2).get());
670 670
671 std::set<GURL> no_urls; 671 std::set<GURL> no_urls;
672 672
673 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); 673 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0));
674 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); 674 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1));
675 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 675 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
676 676
677 URLPatternSet allowed_hosts; 677 URLPatternSet allowed_hosts;
678 allowed_hosts.AddPattern(URLPattern(URLPattern::SCHEME_ALL, 678 allowed_hosts.AddPattern(URLPattern(URLPattern::SCHEME_ALL,
679 http_url.spec())); 679 http_url.spec()));
(...skipping 12 matching lines...) Expand all
692 EXPECT_EQ(permissions->explicit_hosts(), 692 EXPECT_EQ(permissions->explicit_hosts(),
693 permissions_data->GetTabSpecificPermissionsForTesting(0) 693 permissions_data->GetTabSpecificPermissionsForTesting(0)
694 ->explicit_hosts()); 694 ->explicit_hosts());
695 } 695 }
696 696
697 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), allowed_urls, 0)); 697 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), allowed_urls, 0));
698 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); 698 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1));
699 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 699 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
700 700
701 permissions_data->ClearTabSpecificPermissions(0); 701 permissions_data->ClearTabSpecificPermissions(0);
702 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(0)); 702 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(0).get());
703 703
704 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); 704 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0));
705 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); 705 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1));
706 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 706 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
707 707
708 std::set<GURL> more_allowed_urls = allowed_urls; 708 std::set<GURL> more_allowed_urls = allowed_urls;
709 more_allowed_urls.insert(https_url); 709 more_allowed_urls.insert(https_url);
710 URLPatternSet more_allowed_hosts = allowed_hosts; 710 URLPatternSet more_allowed_hosts = allowed_hosts;
711 more_allowed_hosts.AddPattern(URLPattern(URLPattern::SCHEME_ALL, 711 more_allowed_hosts.AddPattern(URLPattern(URLPattern::SCHEME_ALL,
712 https_url.spec())); 712 https_url.spec()));
(...skipping 16 matching lines...) Expand all
729 permissions_data->GetTabSpecificPermissionsForTesting(1) 729 permissions_data->GetTabSpecificPermissionsForTesting(1)
730 ->explicit_hosts()); 730 ->explicit_hosts());
731 } 731 }
732 732
733 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), allowed_urls, 0)); 733 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), allowed_urls, 0));
734 EXPECT_TRUE( 734 EXPECT_TRUE(
735 ScriptAllowedExclusivelyOnTab(extension.get(), more_allowed_urls, 1)); 735 ScriptAllowedExclusivelyOnTab(extension.get(), more_allowed_urls, 1));
736 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 736 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
737 737
738 permissions_data->ClearTabSpecificPermissions(0); 738 permissions_data->ClearTabSpecificPermissions(0);
739 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(0)); 739 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(0).get());
740 740
741 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); 741 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0));
742 EXPECT_TRUE( 742 EXPECT_TRUE(
743 ScriptAllowedExclusivelyOnTab(extension.get(), more_allowed_urls, 1)); 743 ScriptAllowedExclusivelyOnTab(extension.get(), more_allowed_urls, 1));
744 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 744 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
745 745
746 permissions_data->ClearTabSpecificPermissions(1); 746 permissions_data->ClearTabSpecificPermissions(1);
747 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(1)); 747 EXPECT_FALSE(permissions_data->GetTabSpecificPermissionsForTesting(1).get());
748 748
749 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0)); 749 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 0));
750 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1)); 750 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 1));
751 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2)); 751 EXPECT_TRUE(ScriptAllowedExclusivelyOnTab(extension.get(), no_urls, 2));
752 } 752 }
753 753
754 } // namespace extensions 754 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698