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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc

Issue 899983002: Revert of Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 URLMatcher matcher; 705 URLMatcher matcher;
706 scoped_ptr<WebRequestConditionSet> conditions = 706 scoped_ptr<WebRequestConditionSet> conditions =
707 WebRequestConditionSet::Create( 707 WebRequestConditionSet::Create(
708 NULL, matcher.condition_factory(), rule.conditions, &error); 708 NULL, matcher.condition_factory(), rule.conditions, &error);
709 ASSERT_TRUE(error.empty()) << error; 709 ASSERT_TRUE(error.empty()) << error;
710 ASSERT_TRUE(conditions); 710 ASSERT_TRUE(conditions);
711 711
712 bool bad_message = false; 712 bool bad_message = false;
713 scoped_ptr<WebRequestActionSet> actions = 713 scoped_ptr<WebRequestActionSet> actions =
714 WebRequestActionSet::Create( 714 WebRequestActionSet::Create(
715 NULL, HostID(), NULL, rule.actions, &error, &bad_message); 715 NULL, NULL, rule.actions, &error, &bad_message);
716 ASSERT_TRUE(error.empty()) << error; 716 ASSERT_TRUE(error.empty()) << error;
717 ASSERT_FALSE(bad_message); 717 ASSERT_FALSE(bad_message);
718 ASSERT_TRUE(actions); 718 ASSERT_TRUE(actions);
719 719
720 EXPECT_FALSE(WebRequestRulesRegistry::StageChecker( 720 EXPECT_FALSE(WebRequestRulesRegistry::StageChecker(
721 conditions.get(), actions.get(), &error)); 721 conditions.get(), actions.get(), &error));
722 EXPECT_THAT(error, HasSubstr("no time in the request life-cycle")); 722 EXPECT_THAT(error, HasSubstr("no time in the request life-cycle"));
723 EXPECT_THAT(error, HasSubstr(actions->actions().back()->GetName())); 723 EXPECT_THAT(error, HasSubstr(actions->actions().back()->GetName()));
724 } 724 }
725 725
726 TEST(WebRequestRulesRegistrySimpleTest, HostPermissionsChecker) { 726 TEST(WebRequestRulesRegistrySimpleTest, HostPermissionsChecker) {
727 const char kAction[] = // This action requires all URLs host permission. 727 const char kAction[] = // This action requires all URLs host permission.
728 "{ \n" 728 "{ \n"
729 " \"instanceType\": \"declarativeWebRequest.RedirectRequest\",\n" 729 " \"instanceType\": \"declarativeWebRequest.RedirectRequest\",\n"
730 " \"redirectUrl\": \"http://bar.com\" \n" 730 " \"redirectUrl\": \"http://bar.com\" \n"
731 "} "; 731 "} ";
732 scoped_ptr<base::Value> action_value(base::JSONReader::Read(kAction)); 732 scoped_ptr<base::Value> action_value(base::JSONReader::Read(kAction));
733 ASSERT_TRUE(action_value); 733 ASSERT_TRUE(action_value);
734 734
735 WebRequestActionSet::AnyVector actions; 735 WebRequestActionSet::AnyVector actions;
736 actions.push_back(linked_ptr<base::Value>(action_value.release())); 736 actions.push_back(linked_ptr<base::Value>(action_value.release()));
737 ASSERT_TRUE(actions.back().get()); 737 ASSERT_TRUE(actions.back().get());
738 738
739 std::string error; 739 std::string error;
740 bool bad_message = false; 740 bool bad_message = false;
741 scoped_ptr<WebRequestActionSet> action_set( 741 scoped_ptr<WebRequestActionSet> action_set(
742 WebRequestActionSet::Create( 742 WebRequestActionSet::Create(NULL, NULL, actions, &error, &bad_message));
743 NULL, HostID(), NULL, actions, &error, &bad_message));
744 ASSERT_TRUE(error.empty()) << error; 743 ASSERT_TRUE(error.empty()) << error;
745 ASSERT_FALSE(bad_message); 744 ASSERT_FALSE(bad_message);
746 ASSERT_TRUE(action_set); 745 ASSERT_TRUE(action_set);
747 746
748 scoped_refptr<Extension> extension_no_url( 747 scoped_refptr<Extension> extension_no_url(
749 LoadManifest("permissions", "web_request_no_host.json")); 748 LoadManifest("permissions", "web_request_no_host.json"));
750 scoped_refptr<Extension> extension_some_urls( 749 scoped_refptr<Extension> extension_some_urls(
751 LoadManifest("permissions", "web_request_com_host_permissions.json")); 750 LoadManifest("permissions", "web_request_com_host_permissions.json"));
752 scoped_refptr<Extension> extension_all_urls( 751 scoped_refptr<Extension> extension_all_urls(
753 LoadManifest("permissions", "web_request_all_host_permissions.json")); 752 LoadManifest("permissions", "web_request_all_host_permissions.json"));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 // This is a correct match. 813 // This is a correct match.
815 GURL url2("http://foo.com/index.html"); 814 GURL url2("http://foo.com/index.html");
816 scoped_ptr<net::URLRequest> request2(context.CreateRequest( 815 scoped_ptr<net::URLRequest> request2(context.CreateRequest(
817 url2, net::DEFAULT_PRIORITY, NULL, NULL)); 816 url2, net::DEFAULT_PRIORITY, NULL, NULL));
818 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST); 817 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST);
819 deltas = registry->CreateDeltas(NULL, request_data2, false); 818 deltas = registry->CreateDeltas(NULL, request_data2, false);
820 EXPECT_EQ(1u, deltas.size()); 819 EXPECT_EQ(1u, deltas.size());
821 } 820 }
822 821
823 } // namespace extensions 822 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698