OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/web_request/web_request_permissions.h" | 5 #include "extensions/browser/api/web_request/web_request_permissions.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
9 | 9 |
10 namespace extensions { | 10 namespace extensions { |
11 | 11 |
12 TEST(ExtensionWebRequestPermissions, IsSensitiveURL) { | 12 TEST(ExtensionWebRequestPermissions, IsSensitiveURL) { |
13 struct TestCase { | 13 struct TestCase { |
14 const char* url; | 14 const char* url; |
15 bool is_sensitive; | 15 bool is_sensitive_if_request_from_common_renderer; |
| 16 bool is_sensitive_if_request_from_browser_or_webui_renderer; |
16 } cases[] = { | 17 } cases[] = { |
17 {"http://www.google.com", false}, | 18 {"http://www.google.com", false, false}, |
18 {"http://www.example.com", false}, | 19 {"http://www.example.com", false, false}, |
19 {"http://clients.google.com", true}, | 20 {"http://clients.google.com", false, true}, |
20 {"http://clients4.google.com", true}, | 21 {"http://clients4.google.com", false, true}, |
21 {"http://clients9999.google.com", true}, | 22 {"http://clients9999.google.com", false, true}, |
22 {"http://clients9999..google.com", false}, | 23 {"http://clients9999..google.com", false, false}, |
23 {"http://clients9999.example.google.com", false}, | 24 {"http://clients9999.example.google.com", false, false}, |
24 {"http://clients.google.com.", true}, | 25 {"http://clients.google.com.", false, true}, |
25 {"http://.clients.google.com.", true}, | 26 {"http://.clients.google.com.", false, true}, |
26 {"http://google.example.com", false}, | 27 {"http://google.example.com", false, false}, |
27 {"http://www.example.com", false}, | 28 {"http://www.example.com", false, false}, |
28 {"http://clients.google.com", true}, | 29 {"http://clients.google.com", false, true}, |
29 {"http://sb-ssl.google.com", true}, | 30 {"http://sb-ssl.google.com", true, true}, |
30 {"http://sb-ssl.random.google.com", false}, | 31 {"http://sb-ssl.random.google.com", false, false}, |
31 {"http://chrome.google.com", false}, | 32 {"http://chrome.google.com", false, false}, |
32 {"http://chrome.google.com/webstore", true}, | 33 {"http://chrome.google.com/webstore", true, true}, |
33 {"http://chrome.google.com/webstore?query", true}, | 34 {"http://chrome.google.com/webstore?query", true, true}, |
34 }; | 35 }; |
35 for (const TestCase& test : cases) { | 36 for (const TestCase& test : cases) { |
36 EXPECT_EQ(test.is_sensitive, IsSensitiveURL(GURL(test.url))) << test.url; | 37 EXPECT_EQ( |
| 38 test.is_sensitive_if_request_from_common_renderer, |
| 39 IsSensitiveURL(GURL(test.url), |
| 40 false /* is_request_from_browser_or_webui_renderer */)) |
| 41 << test.url; |
| 42 EXPECT_EQ( |
| 43 test.is_sensitive_if_request_from_browser_or_webui_renderer, |
| 44 IsSensitiveURL(GURL(test.url), |
| 45 true /* is_request_from_browser_or_webui_renderer */)) |
| 46 << test.url; |
37 } | 47 } |
38 } | 48 } |
39 | 49 |
40 } // namespace extensions | 50 } // namespace extensions |
OLD | NEW |