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

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc

Issue 694773003: Allow URL requests for object/embed tags to be intercepted as streams. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-guest-view-container-3
Patch Set: Created 6 years 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_condition.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 EXPECT_EQ(1u, request_data.url_match_ids.size()); 88 EXPECT_EQ(1u, request_data.url_match_ids.size());
89 content::ResourceRequestInfo::AllocateForTesting( 89 content::ResourceRequestInfo::AllocateForTesting(
90 match_request.get(), 90 match_request.get(),
91 content::RESOURCE_TYPE_MAIN_FRAME, 91 content::RESOURCE_TYPE_MAIN_FRAME,
92 NULL, // context 92 NULL, // context
93 -1, // render_process_id 93 -1, // render_process_id
94 -1, // render_view_id 94 -1, // render_view_id
95 -1, // render_frame_id 95 -1, // render_frame_id
96 true, // is_main_frame 96 true, // is_main_frame
97 false, // parent_is_main_frame 97 false, // parent_is_main_frame
98 true, // allow_download
98 false); // is_async 99 false); // is_async
99 EXPECT_TRUE(result->IsFulfilled(request_data)); 100 EXPECT_TRUE(result->IsFulfilled(request_data));
100 101
101 const GURL https_url("https://www.example.com"); 102 const GURL https_url("https://www.example.com");
102 scoped_ptr<net::URLRequest> wrong_resource_type(context.CreateRequest( 103 scoped_ptr<net::URLRequest> wrong_resource_type(context.CreateRequest(
103 https_url, net::DEFAULT_PRIORITY, NULL, NULL)); 104 https_url, net::DEFAULT_PRIORITY, NULL, NULL));
104 data.request = wrong_resource_type.get(); 105 data.request = wrong_resource_type.get();
105 request_data.url_match_ids = matcher.MatchURL(http_url); 106 request_data.url_match_ids = matcher.MatchURL(http_url);
106 // Make sure IsFulfilled does not fail because of URL matching. 107 // Make sure IsFulfilled does not fail because of URL matching.
107 EXPECT_EQ(1u, request_data.url_match_ids.size()); 108 EXPECT_EQ(1u, request_data.url_match_ids.size());
108 content::ResourceRequestInfo::AllocateForTesting( 109 content::ResourceRequestInfo::AllocateForTesting(
109 wrong_resource_type.get(), 110 wrong_resource_type.get(),
110 content::RESOURCE_TYPE_SUB_FRAME, 111 content::RESOURCE_TYPE_SUB_FRAME,
111 NULL, // context 112 NULL, // context
112 -1, // render_process_id 113 -1, // render_process_id
113 -1, // render_view_id 114 -1, // render_view_id
114 -1, // render_frame_id 115 -1, // render_frame_id
115 false, // is_main_frame 116 false, // is_main_frame
116 false, // parent_is_main_frame 117 false, // parent_is_main_frame
118 true, // allow_download
117 false); // is_async 119 false); // is_async
118 EXPECT_FALSE(result->IsFulfilled(request_data)); 120 EXPECT_FALSE(result->IsFulfilled(request_data));
119 } 121 }
120 122
121 TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) { 123 TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
122 // Necessary for TestURLRequest. 124 // Necessary for TestURLRequest.
123 base::MessageLoopForIO message_loop; 125 base::MessageLoopForIO message_loop;
124 URLMatcher matcher; 126 URLMatcher matcher;
125 127
126 std::string error; 128 std::string error;
(...skipping 28 matching lines...) Expand all
155 EXPECT_EQ(1u, request_data.first_party_url_match_ids.size()); 157 EXPECT_EQ(1u, request_data.first_party_url_match_ids.size());
156 content::ResourceRequestInfo::AllocateForTesting( 158 content::ResourceRequestInfo::AllocateForTesting(
157 match_request.get(), 159 match_request.get(),
158 content::RESOURCE_TYPE_MAIN_FRAME, 160 content::RESOURCE_TYPE_MAIN_FRAME,
159 NULL, // context 161 NULL, // context
160 -1, // render_process_id 162 -1, // render_process_id
161 -1, // render_view_id 163 -1, // render_view_id
162 -1, // render_frame_id 164 -1, // render_frame_id
163 true, // is_main_frame 165 true, // is_main_frame
164 false, // parent_is_main_frame 166 false, // parent_is_main_frame
167 true, // allow_download
165 false); // is_async 168 false); // is_async
166 EXPECT_TRUE(result->IsFulfilled(request_data)); 169 EXPECT_TRUE(result->IsFulfilled(request_data));
167 } 170 }
168 171
169 // Conditions without UrlFilter attributes need to be independent of URL 172 // Conditions without UrlFilter attributes need to be independent of URL
170 // matching results. We test here that: 173 // matching results. We test here that:
171 // 1. A non-empty condition without UrlFilter attributes is fulfilled iff its 174 // 1. A non-empty condition without UrlFilter attributes is fulfilled iff its
172 // attributes are fulfilled. 175 // attributes are fulfilled.
173 // 2. An empty condition (in particular, without UrlFilter attributes) is 176 // 2. An empty condition (in particular, without UrlFilter attributes) is
174 // always fulfilled. 177 // always fulfilled.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // filters. 397 // filters.
395 " \"requestHeaders\": [{}], \n" 398 " \"requestHeaders\": [{}], \n"
396 " \"responseHeaders\": [{}], \n" 399 " \"responseHeaders\": [{}], \n"
397 "}"), 400 "}"),
398 &error); 401 &error);
399 EXPECT_FALSE(error.empty()); 402 EXPECT_FALSE(error.empty());
400 EXPECT_FALSE(result.get()); 403 EXPECT_FALSE(result.get());
401 } 404 }
402 405
403 } // namespace extensions 406 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698