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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc

Issue 12328079: Update TestURLRequest constructor interface in extensions unit tests. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase onto master. Created 7 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 | Annotate | Revision Log
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 "chrome/browser/extensions/api/web_request/web_request_permissions.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/extensions/extension_info_map.h" 8 #include "chrome/browser/extensions/extension_info_map.h"
9 #include "chrome/common/extensions/extension_constants.h" 9 #include "chrome/common/extensions/extension_constants.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 18 matching lines...) Expand all
29 "http://www.gstatic.com/chrome/extensions/blacklist", 29 "http://www.gstatic.com/chrome/extensions/blacklist",
30 "https://www.gstatic.com/chrome/extensions/blacklist", 30 "https://www.gstatic.com/chrome/extensions/blacklist",
31 "notregisteredscheme://www.foobar.com" 31 "notregisteredscheme://www.foobar.com"
32 }; 32 };
33 const char* non_sensitive_urls[] = { 33 const char* non_sensitive_urls[] = {
34 "http://www.google.com/" 34 "http://www.google.com/"
35 }; 35 };
36 // Check that requests are rejected based on the destination 36 // Check that requests are rejected based on the destination
37 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { 37 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) {
38 GURL sensitive_url(sensitive_urls[i]); 38 GURL sensitive_url(sensitive_urls[i]);
39 net::TestURLRequest request(sensitive_url, NULL, &context); 39 net::TestURLRequest request(sensitive_url, NULL, &context, NULL);
40 EXPECT_TRUE( 40 EXPECT_TRUE(
41 WebRequestPermissions::HideRequest(extension_info_map.get(), &request)) 41 WebRequestPermissions::HideRequest(extension_info_map.get(), &request))
42 << sensitive_urls[i]; 42 << sensitive_urls[i];
43 } 43 }
44 // Check that requests are accepted if they don't touch sensitive urls. 44 // Check that requests are accepted if they don't touch sensitive urls.
45 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { 45 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) {
46 GURL non_sensitive_url(non_sensitive_urls[i]); 46 GURL non_sensitive_url(non_sensitive_urls[i]);
47 net::TestURLRequest request(non_sensitive_url, NULL, &context); 47 net::TestURLRequest request(non_sensitive_url, NULL, &context, NULL);
48 EXPECT_FALSE( 48 EXPECT_FALSE(
49 WebRequestPermissions::HideRequest(extension_info_map.get(), &request)) 49 WebRequestPermissions::HideRequest(extension_info_map.get(), &request))
50 << non_sensitive_urls[i]; 50 << non_sensitive_urls[i];
51 } 51 }
52 52
53 // Check protection of requests originating from the frame showing the Chrome 53 // Check protection of requests originating from the frame showing the Chrome
54 // WebStore. 54 // WebStore.
55 // Normally this request is not protected: 55 // Normally this request is not protected:
56 GURL non_sensitive_url("http://www.google.com/test.js"); 56 GURL non_sensitive_url("http://www.google.com/test.js");
57 net::TestURLRequest non_sensitive_request(non_sensitive_url, NULL, &context); 57 net::TestURLRequest non_sensitive_request(
58 non_sensitive_url, NULL, &context, NULL);
58 EXPECT_FALSE(WebRequestPermissions::HideRequest(extension_info_map.get(), 59 EXPECT_FALSE(WebRequestPermissions::HideRequest(extension_info_map.get(),
59 &non_sensitive_request)); 60 &non_sensitive_request));
60 // If the origin is labeled by the WebStoreAppId, it becomes protected. 61 // If the origin is labeled by the WebStoreAppId, it becomes protected.
61 int process_id = 42; 62 int process_id = 42;
62 int site_instance_id = 23; 63 int site_instance_id = 23;
63 int frame_id = 17; 64 int frame_id = 17;
64 net::TestURLRequest sensitive_request(non_sensitive_url, NULL, &context); 65 net::TestURLRequest sensitive_request(
66 non_sensitive_url, NULL, &context, NULL);
65 ResourceRequestInfo::AllocateForTesting(&sensitive_request, 67 ResourceRequestInfo::AllocateForTesting(&sensitive_request,
66 ResourceType::SCRIPT, NULL, process_id, frame_id); 68 ResourceType::SCRIPT, NULL, process_id, frame_id);
67 extension_info_map->RegisterExtensionProcess(extension_misc::kWebStoreAppId, 69 extension_info_map->RegisterExtensionProcess(extension_misc::kWebStoreAppId,
68 process_id, site_instance_id); 70 process_id, site_instance_id);
69 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map.get(), 71 EXPECT_TRUE(WebRequestPermissions::HideRequest(extension_info_map.get(),
70 &sensitive_request)); 72 &sensitive_request));
71 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698